aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/local-storage-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/local-storage-controller.js')
-rw-r--r--js/controllers/local-storage-controller.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js
new file mode 100644
index 00000000..6963b245
--- /dev/null
+++ b/js/controllers/local-storage-controller.js
@@ -0,0 +1,50 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.LocalStorage = Montage.create( Montage, {
11
12 getItem: {
13 value: function(item) {
14 var item;
15
16 if (window.localStorage) {
17 item = window.localStorage.getItem(item);
18 if(item !== null) return JSON.parse(item)
19 return null;
20 } else {
21 alert("Local Storage is not supported on your browser");
22 return null;
23 }
24
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 }
36 },
37
38 setItem: {
39 value: function(item, value) {
40 if (window.localStorage) {
41 window.localStorage.setItem(item, JSON.stringify(value));
42 return true;
43 } else {
44 alert("Local Storage is not supported on your browser");
45 return false;
46 }
47 }
48 }
49
50}); \ No newline at end of file