diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/controllers/local-storage-controller.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/controllers/local-storage-controller.js')
-rw-r--r-- | js/controllers/local-storage-controller.js | 50 |
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> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.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 | ||