You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
5 years ago
|
// Saves options to chrome.storage
|
||
|
function save_options() {
|
||
|
var frontend_url = document.getElementById('frontend_url').value;
|
||
|
var audio_only = document.getElementById('audio_only').checked;
|
||
|
chrome.storage.sync.set({
|
||
|
frontend_url: frontend_url,
|
||
|
audio_only: audio_only
|
||
|
}, function() {
|
||
|
// Update status to let user know options were saved.
|
||
|
var status = document.getElementById('status');
|
||
|
status.textContent = 'Options saved.';
|
||
|
setTimeout(function() {
|
||
|
status.textContent = '';
|
||
|
}, 750);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Restores select box and checkbox state using the preferences
|
||
|
// stored in chrome.storage.
|
||
|
function restore_options() {
|
||
|
chrome.storage.sync.get({
|
||
|
frontend_url: 'http://localhost',
|
||
|
audio_only: false
|
||
|
}, function(items) {
|
||
|
document.getElementById('frontend_url').value = items.frontend_url;
|
||
|
document.getElementById('audio_only').checked = items.audio_only;
|
||
|
});
|
||
|
}
|
||
|
document.addEventListener('DOMContentLoaded', restore_options);
|
||
|
document.getElementById('save').addEventListener('click',
|
||
|
save_options);
|