-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
29 lines (26 loc) · 939 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
function save_options() {
var options = {};
options.host = document.getElementById('host').value;
options.deviceId = document.getElementById('device_id').value;
options.authToken= document.getElementById('auth_token').value;
chrome.storage.local.set(options, function() {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
function restore_options() {
chrome.storage.local.get({
host: "ws://localhost:5000/socket",
deviceId: "webextension",
authToken: "",
}, function(options) {
document.getElementById('host').value = options.host;
document.getElementById('device_id').value = options.deviceId;
document.getElementById('auth_token').value = options.authToken;
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);