-
Notifications
You must be signed in to change notification settings - Fork 7
/
options.js
39 lines (35 loc) · 959 Bytes
/
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
const form = document.querySelector("form");
const stableButton = document.getElementById("buildChoice1");
const insidersButton = document.getElementById("buildChoice2");
// Using sync storage so other browser sessions will have the settings
function save_options(data) {
const build = data.getAll("build")[0];
chrome.storage.sync.set({
vsCodeBuild: build
}, function () {
console.log(`Preferences saved: ${build}`);
});
}
// Display the user's chosen settings
function restore_options() {
chrome.storage.sync.get({
vsCodeBuild: 'vscode.dev'
}, function (items) {
if (items.vsCodeBuild == 'vscode.dev') {
stableButton.checked = true;
}
else {
insidersButton.checked = true;
}
});
}
document.addEventListener('DOMContentLoaded', restore_options);
form.addEventListener(
"submit",
(event) => {
const data = new FormData(form);
save_options(data);
event.preventDefault();
},
false
);