function renderElectionFrontpage()

in pysteve/www/htdocs/js/steve_rest.js [844:921]


function renderElectionFrontpage(response, el) {
    var par = document.getElementById('preloaderWrapper')
    par.innerHTML = "";
    
    var title = document.createElement('h1');
    title.innerHTML = response.base_data.title;
    par.appendChild(title);
    
    var issueList = document.createElement('ol');
    issueList.setAttribute("class", "issueList")
    
    var s = 0;
    var ynas = 0;
    response.issues.sort(function(a,b) { return (a.title > b.title)? 1 : -1 } )
    for (i in response.issues) {
        var issue = response.issues[i]
        if (issue.type == "yna") {
            ynas++;
        }
        s++;
        var outer = document.createElement('li');
        // Set style
        outer.setAttribute("class", "issueListItemWide")
        
        var no = document.createElement('div');
        no.setAttribute("class", "issueNumber")
        no.innerHTML = (s)
        
        if (issue.hasVoted) {
            outer.setAttribute("style", "background: linear-gradient(to bottom, #d8d8d8 0%,#aaaaaa 100%); opacity: 0.55;")
            outer.setAttribute("title", "Notice: You have already voted once on this issue. You may recast your vote if you like.")
        } else {
            outer.setAttribute("title", "You have not yet voted on this issue");
        }
        
        // Add issue
        var inner = document.createElement('span')
        var a = issue.id
        while (a.length < 8) {
            a = ' ' + a
        }
        a = a.replace(/\s/g, "&nbsp;")
        inner.innerHTML = a + ": " + issue.title;
        outer.appendChild(no)
        outer.appendChild(inner)
        outer.setAttribute("onclick", "location.href='ballot_" + (issue.category ? issue.category : issue.type.match(/([a-z]+)/)[0]) + ".html?" + el[0] + "/" + issue.id + "/" + (el[1] ? el[1] : "") + "';")
        outer.style.animation = "fadein " + (0.5 +  (s/6)) + "s"
        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 Yes/No issues")
        btn.setAttribute("onclick", "location.href='/bulk_yna.html?" + el[0] + "/" + el[1] + "';")
        par.appendChild(btn)
        var p = document.createElement('p')
        p.innerHTML = "Click on an issue to start voting. As this election has more than one yes/no vote, we have placed a button at the bottom of this page for batch-voting on these issues."
        par.insertBefore(p, title.nextSibling)
    } else {
        var p = document.createElement('p')
        p.innerHTML = "Click on an issue to start voting. You may recast your vote on any issue as often as you like."
        par.insertBefore(p, title.nextSibling)
    }
    
    if (response.base_data.monitors && response.base_data.monitors.length > 0) {
        var p = document.createElement('div')
        p.setAttribute("style", "width: 100%; float: left; text-align: center;")
        p.innerHTML = "Should you experience issues with your voting, or if you have any questions, please don't hesitate to contact the vote monitors: "
        var m = response.base_data.monitors.join(", ")
        p.innerHTML += "<a href='mailto:" + m + "?subject=Issues%20with%20election%20" + response.base_data.id + "%20at%20" + response.baseurl + "'>" + m + "</a>."
        par.appendChild(p)
    }
    
}