change local storage support check
change local storage support check

--- a/js/local_score_manager.js
+++ b/js/local_score_manager.js
@@ -18,24 +18,26 @@
   }
 };
 
-function isLocalStorageNameSupported() 
-{
-  var testKey = 'test', storage = window.localStorage;
+function LocalScoreManager() {
+  this.key     = "bestScore";
+
+  var supported = this.localStorageSupported();
+  console.log(supported);
+  this.storage = supported ? window.localStorage : window.fakeStorage;
+}
+
+LocalScoreManager.prototype.localStorageSupported = function () {
+  var testKey = "test";
+  var storage = window.localStorage;
+
   try {
-    storage.setItem(testKey, '1');
+    storage.setItem(testKey, "1");
     storage.removeItem(testKey);
     return true;
-  } 
-  catch (error) {
+  } catch (error) {
     return false;
   }
-}
-
-function LocalScoreManager() {
-  var localSupported = isLocalStorageNameSupported();
-  this.key     = "bestScore";
-  this.storage = localSupported ? window.localStorage : window.fakeStorage;
-}
+};
 
 LocalScoreManager.prototype.get = function () {
   return this.storage.getItem(this.key) || 0;

comments