1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-29 11:15:09 +00:00
pixelfed/resources/assets/js/components/localstorage.js

33 lines
506 B
JavaScript
Raw Normal View History

2018-05-20 03:11:16 +00:00
window.ls = {};
window.ls.get = function(key) {
return JSON.parse(localStorage.getItem(key));
}
window.ls.set = function(key, val) {
try {
localStorage.setItem(key, JSON.stringify(val));
return true;
} catch(e) {
return false;
}
}
window.ls.del = function(key) {
try {
localStorage.removeItem(key);
return true;
} catch(e) {
return false;
}
}
window.ls.clear = function() {
try {
localStorage.clear();
return true;
} catch(e) {
return false;
}
}