2018-12-26 08:45:53 +01: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() {
|
2019-01-03 23:30:27 +01:00
|
|
|
var data = {
|
|
|
|
state: state.get(),
|
|
|
|
bookmarks: bookmarks.get()
|
|
|
|
};
|
|
|
|
set(saveName, JSON.stringify(data));
|
2018-12-27 19:41:40 +01:00
|
|
|
console.log("data saved");
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
var load = function() {
|
2018-12-26 08:45:53 +01:00
|
|
|
var data = JSON.parse(get(saveName));
|
2019-01-03 23:30:27 +01:00
|
|
|
return data;
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2018-12-26 16:24:52 +01:00
|
|
|
var wipe = function() {
|
|
|
|
clear(saveName);
|
|
|
|
};
|
|
|
|
|
2018-12-26 08:45:53 +01:00
|
|
|
return {
|
|
|
|
save: save,
|
|
|
|
clear: clear,
|
|
|
|
set: set,
|
|
|
|
get: get,
|
2018-12-26 16:24:52 +01:00
|
|
|
wipe: wipe,
|
2019-01-03 23:30:27 +01:00
|
|
|
load: load
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|