-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
37 lines (32 loc) · 1.02 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
function save_options() {
const openAIApiKey = document.getElementById('openai_api_key').value;
console.debug('save options.');
chrome.storage.sync.set(
{ openAIApiKey, },
() => {
const status = document.getElementById('status');
status.style.setProperty('display', 'block');
setTimeout(() => {
status.style.setProperty('display', 'none');
}, 750);
}
);
}
function restore_options() {
chrome.storage.sync.get(
{'openAIApiKey': ''},
(options) => {
document.getElementById('openai_api_key').value = options.openAIApiKey;
}
);
}
function handle_form_submit(event) {
event.preventDefault();
};
function option_main() {
console.debug('option_main');
document.addEventListener('DOMContentLoaded', restore_options);
document.forms['main-form'].addEventListener('submit', handle_form_submit);
document.getElementById('save').addEventListener('click', save_options);
}
option_main();