Mercurial > bugzilla-dashboard
annotate js/modules/cache.js @ 75:312d4af344c2
Fixed cache.js for iPad.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 19:31:19 -0700 |
parents | 55c1b3647357 |
children | 4bb45ff5788a |
rev | line source |
---|---|
66 | 1 Require.modules["cache"] = function(exports, require) { |
2 var window = require("window"); | |
75 | 3 var cache = window.localStorage.getItem("cache"); |
66 | 4 |
75 | 5 if (cache) |
6 cache = JSON.parse(cache); | |
7 else | |
66 | 8 cache = {}; |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
9 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
10 exports.set = function set(key, value) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
11 cache[key] = value; |
75 | 12 |
13 // Remove the key first, to get around a strange iPad | |
14 // issue: http://stackoverflow.com/questions/2603682/is-anyone-else-receiving-a-quota-exceeded-err-on-their-ipad-when-accessing-locals | |
15 window.localStorage.removeItem("cache"); | |
16 | |
17 // TODO: We should really catch QUOTA_EXCEEDED_ERR here, | |
18 // which could be thrown if the user is in private | |
19 // browsing mode. | |
20 window.localStorage.setItem("cache", JSON.stringify(cache)); | |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
21 }; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
22 exports.get = function get(key) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
23 return cache[key]; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
24 }; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
25 }; |