function drawList()

in pysteve/www/htdocs/js/steve_stv.js [370:457]


function drawList() {
    // Remove drag helper
    document.getElementById('candidates').style.background = "";
    
    // Fetch ballot master and clear it
    var ballot = document.getElementById('ballot')
    ballot.innerHTML = ""
    var s = 0;
    
    // For each nominee, do...
    for (i in ballotNames) {
        s++;
        var el = ballotNames[i];
        var outer = document.createElement('li');
        // Set style
        outer.setAttribute("class", "ballotbox")
        
        var no = document.createElement('div');
        no.setAttribute("class", "ballotNumber")
        no.innerHTML = (s)
        
        
        // Above/below cutaway line? If so, draw it
        if (s == seats) {
            outer.style.borderBottom = "1px solid #A00"
        }
        if (s == seats+1) {
            outer.style.borderTop = "1px solid #A00"
        }
        
        // 'grey out' people below cutaway line
        if (s > seats) {
            outer.style.opacity = "0.75"
        }
        
        // Add element and set drag'n'drop + data
        var inner = document.createElement('span')
        inner.style.left = "35px"
        inner.style.maxWidth = "300px"
        inner.style.maxHeight = "60px"
        inner.style.overflow = "hidden"
        inner.innerHTML = ballotChars[i] + ": " + el;
        inner.setAttribute("ondrop", "dropVote(event, true)")
        outer.setAttribute("id", el)
        outer.setAttribute("data", el)
        inner.setAttribute("data", el)
        outer.setAttribute("draggable", "true")
        outer.setAttribute("ondragstart", "dragVote(event)")
        outer.setAttribute("ondragenter", "showLines(event)")
        outer.appendChild(no)
        outer.appendChild(inner)
        outer.setAttribute("title", "Drag to move "  + el + " up or down on the list")
        outer.setAttribute("ondrop", "dropVote(event, false)")
        
        
        if (el == source) {
            outer.style.opacity = "0"
        }
        
        // Add to box
        ballot.appendChild(outer)
    }
    
    // Drop upper and lower filler boxes, so people can drag to the top/bottom of the list as well
    if (!document.getElementById('UPPER')) {
        var d = document.createElement('div');
        d.setAttribute("class", "fillerbox")
        d.setAttribute("data", "UPPER");
        d.setAttribute("id", "UPPER");
        d.setAttribute("ondragenter", "showLines(event)")
        d.setAttribute("ondrop", "dropVote(event, false)")
        insertBefore(d, ballot);
        
        var d = document.createElement('div');
        d.setAttribute("class", "fillerbox")
        d.setAttribute("id", "LOWER")
        d.setAttribute("data", "LOWER");
        d.setAttribute("ondrop", "dropVote(event, false)")
        d.setAttribute("ondragenter", "showLines(event)")
        insertAfter(d, ballot);
    }
    
    // Clear any bad lines
    document.getElementById('UPPER').style.borderTop = "none"
    document.getElementById('LOWER').style.borderBottom = "none"
    document.getElementById('UPPER').style.borderBottom = "none"
    document.getElementById('LOWER').style.borderTop = "none"
}