-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.js
31 lines (28 loc) · 958 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
'use strict';
(function() {
{ // listen radiobuttons "change" event
let radio_buttons = document.querySelectorAll('input[name=dispfmt]');
for (let i = 0; i < radio_buttons.length; i++) {
radio_buttons[i].addEventListener("change", function(e) {
if (radio_buttons[i].checked) {
browser.storage.local.set({"display_format": radio_buttons[i].value});
}
});
}
}
document.addEventListener("DOMContentLoaded", function() {
// load current settings
function setCurrentChoice(result) {
const config_value = result.display_format || "24";
let radio_buttons = document.querySelectorAll('input[name=dispfmt]');
for (let i = 0; i < radio_buttons.length; i++) {
radio_buttons[i].checked = (radio_buttons[i].value == config_value);
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get("display_format");
getting.then(setCurrentChoice, onError);
});
})();