mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-14 02:26:20 +02:00
39 lines
979 B
JavaScript
39 lines
979 B
JavaScript
// Restores preferences from chrome.storage.
|
|
function restoreOptions() {
|
|
chrome.storage.sync.get(
|
|
{
|
|
preserveLastCode: true,
|
|
replaceNewTab: false
|
|
},
|
|
function(items) {
|
|
document.forms.optionsForm.preserveLastCode.checked =
|
|
items.preserveLastCode;
|
|
document.forms.optionsForm.replaceNewTab.checked = items.replaceNewTab;
|
|
}
|
|
);
|
|
}
|
|
|
|
function saveOptions(e) {
|
|
var preserveLastCode = document.forms.optionsForm.preserveLastCode.checked;
|
|
var replaceNewTab = document.forms.optionsForm.replaceNewTab.checked;
|
|
|
|
chrome.storage.sync.set(
|
|
{
|
|
preserveLastCode: preserveLastCode,
|
|
replaceNewTab: replaceNewTab
|
|
},
|
|
function() {
|
|
var status = document.getElementById('js-status');
|
|
status.textContent = 'Settings saved.';
|
|
setTimeout(function() {
|
|
status.innerHTML = ' ';
|
|
}, 750);
|
|
}
|
|
);
|
|
|
|
e.preventDefault();
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', restoreOptions);
|
|
document.forms.optionsForm.addEventListener('submit', saveOptions);
|