47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
var default_preferences = {"pbkdf2_level": 1000,
|
|
"account_url": "https://gpass-demo.soutade.fr/demo",
|
|
"always_disabled":false,
|
|
"popup_clipboard":false
|
|
};
|
|
|
|
function save() {
|
|
var account_url = document.getElementById('account_url').value;
|
|
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
|
var always_disabled = document.getElementById('always_disabled').checked;
|
|
var popup_clipboard = document.getElementById('popup_clipboard').checked;
|
|
|
|
chrome.storage.local.set({
|
|
'account_url': account_url,
|
|
'pbkdf2_level': pbkdf2_level,
|
|
'always_disabled': always_disabled,
|
|
'popup_clipboard': popup_clipboard,
|
|
}, function() {
|
|
alert('Saved');
|
|
});
|
|
}
|
|
|
|
function restoreOption(preferences, pref)
|
|
{
|
|
var res;
|
|
|
|
if (!preferences.hasOwnProperty(pref))
|
|
res = default_preferences[pref];
|
|
else
|
|
res = preferences[pref];
|
|
|
|
var element = document.getElementById(pref);
|
|
if (element.type == 'checkbox')
|
|
element.checked = res;
|
|
else
|
|
element.value = res;
|
|
}
|
|
|
|
chrome.storage.local.get(null, function(prefs) {
|
|
restoreOption(prefs, 'account_url');
|
|
restoreOption(prefs, 'pbkdf2_level');
|
|
restoreOption(prefs, 'always_disabled');
|
|
restoreOption(prefs, 'popup_clipboard');
|
|
});
|
|
|
|
document.getElementById('save').addEventListener("click", save);
|