summaryrefslogtreecommitdiffstats
path: root/theme/javascript/storage.js
diff options
context:
space:
mode:
Diffstat (limited to 'theme/javascript/storage.js')
-rw-r--r--theme/javascript/storage.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/theme/javascript/storage.js b/theme/javascript/storage.js
index 6861758..7a7643c 100644
--- a/theme/javascript/storage.js
+++ b/theme/javascript/storage.js
@@ -7,10 +7,17 @@ module.exports = {
setBaseKey: function(key) {
baseKey = key;
},
+
+ // Write something in localstorage
set: function(key, value) {
key = baseKey+':'+key;
- localStorage[key] = JSON.stringify(value);
+
+ try {
+ localStorage[key] = JSON.stringify(value);
+ } catch(e) {}
},
+
+ // Read a value from localstorage
get: function(key, def) {
key = baseKey+':'+key;
if (localStorage[key] === undefined) return def;
@@ -21,6 +28,8 @@ module.exports = {
return localStorage[key] || def;
}
},
+
+ // Remove a key from localstorage
remove: function(key) {
key = baseKey+':'+key;
localStorage.removeItem(key);