Merge remote-tracking branch 'origin/master' into gh-pages
This commit is contained in:
commit
ba3f11c563
35
index.html
35
index.html
|
@ -285,7 +285,6 @@
|
||||||
var gameBoardHeight = 9;
|
var gameBoardHeight = 9;
|
||||||
var score = 0;
|
var score = 0;
|
||||||
var firstClick = true;
|
var firstClick = true;
|
||||||
var currentlyIterating = false;
|
|
||||||
var mineChance = 0.2;
|
var mineChance = 0.2;
|
||||||
var clickholdMs = 200;
|
var clickholdMs = 200;
|
||||||
var timeout; //hold timer
|
var timeout; //hold timer
|
||||||
|
@ -328,6 +327,37 @@
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveGame() {
|
||||||
|
if (typeof(Storage) == "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//variables
|
||||||
|
localStorage.setItem("score", score);
|
||||||
|
localStorage.setItem("mineChance", mineChance);
|
||||||
|
localStorage.setItem("firstClick", firstClick);
|
||||||
|
|
||||||
|
//game board
|
||||||
|
localStorage.setItem("gameBoard", $('#game').html());
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadGame() {
|
||||||
|
//check if storage available and if saved game exists
|
||||||
|
if (typeof(Storage) == "undefined" || localStorage.getItem("gameBoard") == null) {
|
||||||
|
drawGameBoard();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//variables
|
||||||
|
score = parseInt(localStorage.getItem("score"));
|
||||||
|
mineChance = parseFloat(localStorage.getItem("mineChance"));
|
||||||
|
firstClick = (localStorage.getItem("firstClick") == "true");
|
||||||
|
|
||||||
|
//game board
|
||||||
|
$('#game').html(localStorage.getItem("gameBoard"));
|
||||||
|
$('#setup').hide();
|
||||||
|
}
|
||||||
|
|
||||||
$.fn.check = function() {
|
$.fn.check = function() {
|
||||||
//unclicked tiles
|
//unclicked tiles
|
||||||
if ($(this).filter('li:not(.revealed):not(.flagged)').length > 0) {
|
if ($(this).filter('li:not(.revealed):not(.flagged)').length > 0) {
|
||||||
|
@ -748,6 +778,7 @@
|
||||||
|
|
||||||
updateScore();
|
updateScore();
|
||||||
updateMinesLeft();
|
updateMinesLeft();
|
||||||
|
saveGame();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
|
@ -757,7 +788,7 @@
|
||||||
resizeToWindow();
|
resizeToWindow();
|
||||||
|
|
||||||
//instantiate the game
|
//instantiate the game
|
||||||
drawGameBoard();
|
loadGame(); //loadGame will draw the game board if no saved game is found
|
||||||
|
|
||||||
$('#gameOver').hide();
|
$('#gameOver').hide();
|
||||||
$('button.cancel').hide();
|
$('button.cancel').hide();
|
||||||
|
|
Loading…
Reference in New Issue