-
Notifications
You must be signed in to change notification settings - Fork 8
/
options.js
31 lines (29 loc) · 1.16 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
document.addEventListener('DOMContentLoaded', function () {
const elems = document.querySelectorAll('select');
M.FormSelect.init(elems);
// Retrieve the previously selected model from storage and set it as the active option if it exists
chrome.storage.sync.get('defaultModel', function (data) {
if (data.defaultModel) {
const modelSelect = document.getElementById('model-select');
modelSelect.value = data.defaultModel;
M.FormSelect.init(modelSelect);
}
});
});
document.getElementById("configuration-form").addEventListener("submit", function (event) {
event.preventDefault();
const apiKey = document.getElementById("api-key-input").value;
const defaultModel = document.getElementById("model-select").value;
chrome.storage.sync.set({
apiKey: apiKey,
defaultModel: defaultModel
}, () => {
chrome.notifications.create({
type: 'basic',
iconUrl: '/icons/64.png',
title: 'AI Event Scheduler',
message: `💾 Saved. Current model: ${defaultModel}`,
priority: 1
});
});
});