-
Notifications
You must be signed in to change notification settings - Fork 8
/
popup.js
53 lines (48 loc) · 1.92 KB
/
popup.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
47
48
49
50
51
52
53
document.addEventListener('DOMContentLoaded', function () {
// Options button
const optionsButton = document.getElementById('optionsButton');
optionsButton.addEventListener('click', function () {
chrome.runtime.openOptionsPage();
});
// Mode buttons selection
chrome.storage.sync.get('selectedMode', function (data) {
if (data.selectedMode) {
switch (data.selectedMode) {
case 'newTab':
newTabButton.click();
break;
case 'ical':
icalButton.click();
break;
case 'auto':
autoButton.click();
break;
}
}
});
const newTabButton = document.getElementById('newTabButton');
const icalButton = document.getElementById('icalButton');
const autoButton = document.getElementById('autoButton');
const modeText = document.getElementById('modeText');
newTabButton.addEventListener('click', function () {
newTabButton.classList.add('active');
icalButton.classList.remove('active');
autoButton.classList.remove('active');
modeText.innerHTML = '<b>Mode</b>: new tab';
chrome.storage.sync.set({ selectedMode: 'newTab' });
});
icalButton.addEventListener('click', function () {
icalButton.classList.add('active');
newTabButton.classList.remove('active');
autoButton.classList.remove('active');
modeText.innerHTML = '<b>Mode</b>: .ical';
chrome.storage.sync.set({ selectedMode: 'ical' });
});
autoButton.addEventListener('click', function () {
autoButton.classList.add('active');
newTabButton.classList.remove('active');
icalButton.classList.remove('active');
modeText.innerHTML = '<b>Mode</b>: automatic';
chrome.storage.sync.set({ selectedMode: 'auto' });
});
});