diff options
author | Valerio Virgillito | 2012-02-24 13:27:33 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-24 13:27:33 -0800 |
commit | f97080989ee988c1e613915c2d246dc17b104b3b (patch) | |
tree | e8632f5a4537a93263658341cf5941b1baff5ca1 /js/controllers | |
parent | 2b672f6508a849b8023b0bc114ad15e9ddca5adc (diff) | |
download | ninja-f97080989ee988c1e613915c2d246dc17b104b3b.tar.gz |
clearing the old local setting and using the new version/prefix local settings.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/local-storage-controller.js | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js index ea763cff..1388f3e5 100755 --- a/js/controllers/local-storage-controller.js +++ b/js/controllers/local-storage-controller.js | |||
@@ -20,20 +20,25 @@ exports.LocalStorage = Montage.create( Component, { | |||
20 | 20 | ||
21 | // Redefine setItem and getItem if local storage is not available. | 21 | // Redefine setItem and getItem if local storage is not available. |
22 | if(!this.canStore) { | 22 | if(!this.canStore) { |
23 | this._getItem = function() { | 23 | this.getItem = function() { |
24 | console.log("Local Storage is not supported on your browser"); | 24 | console.log("Local Storage is not supported on your browser"); |
25 | return ""; | 25 | return ""; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | this._setItem = function() { | 28 | this.setItem = function() { |
29 | console.log("Local Storage is not supported on your browser"); | 29 | console.log("Local Storage is not supported on your browser"); |
30 | return false; | 30 | return false; |
31 | } | 31 | } |
32 | } | 32 | } |
33 | |||
34 | // Temporary clear the local storage if we find the version key | ||
35 | if(window.localStorage.version) { | ||
36 | window.localStorage.clear(); | ||
37 | } | ||
33 | } | 38 | } |
34 | }, | 39 | }, |
35 | 40 | ||
36 | _getItem: { | 41 | getItem: { |
37 | value: function(key) { | 42 | value: function(key) { |
38 | var value = window.localStorage.getItem("ninja-" + key); | 43 | var value = window.localStorage.getItem("ninja-" + key); |
39 | if(value !== null) value = JSON.parse(value); | 44 | if(value !== null) value = JSON.parse(value); |
@@ -42,38 +47,11 @@ exports.LocalStorage = Montage.create( Component, { | |||
42 | } | 47 | } |
43 | }, | 48 | }, |
44 | 49 | ||
45 | _setItem: { | 50 | setItem: { |
46 | value: function(key, value) { | 51 | value: function(key, value) { |
47 | window.localStorage.setItem("ninja-" + key, JSON.stringify(value)); | 52 | window.localStorage.setItem("ninja-" + key, JSON.stringify(value)); |
48 | } | ||
49 | }, | ||
50 | |||
51 | getItem: { | ||
52 | value: function(item) { | ||
53 | var item; | ||
54 | 53 | ||
55 | if (window.localStorage) { | 54 | return value; |
56 | item = window.localStorage.getItem(item); | ||
57 | if(item !== null) return JSON.parse(item) | ||
58 | return null; | ||
59 | } else { | ||
60 | alert("Local Storage is not supported on your browser"); | ||
61 | return null; | ||
62 | } | ||
63 | |||
64 | } | ||
65 | }, | ||
66 | |||
67 | setItem: { | ||
68 | value: function(item, value) { | ||
69 | if (window.localStorage) { | ||
70 | window.localStorage.setItem(item, JSON.stringify(value)); | ||
71 | return true; | ||
72 | } else { | ||
73 | alert("Local Storage is not supported on your browser"); | ||
74 | return false; | ||
75 | } | ||
76 | } | 55 | } |
77 | } | 56 | } |
78 | |||
79 | }); \ No newline at end of file | 57 | }); \ No newline at end of file |