2017-07-14 05:11:06 +00:00
|
|
|
function saveOptions(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
browser.storage.local.set({
|
2017-07-22 17:47:25 +00:00
|
|
|
instance_url: document.querySelector("#instance_url").value ,
|
|
|
|
window_width: document.querySelector("#window_width").value ,
|
2017-07-26 08:06:36 +00:00
|
|
|
window_height: document.querySelector("#window_height").value,
|
2017-08-12 16:25:57 +00:00
|
|
|
remove_querystrings: document.querySelector("#remove_querystrings").checked,
|
|
|
|
exceptUrlList: document.querySelector("#exceptUrlList").value
|
2017-07-14 05:11:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function restoreOptions() {
|
|
|
|
|
2017-07-22 17:47:25 +00:00
|
|
|
function setCurrentChoices(result) {
|
|
|
|
document.querySelector("#instance_url").value = result["instance_url"] || "http://semanticscuttle.sourceforge.net/";
|
|
|
|
document.querySelector("#window_width").value = result["window_width"] || "640";
|
|
|
|
document.querySelector("#window_height").value = result["window_height"] || "480";
|
2017-07-26 08:06:36 +00:00
|
|
|
document.querySelector("#remove_querystrings").checked = result["remove_querystrings"] || false;
|
2017-08-12 16:25:57 +00:00
|
|
|
document.querySelector("#exceptUrlList").value = result["exceptUrlList"] || "https://www.google.fr,https://www.youtube.com,http://lalist.inist.fr,https://www.qwant.com";
|
2017-07-14 05:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onError(error) {
|
|
|
|
console.log(`Error: ${error}`);
|
|
|
|
}
|
|
|
|
|
2017-08-12 16:25:57 +00:00
|
|
|
var getting = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings","exceptUrlList"]);
|
2017-07-22 17:47:25 +00:00
|
|
|
getting.then(setCurrentChoices, onError);
|
2017-07-14 05:11:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", restoreOptions);
|
|
|
|
document.querySelector("form").addEventListener("submit", saveOptions);
|