-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
38 lines (37 loc) · 1.37 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
// Saves options to chrome.storage
function save_options() {
var startTime = document.getElementById('startTime').value;
var endTime = document.getElementById('endTime').value;
var music = document.getElementById('music').checked;
var manual = document.getElementById('manual').checked;
var randomness = document.getElementById('randomness').checked;
chrome.storage.sync.set({
startTime: startTime,
endTime: endTime,
music: music,
manual: manual,
randomness: randomness
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
window.close();
});
}
// stored in chrome.storage.
function restore_options() {
chrome.storage.sync.get({
startTime: '09:00',
endTime: '16:35',
music: false,
manual: false,
randomness: false
}, function(items) {
document.getElementById('startTime').value = items.startTime;
document.getElementById('endTime').value = items.endTime;
document.getElementById('music').checked = items.music;
document.getElementById('manual').checked = items.manual;
document.getElementById('randomness').checked = items.randomness;
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);