|
|
@ -1,6 +1,8 @@ |
|
|
|
var points = 0; |
|
|
|
function updateDimensions( dimension ){ |
|
|
|
less.modifyVars({"@sizeWidth":dimension+"px"}); |
|
|
|
} |
|
|
|
|
|
|
|
function populateHoneycomb( honeyCells ){ |
|
|
|
|
|
|
|
// honeyCells = jsonExample;
|
|
|
@ -10,8 +12,29 @@ function populateHoneycomb( honeyCells ){ |
|
|
|
var width = "innerWidth" in window |
|
|
|
? window.innerWidth |
|
|
|
: document.documentElement.offsetWidth; |
|
|
|
var cellWidth = (width - honeyCells.width)/(honeyCells.width+0.5); |
|
|
|
|
|
|
|
// var cellWidth = ( height/honeyCells.height )*Math.sqrt(3);
|
|
|
|
// if( width/honeyCells.width < height/honeyCells.height ){
|
|
|
|
|
|
|
|
var cellWidth = (width - honeyCells.width)/(honeyCells.width+0.5); |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
updateDimensions( cellWidth ); |
|
|
|
|
|
|
|
var horizontal = false; |
|
|
|
if(width/height > 1){ |
|
|
|
horizontal = true; |
|
|
|
} |
|
|
|
|
|
|
|
var honeyCombHorizontal = false; |
|
|
|
|
|
|
|
if( honeyCells.width/honeyCells.height > 1){ |
|
|
|
honeyCombHorizontal = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var honeyComb = document.getElementById("honeyComb"); |
|
|
|
honeyComb.innerHTML = ""; |
|
|
|
|
|
|
@ -44,21 +67,98 @@ function populateHoneycomb( honeyCells ){ |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
setFilled( honeyCells ); |
|
|
|
setFilled( honeyCells, honeyCells.filled, "active" ); |
|
|
|
setFilled( honeyCells, honeyCells.touched, "touched" ); |
|
|
|
setFilled( honeyCells, honeyCells.unit, "unitMember" ); |
|
|
|
|
|
|
|
} |
|
|
|
function setFilled( honeyCells ){ |
|
|
|
function setFilled( honeyCells, cellsToCheck, className ){ |
|
|
|
// honeyCells = jsonExample;
|
|
|
|
|
|
|
|
var hexCells = document.getElementsByClassName("hex"); |
|
|
|
|
|
|
|
for (var i = 0; i < honeyCells.filled.length; i++) { |
|
|
|
var x = honeyCells.filled[i].x; |
|
|
|
var y = honeyCells.filled[i].y; |
|
|
|
for (var i = 0; i < cellsToCheck.length; i++) { |
|
|
|
var x = cellsToCheck[i].x; |
|
|
|
var y = cellsToCheck[i].y; |
|
|
|
var filledCell = ( y * honeyCells.width ) + x; |
|
|
|
var honeyCell = hexCells[ filledCell ]; |
|
|
|
honeyCell.className += " disabled"; |
|
|
|
honeyCell.className += " "+className; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function hasClass(el, cls) { |
|
|
|
return el.className && new RegExp("(\\s|^)" + cls + "(\\s|$)").test(el.className); |
|
|
|
} |
|
|
|
function removeClass(ele,cls) { |
|
|
|
if (hasClass(ele,cls)) { |
|
|
|
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); |
|
|
|
ele.className=ele.className.replace(reg,' '); |
|
|
|
} |
|
|
|
} |
|
|
|
function removeId(id) { |
|
|
|
return (elem=document.getElementById(id)).parentNode.removeChild(elem); |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
for (var i = rankings.length - 1; i >= 0; i--) { |
|
|
|
if( rankings[i].teamId == 235 ){ |
|
|
|
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){ |
|
|
|
score = rankings[i].rank; |
|
|
|
ringTheBell(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
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(){ |
|
|
|
var intervalID = setInterval( function(){ |
|
|
|
loadRankingJs('https://davar.icfpcontest.org/rankings.js?cachebuster='+ new Date().getTime()); |
|
|
|
}, 30000); |
|
|
|
|
|
|
|
} |
|
|
|
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(); |
|
|
|
} |
|
|
|
// jsonExample = {"height":15,"width":15,"sourceSeeds":[0],"units":[{"members":[{"x":0,"y":0}],"pivot":{"x":0,"y":0}}],"id":1,"filled":[{"x":2,"y":4},{"x":3,"y":4},{"x":4,"y":4},{"x":5,"y":4},{"x":6,"y":4},{"x":11,"y":4},{"x":2,"y":5},{"x":8,"y":5},{"x":11,"y":5},{"x":2,"y":6},{"x":11,"y":6},{"x":2,"y":7},{"x":3,"y":7},{"x":4,"y":7},{"x":8,"y":7},{"x":11,"y":7},{"x":2,"y":8},{"x":9,"y":8},{"x":11,"y":8},{"x":2,"y":9},{"x":8,"y":9},{"x":2,"y":10},{"x":3,"y":10},{"x":4,"y":10},{"x":5,"y":10},{"x":6,"y":10},{"x":9,"y":10},{"x":11,"y":10}],"sourceLength":100};
|