-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathoptions.js
More file actions
42 lines (33 loc) · 1.36 KB
/
Copy pathoptions.js
File metadata and controls
42 lines (33 loc) · 1.36 KB
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
'use strict';
(async () => {
let config = await loadConfig();
// Dat.GUI config
let guiConfig = {};
guiConfig[ config.timeout.label ] = config.timeout.value;
guiConfig[ config.activeWindow.label ] = config.activeWindow.value;
guiConfig[ config.excludedWebsites.label ] = config.excludedWebsites.value.join(", ");
// Initialize dat.GUI
let gui = new dat.GUI({
autoPlace: false
});
gui.domElement.id = 'gui_css';
// Add timeout setting to dat.GUI, set up event handler
gui.add(guiConfig, config.timeout.label, 1, 60, 1).onChange(onChange);
// Add active window setting to dat.GUI, set up event handler
gui.add(guiConfig, config.activeWindow.label).onChange(onChange);
// Add list of excluded websites setting to dat.GUI, set up event handler
gui.add(guiConfig, config.excludedWebsites.label).onChange(onChange);
// Add dat.GUI to extension UI
document.body.appendChild(gui.domElement);
async function onChange() {
config.timeout.value = guiConfig[ config.timeout.label ];
config.activeWindow.value = guiConfig[ config.activeWindow.label ];
config.excludedWebsites.value = guiConfig[ config.excludedWebsites.label ].split(/[ ,]+/);
saveConfig(config);
}
// Test for clearing local storage
async function clear() {
await browser.storage.local.clear().then(() => console.log('cleared'), e => console.log(e));
}
//
})();