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 += "

Updated "+hour+"h "+minutes+"m "+seconds+"s

"; results += "

Cazziammolla Placement: "+rankings[i].rank+"

"; results += "

with a score of: "+rankings[i].score+"

"; 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 += ""+i+""+settings[i].rankings[j].rank+""+settings[i].rankings[j].score+"" } }; }; var results = ""+results+"
SettingPlacementScore
"; 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(); } }