summaryrefslogtreecommitdiffstats
path: root/assets/js/_helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/_helpers.js')
-rw-r--r--assets/js/_helpers.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/assets/js/_helpers.js b/assets/js/_helpers.js
index 7c50670e..8e18169e 100644
--- a/assets/js/_helpers.js
+++ b/assets/js/_helpers.js
@@ -6,6 +6,7 @@
Array.prototype.find = Array.prototype.find || function (condition) {
return this.filter(condition)[0];
};
+
Array.from = Array.from || function (source) {
return Array.prototype.slice.call(source);
};
@@ -201,15 +202,19 @@ window.helpers = window.helpers || {
if (localStorageIsUsable) {
return {
get: function (key) {
- if (!localStorage[key]) return;
+ let storageItem = localStorage.getItem(key)
+ if (!storageItem) return;
try {
- return JSON.parse(decodeURIComponent(localStorage[key]));
+ return JSON.parse(decodeURIComponent(storageItem));
} catch(e) {
// Erase non parsable value
helpers.storage.remove(key);
}
},
- set: function (key, value) { localStorage[key] = encodeURIComponent(JSON.stringify(value)); },
+ set: function (key, value) {
+ let encoded_value = encodeURIComponent(JSON.stringify(value))
+ localStorage.setItem(key, encoded_value);
+ },
remove: function (key) { localStorage.removeItem(key); }
};
}