aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/local-storage-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/local-storage-controller.js')
-rwxr-xr-xjs/controllers/local-storage-controller.js51
1 files changed, 40 insertions, 11 deletions
diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js
index 6963b245..ea763cff 100755
--- a/js/controllers/local-storage-controller.js
+++ b/js/controllers/local-storage-controller.js
@@ -7,7 +7,46 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component;
9 9
10exports.LocalStorage = Montage.create( Montage, { 10exports.LocalStorage = Montage.create( Component, {
11
12 canStore: {
13 value: null
14 },
15
16 deserializedFromTemplate: {
17 value: function() {
18 this.canStore = window.localStorage;
19 this.application.localStorage = this;
20
21 // Redefine setItem and getItem if local storage is not available.
22 if(!this.canStore) {
23 this._getItem = function() {
24 console.log("Local Storage is not supported on your browser");
25 return "";
26 };
27
28 this._setItem = function() {
29 console.log("Local Storage is not supported on your browser");
30 return false;
31 }
32 }
33 }
34 },
35
36 _getItem: {
37 value: function(key) {
38 var value = window.localStorage.getItem("ninja-" + key);
39 if(value !== null) value = JSON.parse(value);
40
41 return value;
42 }
43 },
44
45 _setItem: {
46 value: function(key, value) {
47 window.localStorage.setItem("ninja-" + key, JSON.stringify(value));
48 }
49 },
11 50
12 getItem: { 51 getItem: {
13 value: function(item) { 52 value: function(item) {
@@ -22,16 +61,6 @@ exports.LocalStorage = Montage.create( Montage, {
22 return null; 61 return null;
23 } 62 }
24 63
25 /*
26 if (window.localStorage) {
27 this.getItem = function(item) {
28 return window.localStorage.getItem(item);
29 }(item);
30 } else {
31 alert("Local Storage is not supported on your browser");
32
33 }
34 */
35 } 64 }
36 }, 65 },
37 66