-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.js
32 lines (29 loc) · 952 Bytes
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function save_options() {
var host = document.getElementById('form_host').value;
var port = document.getElementById('form_port').value;
var name = document.getElementById('form_name').value;
chrome.storage.sync.set({
host: host,
port: port,
username: name
}, function() {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
function restore_options() {
chrome.storage.sync.get({
host: 'http://localhost',
port: 8993,
username: "Damian"
}, function(items) {
document.getElementById('form_host').value = items.host;
document.getElementById('form_port').value = items.port;
document.getElementById('form_name').value = items.username;
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);