You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

116 lines
3.0 KiB

var currentGame = null;
var infoIsMoving = false;
var infoIsOpen = true;
var instructionsOpen = false;
var testMode = false;
var animationDuration = 300;
function addLevel(HTMLInputElement, add){
HTMLInputElement.blur();
var currentLevelNum = parseInt($("#currentLevel").html());
var newLevelNum = currentLevelNum + add;
$("#currentLevel").html(newLevelNum);
checkLevelButtons(newLevelNum);
currentGame = new Level(newLevelNum);
}
function setRekordInfo(){
for (var i = 1; i <= levelCount; i++){
var bricks = getTotalBricksDestroyed(i);
var time = getRecordTime(i);
time = time == Infinity ? "---" : toTimeString(time);
$("#rekordInfo table:eq(1) tr:eq(" + i + ") td:eq(0)").text(bricks);
$("#rekordInfo table:eq(1) tr:eq(" + i + ") td:eq(2)").text(time);
}
var time = toTimeString(getTotalTimePlayed(), true);
var bricks = getTotalBricksDestroyedGlobal();
$("#totalTimePlayed").text(time);
$("#totalBricksDestroyed").text(bricks);
}
function checkLevelButtons(level) {
$("#levelUp").removeAttr("disabled");
$("#levelUp").css("cursor", "pointer");
$("#levelDown").removeAttr("disabled");
$("#levelDown").css("cursor", "pointer");
if (level == levelCount || level == levelReached + 1){
$("#levelUp").attr("disabled", "disabled");
$("#levelUp").css("cursor", "auto");
}
if (level == 1){
$("#levelDown").attr("disabled", "disabled");
$("#levelDown").css("cursor", "auto");
}
}
function setInfoStyles(){
$("#levelLabel, #currentLevel").css("font-size", String($("#levelSelector").outerHeight() * 0.25) + "px");
$("#levelUp, #levelDown").css("font-size", String($("#levelSelector").outerHeight() * 0.2) + "px");
$("#closeButton").css({
"width": String($("#closeButton").outerHeight()) + "px",
"font-size": String($("#closeButton").outerHeight() * 0.6) + "px"
});
$("#controlsInfo table tr td").css("font-size", String($("#controlsInfo table tr td").innerHeight() * 0.3) + "px");
}
function closeInfo(HTMLInputElement){
try {HTMLInputElement.blur();}catch(e){}
if (infoIsMoving) return;
infoIsMoving = true;
$("#info *").hide();
$("#info").animate({
width: 0
}, animationDuration, function(){
$("#openButton").show();
$("#openButton").animate({
width: 60
}, animationDuration, function(){
infoIsMoving = false;
infoIsOpen = false;
});
});
}
function openInfo(HTMLInputElement){
try {HTMLInputElement.blur();} catch(e) {}
if (infoIsMoving){
return;
}
infoIsMoving = true;
$("#openButton").animate({
width: 0
}, animationDuration, function() {
$("#openButton").hide();
$("#info").animate({
width: 450
}, animationDuration, function() {
$("#info *").show();
infoIsMoving = false;
infoIsOpen = true;
});
});
}
function pauseAnimation(paused){
//TODO
}
function openInstructions(){
$("#instructions").show();
instructionsOpen = true;
}
function closeInstructions(){
$("#instructions").hide();
instructionsOpen = false;
}
function toggleTestMode(){
testMode = !testMode;
}