forked from zombieFox/nightTab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
54 lines (44 loc) · 956 Bytes
/
Copy pathdata.js
File metadata and controls
54 lines (44 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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() {
set(saveName, JSON.stringify(state.get()));
console.log(saveName + " data saved");
};
var restore = function() {
var data = JSON.parse(get(saveName));
if (data) {
bookmarks.restore(data.bookmarks);
theme.restore(data.theme);
control.restore(data.control);
console.log(saveName + " data restored");
};
};
var wipe = function() {
clear(saveName);
};
var init = function() {
if (get(saveName)) {
restore();
} else {
save();
};
};
return {
init: init,
save: save,
clear: clear,
set: set,
get: get,
wipe: wipe,
restore: restore
};
})();