in pysteve/www/htdocs/js/steve_stv.js [133:243]
function drawCandidates() {
var box = document.getElementById('candidates')
box.innerHTML = "<h3>Candidates:</h3>"
for (i in candidates) {
var name = candidates[i]
var char = chars[i]
// Add element and set drag'n'drop + data
var outer = document.createElement('div')
var inner = document.createElement('span')
inner.style.fontFamily = "monospace"
inner.innerHTML = char + ": " + name;
inner.setAttribute("ondrop", "dropCandidate(event, true)")
outer.setAttribute("class", "ballotbox_clist")
outer.setAttribute("id", name)
outer.setAttribute("data", name)
inner.setAttribute("data", name)
inner.setAttribute("draggable", "false")
outer.setAttribute("draggable", "true")
outer.setAttribute("ondragstart", "dragVote(event)")
outer.appendChild(inner)
// if it's a super long name, like a data blob, don't tooltip it
if (name.length > 32) outer.setAttribute("title", "Drag to move the candidate to the ballot box")
else outer.setAttribute("title", "Drag to move " + name + " to the ballot box")
outer.setAttribute("ondrop", "dropCandidate(event, false)")
outer.setAttribute("ondragover", "event.preventDefault();")
outer.setAttribute("ondragend", "event.preventDefault();")
outer.setAttribute("ondragenter", "event.preventDefault();")
// Does the candidate have a statement? if so, put it on there
if (statements[char]) {
var statement = document.createElement('div')
statement.setAttribute("class", "statement_marker")
// if it's a super long name, like a data blob, don't tooltip it
if (name.length > 32) statement.setAttribute("title", "Click to read the candidate's statement")
else statement.setAttribute("title", "Click to read " + name + "'s statement")
statement.setAttribute("onclick", "location.hash='#statement_"+char+"';")
statement.innerHTML = "<a href='#statement_"+char+"'>Statement</a>"
outer.appendChild(statement)
var popup = document.createElement("div")
popup.setAttribute("class", "modal")
popup.setAttribute("id", "statement_" + char)
popup.setAttribute("aria-hidden", "true")
var popupd = document.createElement("div")
popupd.setAttribute("class", "modal-dialog")
popup.appendChild(popupd)
var popuph = document.createElement("div")
popuph.setAttribute("class", "modal-header")
popuph.innerHTML = '<h2>Statement from ' + name + '</h2><a href="#close" class="btn-close" aria-hidden="true">×</a>'
var popupb = document.createElement("div")
popupb.setAttribute("class", "modal-body")
popupb.innerHTML = '<pre>' + (statements[char] ? statements[char] : "This candidate has not prepared a statement") +'</pre>'
var popupf = document.createElement("div")
popupf.setAttribute("class", "modal-footer")
popupf.innerHTML = '<a href="#close" class="btn">Close statement</a>'
popupd.appendChild(popuph)
popupd.appendChild(popupb)
popupd.appendChild(popupf)
document.getElementsByTagName('body')[0].appendChild(popup)
}
// Does the candidate have a nomination and/or seconds? if so, put it on there
if (seconds_txt[char]) {
var seconds = document.createElement('div')
seconds.setAttribute("class", "statement_marker")
seconds.style.float = 'right'
seconds.style.marginRight = '4px'
seconds.setAttribute("title", "Click to read " + name + "'s nomination and/or seconds")
seconds.innerHTML = "<a href='#seconds_"+char+"'>2nds</a>"
outer.appendChild(seconds)
var popup = document.createElement("div")
popup.setAttribute("class", "modal")
popup.setAttribute("id", "seconds_" + char)
popup.setAttribute("aria-hidden", "true")
var popupd = document.createElement("div")
popupd.setAttribute("class", "modal-dialog")
popup.appendChild(popupd)
var popuph = document.createElement("div")
popuph.setAttribute("class", "modal-header")
popuph.innerHTML = '<h2>Nomination/Seconds for ' + name + '</h2><a href="#close" class="btn-close" aria-hidden="true">×</a>'
var popupb = document.createElement("div")
popupb.setAttribute("class", "modal-body")
popupb.innerHTML = '<pre>' + (seconds_txt[char] ? seconds_txt[char] : "This candidate does not have a nomination statement") +'</pre>'
var popupf = document.createElement("div")
popupf.setAttribute("class", "modal-footer")
popupf.innerHTML = '<a href="#close" class="btn">Close window</a>'
popupd.appendChild(popuph)
popupd.appendChild(popupb)
popupd.appendChild(popupf)
document.getElementsByTagName('body')[0].appendChild(popup)
}
box.appendChild(outer)
}
document.getElementById('ballotbox').style.height = box.offsetHeight + "px"
}