diff --git a/index.html b/index.html index 29138a6257de990703fa2b9167a1d2923408d4cf..14ec922b0356778f146411193b88a6a8f281c0da 100644 --- a/index.html +++ b/index.html @@ -83,7 +83,7 @@ - + diff --git a/js/application.js b/js/application.js index a4d310a2579bf9940e3844e9e169d65b705865fe..2c1108e757a0e49af7b9ee48dcc45bd8e61cb806 100644 --- a/js/application.js +++ b/js/application.js @@ -1,4 +1,4 @@ // Wait till the browser is ready to render the game (avoids glitches) window.requestAnimationFrame(function () { - new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager); + new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager); }); diff --git a/js/local_score_manager.js b/js/local_storage_manager.js similarity index 57% rename from js/local_score_manager.js rename to js/local_storage_manager.js index 0f37ec216d321fcbf0307869a138880c314006cf..74e5ee8f4b1f9a14e3035f56e49a2c9461fb4fed 100644 --- a/js/local_score_manager.js +++ b/js/local_storage_manager.js @@ -18,7 +18,7 @@ window.fakeStorage = { } }; -function LocalScoreManager() { +function LocalStorageManager() { this.bestScoreKey = "bestScore"; this.gameStateKey = "gameState"; @@ -26,7 +26,7 @@ function LocalScoreManager() { this.storage = supported ? window.localStorage : window.fakeStorage; } -LocalScoreManager.prototype.localStorageSupported = function () { +LocalStorageManager.prototype.localStorageSupported = function () { var testKey = "test"; var storage = window.localStorage; @@ -39,23 +39,23 @@ LocalScoreManager.prototype.localStorageSupported = function () { } }; -LocalScoreManager.prototype.getBestScore = function () { +LocalStorageManager.prototype.getBestScore = function () { return this.storage.getItem(this.bestScoreKey) || 0; }; -LocalScoreManager.prototype.setBestScore = function (score) { +LocalStorageManager.prototype.setBestScore = function (score) { this.storage.setItem(this.bestScoreKey, score); }; -LocalScoreManager.prototype.getGameState = function () { - var stateJSON = this.storage.getItem(this.gameStateKey); - return stateJSON ? JSON.parse(stateJSON) : null; +LocalStorageManager.prototype.getGameState = function () { + var stateJSON = this.storage.getItem(this.gameStateKey); + return stateJSON ? JSON.parse(stateJSON) : null; }; -LocalScoreManager.prototype.setGameState = function (gameState) { - this.storage.setItem(this.gameStateKey, JSON.stringify(gameState)); +LocalStorageManager.prototype.setGameState = function (gameState) { + this.storage.setItem(this.gameStateKey, JSON.stringify(gameState)); }; -LocalScoreManager.prototype.clearGameState = function () { - this.storage.removeItem(this.gameStateKey); +LocalStorageManager.prototype.clearGameState = function () { + this.storage.removeItem(this.gameStateKey); };