From 08c50df9386e4003a76a5fb03a3941516531403f Mon Sep 17 00:00:00 2001 From: Gabriele Cirulli Date: Sat, 22 Mar 2014 15:38:52 +0100 Subject: [PATCH] rename LocalScoreManager to LocalStorageManager --- index.html | 2 +- js/application.js | 2 +- ...re_manager.js => local_storage_manager.js} | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) rename js/{local_score_manager.js => local_storage_manager.js} (57%) diff --git a/index.html b/index.html index 29138a6..14ec922 100644 --- a/index.html +++ b/index.html @@ -83,7 +83,7 @@ - + diff --git a/js/application.js b/js/application.js index a4d310a..2c1108e 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 0f37ec2..74e5ee8 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); }; -- GitLab