-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
83 lines (69 loc) · 2 KB
/
options.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* Created by Mardan MEMET ([email protected]) on 28/11/2017.
* GNU General Public License v3.0
*/
var select = document.getElementsByName("select");
var saveBtn = document.getElementById("save");
var mouseSelect = document.getElementById("mouseSelect");
var params = {
"globalSelect": false,
"mouseSelect": false
};
// version info
var manifestData = chrome.runtime.getManifest();
document.getElementById('version').textContent = "version " + manifestData.version;
setParams();
getParams();
function setParams() {
saveBtn.addEventListener('click', function () {
if (select[0].checked) {
params.globalSelect = true;
}
localStorage.setItem('params', JSON.stringify(params));
});
mouseSelect.addEventListener("change", function () {
if (this.checked) {
params.mouseSelect = true;
}
})
}
function getParams() {
var params = localStorage.getItem('params');
params = JSON.parse(params);
if (params && params.globalSelect == true) {
select[0].checked = true;
}
if (params && params.mouseSelect == true) {
mouseSelect.checked = true;
}
}
function restoreOptions() {
chrome.storage.sync.get({
params: {
"global-select": global
}
}, function (items) {
if (items.params['global-select'] == true) {
select[0].checked = true;
}
});
}
function saveOptions() {
saveBtn.addEventListener('click', function () {
if (select[0].checked) {
global = true;
}
chrome.storage.sync.set({
params: {
"global-select": global
}
}, function () {
var status = document.getElementById("status");
status.style.display = "block";
status.textContent = "مەشغۇلات مۇۋاپىققىيەتلىك بولدى";
setTimeout(function() {
status.style.display = "none";
}, 1500);
});
});
}