Add app.storage wrapper for handling localStorage
This commit is contained in:
parent
230b406722
commit
351e1a20b1
|
@ -84,6 +84,25 @@ app.template = {
|
|||
},
|
||||
}
|
||||
|
||||
app.storage = {
|
||||
_init: function() {
|
||||
if (localStorage['fedilove'] === undefined)
|
||||
localStorage['fedilove'] = '{}';
|
||||
},
|
||||
get: function(key) {
|
||||
app.storage._init();
|
||||
const js = JSON.parse(localStorage['fedilove']);
|
||||
return js[key];
|
||||
},
|
||||
set: function(key, value) {
|
||||
app.storage._init();
|
||||
const js = JSON.parse(localStorage['fedilove']);
|
||||
js[key] = value;
|
||||
localStorage['fedilove'] = JSON.stringify(js);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
app.overlay = {
|
||||
hideAll: function() {
|
||||
document.querySelectorAll('.overlay')
|
||||
|
|
Loading…
Reference in New Issue