gPass/firefox_webextension/options.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-04-17 20:39:53 +02:00
var default_preferences = {"pbkdf2_level": 1000,
"account_url": "https://gpass-demo.soutade.fr/demo"
};
2017-04-17 20:39:53 +02:00
function save() {
var account_url = document.getElementById('account_url').value;
var pbkdf2 = document.getElementById('pbkdf2').value;
browser.storage.local.set({
"account_url":account_url,
"pbkdf2_level":pbkdf2,
2017-04-17 20:39:53 +02:00
})
.then(function ok() { alert("Saved"); },
function err() { alert("Cannot save your preferences");}
);
}
function restoreOptions()
{
document.getElementById('account_url').value = default_preferences['account_url'];
document.getElementById('pbkdf2').value = default_preferences['pbkdf2_level'];
browser.storage.local.get().then(
function(prefs)
{
if (prefs.hasOwnProperty("account_url"))
document.getElementById('account_url').value = prefs["account_url"];
if (prefs.hasOwnProperty("pbkdf2_level"))
document.getElementById('pbkdf2').value = prefs["pbkdf2_level"];
}
);
}
document.getElementById('save').addEventListener("click", save);
document.addEventListener("DOMContentLoaded", restoreOptions);