|
|
@ -1,9 +1,11 @@ |
|
|
|
var points = 0; |
|
|
|
var totalRenders = 0; |
|
|
|
function updateDimensions( dimension ){ |
|
|
|
less.modifyVars({"@sizeWidth":dimension+"px"}); |
|
|
|
} |
|
|
|
|
|
|
|
function populateHoneycomb( honeyCells ){ |
|
|
|
function populateHoneycomb( honeyCells , index){ |
|
|
|
|
|
|
|
|
|
|
|
// honeyCells = jsonExample;
|
|
|
|
var height = "innerHeight" in window |
|
|
@ -16,7 +18,7 @@ function populateHoneycomb( honeyCells ){ |
|
|
|
// var cellWidth = ( height/honeyCells.height )*Math.sqrt(3);
|
|
|
|
// if( width/honeyCells.width < height/honeyCells.height ){
|
|
|
|
|
|
|
|
var cellWidth = (width - honeyCells.width)/(honeyCells.width+0.5); |
|
|
|
var cellWidth = (width - honeyCells.width)/(honeyCells.width+0.5); |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
@ -33,10 +35,11 @@ function populateHoneycomb( honeyCells ){ |
|
|
|
honeyCombHorizontal = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var honeyComb = document.getElementById("honeyComb"); |
|
|
|
honeyComb.innerHTML = ""; |
|
|
|
var renderedHoneyComb = document.getElementById("renderedHoneyComb"); |
|
|
|
renderedHoneyComb.innerHTML=""; |
|
|
|
|
|
|
|
honeyComb.innerHTML = "<div class='honeycombIndex'>"+index+"</div>"; |
|
|
|
|
|
|
|
for (var i = honeyCells.height - 1; i >= 0; i--) { |
|
|
|
var even = (i%2 == 0) ? "even" : ""; |
|
|
@ -67,10 +70,29 @@ function populateHoneycomb( honeyCells ){ |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
setFilled( honeyCells, honeyCells.filled, "active" ); |
|
|
|
setFilled( honeyCells, honeyCells.touched, "touched" ); |
|
|
|
setFilled( honeyCells, honeyCells.unit, "unitMember" ); |
|
|
|
|
|
|
|
addHexDetails( honeyCells ); |
|
|
|
|
|
|
|
renderImage( index ); |
|
|
|
totalRenders++; |
|
|
|
removeHexs(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
function addHexDetails( honeyCells ){ |
|
|
|
setFilled( honeyCells, honeyCells.filled, "active" ); |
|
|
|
|
|
|
|
if(honeyCells.touched){ |
|
|
|
setFilled( honeyCells, honeyCells.touched, "touched" ); |
|
|
|
} |
|
|
|
if(honeyCells.unit){ |
|
|
|
setFilled( honeyCells, honeyCells.unit, "unitMember" ); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
function removeHexs(){ |
|
|
|
var honeyComb = document.getElementById("honeyComb"); |
|
|
|
honeyComb.innerHTML = ""; |
|
|
|
} |
|
|
|
function setFilled( honeyCells, cellsToCheck, className ){ |
|
|
|
// honeyCells = jsonExample;
|
|
|
@ -85,6 +107,60 @@ function setFilled( honeyCells, cellsToCheck, className ){ |
|
|
|
honeyCell.className += " "+className; |
|
|
|
}; |
|
|
|
} |
|
|
|
function renderImage(index){ |
|
|
|
html2canvas(document.getElementById("honeyComb")).then(function(canvas) { |
|
|
|
canvas.id = "rendered_"+index; |
|
|
|
canvas.className = "renderedCanvas"; |
|
|
|
if(index == 0){ |
|
|
|
canvas.className += " visible"; |
|
|
|
} |
|
|
|
document.getElementById("renderedHoneyComb").appendChild(canvas); |
|
|
|
totalRenders--; |
|
|
|
if( totalRenders == 0){ |
|
|
|
document.getElementById("controlBar").className += " visible"; |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
function orderRenderedCanvas(){ |
|
|
|
renders = [].slice.call(renders); |
|
|
|
renders.sort(function(a,b){ |
|
|
|
|
|
|
|
if(a.id.split("_")[1] == 0){ |
|
|
|
a.className += " visible"; |
|
|
|
} |
|
|
|
|
|
|
|
if(a.id.split("_")[1] < b.id.split("_")[1] ){ |
|
|
|
return -1; |
|
|
|
} |
|
|
|
}); |
|
|
|
var container = document.getElementById("renderedHoneyComb"); |
|
|
|
container.innerHTML = ""; |
|
|
|
for (var i = 0; i < renders.length; i++) { |
|
|
|
container.appendChild(renders[i]); |
|
|
|
}; |
|
|
|
// 17:43
|
|
|
|
} |
|
|
|
function slideBack(){ |
|
|
|
var actual = document.getElementById("renderedHoneyComb").getElementsByClassName("visible")[0]; |
|
|
|
var actualId = actual.id.split("_")[1]; |
|
|
|
if(actualId > 0){ |
|
|
|
actualId--; |
|
|
|
} |
|
|
|
actual.className = "renderedCanvas"; |
|
|
|
document.getElementById("rendered_"+actualId).className += " visible"; |
|
|
|
} |
|
|
|
|
|
|
|
function slideForward(){ |
|
|
|
var actual = document.getElementById("renderedHoneyComb").getElementsByClassName("visible")[0]; |
|
|
|
var actualId = actual.id.split("_")[1]; |
|
|
|
if(actualId < 10){ |
|
|
|
actualId++; |
|
|
|
} |
|
|
|
actual.className = "renderedCanvas"; |
|
|
|
document.getElementById("rendered_"+actualId).className += " visible"; |
|
|
|
} |
|
|
|
|
|
|
|
function hasClass(el, cls) { |
|
|
|
return el.className && new RegExp("(\\s|^)" + cls + "(\\s|$)").test(el.className); |
|
|
|
} |
|
|
@ -141,7 +217,6 @@ function populateBoard(){ |
|
|
|
listBoard.innerHTML = results; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
function updateLeaderBoard(){ |
|
|
|
loadRankingJs('https://davar.icfpcontest.org/rankings.js?cachebuster='+ new Date().getTime()); |
|
|
|