aboutsummaryrefslogtreecommitdiff
path: root/options/index.js
blob: 3d85dbe4278fac2f8303a538c95e3d92d6894088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function saveOptions(e) {
    e.preventDefault();
    browser.storage.sync.set({
        rb: document.querySelector("#rb").value,
        reader: document.querySelector("#reader").value,
        instance: document.querySelector("#instance").value
    });
}
function restoreOptions() {
    function setCurrentChoice(result) {
        document.querySelector("#rb").value = result.rb || "";
        document.querySelector("#reader").value = result.reader|| "";
        document.querySelector("#instance").value = result.instance || "";
    }
    function onError(error) {
        console.log(`Error: ${error}`);
    }
    let getting = browser.storage.sync.get(["rb", "instance", "reader"]);
    getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);