-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
46 lines (38 loc) · 1.58 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('help').addEventListener('click', function() {
chrome.tabs.create({url: 'https://github.com/tdalon/confluence_crx/blob/main/README.md#options'});
});
});
// Saves options to chrome.storage
const saveOptions = () => {
const type = document.getElementById('type').value;
const spacekey = document.getElementById('spacekey').value.toUpperCase();
const subdomain = document.getElementById('subdomain').value;
const limit = document.getElementById('limit').value;
chrome.storage.sync.set(
{ type: type, spacekey: spacekey, subdomain: subdomain, limit: limit },
() => {
// Update status to let user know options were saved.
const status = document.getElementById('status_msg');
status.textContent = 'Options saved.';
setTimeout(() => {
status.textContent = '';
}, 750);
}
);
};
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
const restoreOptions = () => {
chrome.storage.sync.get(
{type: 'page', spacekey: '',subdomain:'', limit:25 },
(items) => {
document.getElementById('type').value = items.type;
document.getElementById('spacekey').value = items.spacekey;
document.getElementById('subdomain').value = items.subdomain;
document.getElementById('limit').value = items.limit;
}
);
};
document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('save').addEventListener('click', saveOptions);