nightTab/js/data.js

45 lines
722 B
JavaScript
Raw Normal View History

2018-12-26 07:45:53 +00:00
var data = (function() {
var saveName = "nitghTab";
var set = function(key, data) {
localStorage.setItem(key, data);
};
var get = function(key) {
return localStorage.getItem(key);
};
var clear = function(key) {
localStorage.removeItem(key);
};
var save = function() {
var data = {
state: state.get(),
bookmarks: bookmarks.get()
};
set(saveName, JSON.stringify(data));
2018-12-27 18:41:40 +00:00
console.log("data saved");
2018-12-26 07:45:53 +00:00
};
var load = function() {
2018-12-26 07:45:53 +00:00
var data = JSON.parse(get(saveName));
return data;
2018-12-26 07:45:53 +00:00
};
2018-12-26 15:24:52 +00:00
var wipe = function() {
clear(saveName);
};
2018-12-26 07:45:53 +00:00
return {
save: save,
clear: clear,
set: set,
get: get,
2018-12-26 15:24:52 +00:00
wipe: wipe,
load: load
2018-12-26 07:45:53 +00:00
};
})();