You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2015/03/20 14:37:50 UTC
svn commit: r1668010 - in /steve/trunk/pytest/www/htdocs: bulk_yna.html
css/steve_interactive.css election.html images/vote_a.png images/vote_n.png
images/vote_y.png js/steve_rest.js
Author: humbedooh
Date: Fri Mar 20 13:37:50 2015
New Revision: 1668010
URL: http://svn.apache.org/r1668010
Log:
Start work on bulk YNA voting, tweak some css
Added:
steve/trunk/pytest/www/htdocs/bulk_yna.html
steve/trunk/pytest/www/htdocs/images/vote_a.png (with props)
steve/trunk/pytest/www/htdocs/images/vote_n.png (with props)
steve/trunk/pytest/www/htdocs/images/vote_y.png (with props)
Modified:
steve/trunk/pytest/www/htdocs/css/steve_interactive.css
steve/trunk/pytest/www/htdocs/election.html
steve/trunk/pytest/www/htdocs/js/steve_rest.js
Added: steve/trunk/pytest/www/htdocs/bulk_yna.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/bulk_yna.html?rev=1668010&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/bulk_yna.html (added)
+++ steve/trunk/pytest/www/htdocs/bulk_yna.html Fri Mar 20 13:37:50 2015
@@ -0,0 +1,28 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf8">
+<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/jquery.js" type="text/javascript"></script>
+<script src="js/jquery-ui.js" type="text/javascript"></script>
+<title>Apache STeVe: Bulk voting</title>
+
+</head>
+<body onload="window.setTimeout(loadElection, 1000, null, null, renderElectionBulk);">
+ <div id="popups"></div>
+ <p style="text-align: center;">
+ <img src="/images/steve_logo.png"/>
+ </p>
+<div class="formbox">
+
+<div id="preloaderWrapper">
+ <img src="/images/steve_spinner.gif"/>
+ <div id="preloader">
+ Loading issues, please wait...
+ </div>
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file
Modified: steve/trunk/pytest/www/htdocs/css/steve_interactive.css
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/css/steve_interactive.css?rev=1668010&r1=1668009&r2=1668010&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/css/steve_interactive.css (original)
+++ steve/trunk/pytest/www/htdocs/css/steve_interactive.css Fri Mar 20 13:37:50 2015
@@ -65,10 +65,11 @@ p {
padding: 4px 8px;
text-decoration: none;
text-align: center;
- min-width: 50px;
+ min-width: 30px;
position: relative;
transition: color .1s ease;
cursor: pointer;
+ margin-left: 10px;
}
.btn-red:hover {
background: #d5421b !important;
@@ -86,16 +87,41 @@ p {
padding: 4px 8px;
text-decoration: none;
text-align: center;
- min-width: 50px;
+ min-width: 30px;
position: relative;
transition: color .2s ease;
cursor: pointer;
+ margin-left: 10px;
}
.btn-green:hover {
background: #52Aa2b !important;
transition: 0.3s ease;
}
+
+.btn-yellow {
+ font-weight: bold;
+ background: #daba3b !important;
+ border: #328a2b solid 1px;
+ border-radius: 3px;
+ color: #fff !important;
+ display: inline-block;
+ font-size: 14px;
+ padding: 4px 8px;
+ text-decoration: none;
+ text-align: center;
+ min-width: 30px;
+ position: relative;
+ transition: color .2s ease;
+ cursor: pointer;
+ margin-left: 10px;
+}
+
+.btn-yellow:hover {
+ background: #eaca3b !important;
+ transition: 0.3s ease;
+}
+
.btn:hover {
background: #357ebd;
}
@@ -331,7 +357,7 @@ body, html {
border-radius: 5px;
border: 2px solid #333;
box-shadow: 3px 4px 4px 0px rgba(153,153,153,1);
- width: 800px;
+ min-width: 800px;
}
.formbox h2 {
@@ -377,6 +403,11 @@ fieldset legend {
.issueList {
text-align: left !important;
list-style: none;
+ margin: 0 auto;
+}
+
+.issueList input {
+ min-width: 30px;
}
.issueListItem {
@@ -388,6 +419,19 @@ fieldset legend {
font-family: monospace;
font-size: 16px;
background: linear-gradient(to bottom, #f8f8f8 0%,#dddddd 100%);
+ -khtml-user-drag: element;
+ animation: fadein 1s
+}
+
+
+.issueListItemWide {
+ border: 1px dotted #666;
+ padding: 4px;
+ width: 980px;
+ min-height: 25px;
+ font-family: monospace;
+ font-size: 16px;
+ background: linear-gradient(to bottom, #f8f8f8 0%,#dddddd 100%);
-khtml-user-drag: element;
animation: fadein 1s
}
Modified: steve/trunk/pytest/www/htdocs/election.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/election.html?rev=1668010&r1=1668009&r2=1668010&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/election.html (original)
+++ steve/trunk/pytest/www/htdocs/election.html Fri Mar 20 13:37:50 2015
@@ -10,7 +10,7 @@
<title>Apache STeVe: Election viewer</title>
</head>
-<body onload="window.setTimeout(loadElection, 1000);">
+<body onload="window.setTimeout(loadElection, 1000, null, null, renderElectionFrontpage);">
<div id="popups"></div>
<p style="text-align: center;">
<img src="/images/steve_logo.png"/>
Added: steve/trunk/pytest/www/htdocs/images/vote_a.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/vote_a.png?rev=1668010&view=auto
==============================================================================
Binary file - no diff available.
Propchange: steve/trunk/pytest/www/htdocs/images/vote_a.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: steve/trunk/pytest/www/htdocs/images/vote_n.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/vote_n.png?rev=1668010&view=auto
==============================================================================
Binary file - no diff available.
Propchange: steve/trunk/pytest/www/htdocs/images/vote_n.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: steve/trunk/pytest/www/htdocs/images/vote_y.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/vote_y.png?rev=1668010&view=auto
==============================================================================
Binary file - no diff available.
Propchange: steve/trunk/pytest/www/htdocs/images/vote_y.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: steve/trunk/pytest/www/htdocs/js/steve_rest.js
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/js/steve_rest.js?rev=1668010&r1=1668009&r2=1668010&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/js/steve_rest.js (original)
+++ steve/trunk/pytest/www/htdocs/js/steve_rest.js Fri Mar 20 13:37:50 2015
@@ -175,7 +175,7 @@ function createIssue(election) {
var step = 0;
var election_data = null
-function loadElection(election, uid) {
+function loadElection(election, uid, callback) {
var messages = ["Herding cats...", "Shaving yaks...", "Shooing some cows away...", "Fetching election data...", "Loading issues..."]
if (!election || !uid) {
@@ -184,7 +184,7 @@ function loadElection(election, uid) {
uid = l[1] ? l[1] : "";
}
if (step == 0) {
- getJSON("/steve/voter/view/" + election + "?uid=" + uid, [election,uid], displayElection)
+ getJSON("/steve/voter/view/" + election + "?uid=" + uid, [election,uid, callback], displayElection)
}
var obj = document.getElementById('preloader');
@@ -196,18 +196,18 @@ function loadElection(election, uid) {
}
if (step % 2 == 1) {
obj.style.transform = "translate(0,0)"
- } else {
+ } else if (obj) {
obj.style.transform = "translate(0,-500%)"
}
if (!election_data|| (step % 2 == 0) ) {
- window.setTimeout(loadElection, 750);
+ window.setTimeout(loadElection, 750, election, uid, callback);
}
}
function displayElection(code, response, el) {
election_data = response
if (code == 200) {
- window.setTimeout(renderElectionFrontpage, 2000, response, el);
+ window.setTimeout(el[2], 2000, response, el);
} else {
document.getElementById('preloaderWrapper').innerHTML = "<h1>Sorry, an error occured while fetching election data:</h1><h2>" + response.message + "</h2>"
}
@@ -225,8 +225,12 @@ function renderElectionFrontpage(respons
issueList.setAttribute("class", "issueList")
var s = 0;
+ var ynas = 0;
for (i in response.issues) {
var issue = response.issues[i]
+ if (issue.type == "yna") {
+ ynas++;
+ }
s++;
var outer = document.createElement('li');
// Set style
@@ -246,4 +250,118 @@ function renderElectionFrontpage(respons
issueList.appendChild(outer)
}
par.appendChild(issueList)
+
+ if (ynas > 1) {
+ var btn = document.createElement("input")
+ btn.setAttribute("type", "button")
+ btn.setAttribute("class", "btn-green")
+ btn.setAttribute("style", "margin: 30px;")
+ btn.setAttribute("value", "Bulk vote on YNA issues")
+ btn.setAttribute("onclick", "location.href='/bulk_yna.html?" + el[0] + "/" + el[1] + "';")
+ par.appendChild(btn)
+ }
+
+}
+
+
+
+
+function renderElectionBulk(response, el) {
+ var par = document.getElementById('preloaderWrapper')
+ par.innerHTML = "";
+ par.setAttribute("id", "contents")
+
+ var title = document.createElement('h1');
+ title.innerHTML = "Bulk YNA voting for: " + response.base_data.title;
+ par.appendChild(title);
+
+ var issueList = document.createElement('ol');
+ issueList.setAttribute("class", "issueList")
+
+ var s = 0;
+ var ynas = 0;
+ for (i in response.issues) {
+ var issue = response.issues[i]
+ if (issue.type == "yna") {
+
+ s++;
+ var outer = document.createElement('li');
+ // Set style
+ outer.setAttribute("class", "issueListItemWide")
+
+ var no = document.createElement('div');
+ no.setAttribute("class", "issueNumber")
+ no.innerHTML = (s)
+
+ // Add issue
+ var inner = document.createElement('span')
+ inner.innerHTML = issue.id + ": " + issue.title;
+ outer.appendChild(no)
+ outer.appendChild(inner)
+ outer.style.height = "32px"
+ outer.style.marginBottom = "15px"
+
+ // details
+ var statement = document.createElement('div')
+ statement.setAttribute("class", "statement_marker")
+ statement.style.float = "left"
+ statement.setAttribute("title", "Click to read issue details")
+ statement.innerHTML = "<a href='#details_"+issue.id+"'>Details</a>"
+ outer.appendChild(statement)
+
+ 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", "castVote('" + el[0] + "', '" + issue.id + "', '" + el[1] + "', '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", "castVote('" + el[0] + "', '" + issue.id + "', '" + el[1] + "', '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", "castVote('" + el[0] + "', '" + issue.id + "', '" + el[1] + "', 'a');")
+
+ var mark = document.createElement('img');
+ mark.setAttribute("width", "26")
+ mark.setAttribute("height", "32")
+ mark.setAttribute("style", "float: right; margin-left: 10px;")
+ mark.setAttribute("id", "mark_" + issue.id)
+
+ inner.appendChild(mark)
+ inner.appendChild(no)
+ inner.appendChild(abstain)
+ inner.appendChild(yes)
+ outer.style.animation = "fadein " + (0.5 + (s/6)) + "s"
+ issueList.appendChild(outer)
+ }
+ }
+ par.appendChild(issueList)
+
+}
+
+function castVote(election, issue, uid, vote) {
+ var mark = document.getElementById('mark_' + issue);
+ if (mark) {
+ mark.setAttribute("src", "/images/vote_" + vote[0] + ".png")
+ }
+ postREST("/steve/voter/vote/" + election + "/" + issue, {
+ uid: uid,
+ vote: vote
+ },
+ undefined,
+ castVoteCallback,
+ issue)
+}
+
+function castVoteCallback(code, response, issue) {
+
}
\ No newline at end of file