function renderEditElection()

in pysteve/www/htdocs/js/steve_rest.js [123:166]


function renderEditElection(code, response, election) {
    if (code == 200) {
        var c = response.base_data.closed ? " (<font color='red'>CLOSED!</font>)" : ""
        document.getElementById('title').innerHTML = "Edit election: " + response.base_data.title + " (#" + election  + ")" + c
        
        if (response.base_data.closed) {
            document.getElementById('invite_btn').setAttribute("style", "pointer-events:none; background: #999 !important; color: #bbb !important;")
            document.getElementById('invite_btn').setAttribute("href", null)
            document.getElementById('cue').setAttribute("style", "pointer-events:none; background: #999 !important; color: #bbb !important;")
            document.getElementById('cue').setAttribute("href", null)
            document.getElementById('closea').setAttribute("href", "javascript:void(location.href='reopen.html'+document.location.search);");
            document.getElementById('closex').innerHTML = "Reopen"
            document.getElementById('closea').setAttribute("title", "Click to reopen this election")
        }
        var obj = document.getElementById('ballot')
        obj.innerHTML = "There are no issues in this election yet"
        var s = 0;
        if (response.issues && response.issues.length > 0) {
            obj.innerHTML = "";
        }
        response.issues.sort(function(a,b) { return (a.title > b.title)? 1 : -1 } )
        for (i in response.issues) {
            var issue = response.issues[i]
            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.setAttribute("onclick", "location.href='edit_issue.html?" + election + "/" + issue.id + "';")
            obj.appendChild(outer)
        }
    } else {
        alert("Could not load election data: " + response.message)
    }
}