-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
29 lines (25 loc) · 807 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
const saveOptions = () => {
let editor = document.getElementById('editor').value
let localFolder = document.getElementById('localFolder').value
chrome.storage.sync.set(
{
editor,
localFolder,
},
() => {
let status = document.getElementById('status')
status.textContent = 'Options saved.'
setTimeout(function () {
status.textContent = ''
}, 3000)
}
)
}
const restoreOptions = () => {
chrome.storage.sync.get(['editor', 'localFolder'], (items) => {
document.getElementById('editor').value = items.editor || 'vscode'
document.getElementById('localFolder').value = items.localFolder || ''
})
}
document.addEventListener('DOMContentLoaded', restoreOptions)
document.getElementById('save').addEventListener('click', saveOptions)