-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
26 lines (20 loc) · 713 Bytes
/
options.js
File metadata and controls
26 lines (20 loc) · 713 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
function saveOptions(e) {
e.preventDefault();
browser.storage.local.set({
lbs: document.querySelector("#lbs").checked,
fahrenheit: document.querySelector("#fahrenheit").checked
});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#lbs").checked = result.lbs;// || true;
document.querySelector("#fahrenheit").checked = result.fahrenheit;// || true;
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get();
getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);