|
|
@ -0,0 +1,86 @@ |
|
|
|
|
|
|
|
function toggleLeaderBoard(){ |
|
|
|
var leaderBoard = document.getElementById("leaderBoard"); |
|
|
|
if( hasClass(leaderBoard, "open")){ |
|
|
|
removeClass(leaderBoard, "open"); |
|
|
|
}else{ |
|
|
|
leaderBoard.className += " open"; |
|
|
|
} |
|
|
|
updateLeaderBoard() |
|
|
|
} |
|
|
|
function populateBoard(){ |
|
|
|
var listBoard = document.getElementById("listBoard"); |
|
|
|
var results = ""; |
|
|
|
var rankings = data.data.rankings; |
|
|
|
var date = new Date(); |
|
|
|
var seconds = date.getSeconds(); |
|
|
|
var minutes = date.getMinutes(); |
|
|
|
var hour = date.getHours(); |
|
|
|
|
|
|
|
for (var i = rankings.length - 1; i >= 0; i--) { |
|
|
|
if( rankings[i].teamId == 235 ){ |
|
|
|
|
|
|
|
results += "<p>Updated "+hour+"h "+minutes+"m "+seconds+"s</p>"; |
|
|
|
results += "<h1>Cazziammolla Placement: "+rankings[i].rank+"</h1>"; |
|
|
|
results += "<h2>with a score of: "+rankings[i].score+"</h2>"; |
|
|
|
if (rankings[i].rank != points && points != 0){ |
|
|
|
ringTheBell(); |
|
|
|
} |
|
|
|
points = rankings[i].rank; |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var settings = data.data.settings; |
|
|
|
for (var i = 0; i < settings.length; i++) { |
|
|
|
for (var j = settings[i].rankings.length - 1; j >= 0; j--) { |
|
|
|
if(settings[i].rankings[j].teamId == 235){ |
|
|
|
results += "<tr><td>"+i+"</td><td>"+j+"</td></tr>" |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
var results = "<table><thead><th>Setting</th><th>Placement</th></thead>"+results+"</table>"; |
|
|
|
listBoard.innerHTML = results; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
function updateLeaderBoard(){ |
|
|
|
loadRankingJs('https://davar.icfpcontest.org/rankings.js?cachebuster='+ new Date().getTime()); |
|
|
|
|
|
|
|
var intervalID = setInterval( function(){ |
|
|
|
loadRankingJs('https://davar.icfpcontest.org/rankings.js?cachebuster='+ new Date().getTime()); |
|
|
|
}, 30000); |
|
|
|
console.dir(intervalID); |
|
|
|
} |
|
|
|
function loadRankingJs(scriptName) { |
|
|
|
var rankingScript = document.getElementById("rankingScript"); |
|
|
|
if ( rankingScript ){ |
|
|
|
removeId("rankingScript"); |
|
|
|
} |
|
|
|
var docHeadObj = document.getElementsByTagName("head")[0]; |
|
|
|
var dynamicScript = document.createElement("script"); |
|
|
|
dynamicScript.type = "text/javascript"; |
|
|
|
dynamicScript.id = "rankingScript"; |
|
|
|
dynamicScript.src = scriptName; |
|
|
|
dynamicScript.onload = function(){ populateBoard();}; |
|
|
|
docHeadObj.appendChild(dynamicScript); |
|
|
|
|
|
|
|
return dynamicScript; |
|
|
|
} |
|
|
|
|
|
|
|
function ringTheBell(){ |
|
|
|
document.getElementById("bell").play(); |
|
|
|
} |
|
|
|
document.onkeydown = checkKey; |
|
|
|
|
|
|
|
|
|
|
|
function checkKey(e) { |
|
|
|
|
|
|
|
e = e || window.event; |
|
|
|
|
|
|
|
if (e.keyCode == '37') { |
|
|
|
slideBack(); |
|
|
|
}else if(e.keyCode == '39') { |
|
|
|
slideForward(); |
|
|
|
} |
|
|
|
} |