Author: humbedooh
Date: Tue Mar 24 10:39:25 2015
New Revision: 1668839
URL: http://svn.apache.org/r1668839
Log:
Add page and functionality for doing single issue YNA voting.
Added:
steve/trunk/pysteve/www/htdocs/ballot_yna.html
Modified:
steve/trunk/pysteve/www/htdocs/css/steve_interactive.css
steve/trunk/pysteve/www/htdocs/js/steve_rest.js
Added: steve/trunk/pysteve/www/htdocs/ballot_yna.html
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/ballot_yna.html?rev=1668839&view=auto
==============================================================================
--- steve/trunk/pysteve/www/htdocs/ballot_yna.html (added)
+++ steve/trunk/pysteve/www/htdocs/ballot_yna.html Tue Mar 24 10:39:25 2015
@@ -0,0 +1,39 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="css/steve_interactive.css">
+<link rel="stylesheet" href="css/jquery-ui.css">
+<script src="js/steve_rest.js" type="text/javascript"></script>
+<script src="js/steve_stv.js" type="text/javascript"></script>
+<script src="js/jquery.js" type="text/javascript"></script>
+<script src="js/jquery-ui.js" type="text/javascript"></script>
+<title>Apache STeVe: YNA vote</title>
+
+</head>
+<body onload="window.setTimeout(loadIssue, 500, null, null, null,
displayIssueYNA);">
+ <div id="popups"></div>
+ <p style="text-align: center;">
+ <img src="/images/steve_logo.png"/>
+ </p>
+ <a href="javascript:void(location.href='election.html' +
document.location.search);">Back to election front page</a>
+<div class="formbox">
+ <p>
+ This is a standard YNA (Yes/No/Abstain) vote. If you agree with the
motion put forward, vote <kbd>Yes</kbd>. If you disagree, vote <kbd>No</kbd>.
+ If you neither agree nor disagree, you can mark your ballot as blank
by clicking on <kbd>Abstain</kbd>. For some elections where the number of votes
+ are important, abstaining on a vote you have no preference for/against
can help reach quorum.
+ </p>
+<div id="preloaderWrapper">
+ <img src="/images/steve_spinner.gif"/>
+ <div id="preloader">
+ Loading issue, please wait...
+ </div>
+</div>
+</div>
+<p style="font-size: 12px; font-style: italic; text-align: center;">
+ Powered by <a href="https://steve.apache.org/">Apache STeVe</a>.
+ Copyright 2015, the Apache Software Foundation.
+ Licensed under the <a
href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>
+</p>
+</body>
+</html>
\ No newline at end of file
Modified: steve/trunk/pysteve/www/htdocs/css/steve_interactive.css
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/css/steve_interactive.css?rev=1668839&r1=1668838&r2=1668839&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/css/steve_interactive.css (original)
+++ steve/trunk/pysteve/www/htdocs/css/steve_interactive.css Tue Mar 24
10:39:25 2015
@@ -339,6 +339,22 @@ pre {
position: static;
}
+kbd {
+ font-weight: bold;
+ color: #369;
+ font-size: 16px;
+}
+
+
+.statement {
+ border: 1px dotted #333;
+ background: linear-gradient(to bottom, #eeeecc 0%,#f2f6fc 100%);
+ overflow: auto;
+ max-width: 800px;
+ min-height: 100px;
+ max-height: 400px;
+}
+
.statement_marker a {
color: #fff;
}
Modified: steve/trunk/pysteve/www/htdocs/js/steve_rest.js
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/js/steve_rest.js?rev=1668839&r1=1668838&r2=1668839&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/js/steve_rest.js (original)
+++ steve/trunk/pysteve/www/htdocs/js/steve_rest.js Tue Mar 24 10:39:25 2015
@@ -247,6 +247,20 @@ function keyvaluepair(name, text, type,
return obj
}
+function keyvaluepairText(name, key, value) {
+ var obj = document.createElement('div')
+ obj.setAttribute("class", "keyvaluepair");
+ var txt = document.createElement('div');
+ txt.setAttribute("class", "keyfield")
+ txt.innerHTML = key
+ obj.appendChild(txt)
+ var val = document.createElement('div')
+ val.innerHTML = value
+ obj.appendChild(val)
+
+ return obj
+}
+
function saveCallback(code, response, election) {
if (code == 200) {
alert("Changes saved")
@@ -841,4 +855,88 @@ function showElections(code, response, s
outer.setAttribute("onclick",
"location.href='edit_election.html?" + election.id + "';")
ol.appendChild(outer)
}
+}
+
+
+
+function castSingleVote(vote) {
+ var l = document.location.search.substr(1).split("/");
+ election = l[0];
+ issue = l.length > 1 ? l[l.length-2] : "";
+ uid = l.length > 2 ? l[l.length-1] : "";
+ postREST("/steve/voter/vote/" + election + "/" + issue, {
+ uid: uid,
+ vote: vote
+ },
+ undefined,
+ castSingleVoteCallback,
+ null)
+}
+
+function castSingleVoteCallback(code, response, state) {
+ if (code != 200) {
+ alert(response.message)
+ } else {
+ document.getElementById('ynavote').innerHTML = "<h2>Your vote has been
registered!</h2><p style='text-align:center;'><big>Should you reconsider, you
can always reload this page and vote again.<br/><br/><a
href=\"javascript:void(location.href='election.html'+document.location.search);\">Back
to election front page</a></big></p>"
+ }
+}
+
+
+
+
+function displayIssueYNA(code, response, state) {
+ election_data = response
+ var obj = document.getElementById('preloaderWrapper')
+ obj.setAttribute("id", "ynavote")
+ if (code != 200) {
+ obj.innerHTML = "<h1>Could not load issue:</h1><h2>" +
response.message + "</h2>";
+ } else {
+ obj.innerHTML = ""
+
+ var title = document.createElement('h2')
+ title.innerHTML = response.issue.title;
+ obj.appendChild(title)
+
+ obj.appendChild(keyvaluepairText("nominatedby", "Put forward
(nominated) by:", response.issue.nominatedby))
+ obj.appendChild(keyvaluepairText("seconds", "Seconded by:",
response.issue.seconds.length > 0 ? response.issue.seconds.join(", ") :
"no-one" ))
+
+ var desc = document.createElement('pre')
+ desc.setAttribute("class", "statement")
+ desc.innerHTML = response.issue.description
+ obj.appendChild(desc)
+
+ var outer = document.createElement('div')
+ outer.setAttribute("class", "issueListItem")
+
+ var yes = document.createElement('input')
+ yes.setAttribute("type", "button")
+ yes.setAttribute("value", "Yes")
+ yes.setAttribute("class", "btn-green")
+ yes.setAttribute("style", "float: right;");
+ yes.setAttribute("onclick", "castSingleVote('y');")
+
+ var no = document.createElement('input')
+ no.setAttribute("type", "button")
+ no.setAttribute("value", "No")
+ no.setAttribute("class", "btn-red")
+ no.setAttribute("style", " float: right;");
+ no.setAttribute("onclick", "castSingleVote('n');")
+
+ var abstain = document.createElement('input')
+ abstain.setAttribute("type", "button")
+ abstain.setAttribute("value", "Abstain")
+ abstain.setAttribute("class", "btn-yellow")
+ abstain.setAttribute("style", "float: right;");
+ abstain.setAttribute("onclick", "castSingleVote('a');")
+
+ var p = document.createElement('p')
+ p.innerHTML = "Cast your vote by clicking on the respective
button below. You may recast your vote as many time as you like, should you
reconsider."
+
+ obj.appendChild(p)
+ outer.appendChild(no)
+ outer.appendChild(abstain)
+ outer.appendChild(yes)
+
+ obj.appendChild(outer)
+ }
}
\ No newline at end of file