-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
30 lines (25 loc) · 1.04 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
let chosen_time_frame;
const button = document.querySelector("button");
button.addEventListener("click", async () => {
//document.getElementById('#alert').innerHTML = "Your open Chrome tabs will be saved to your bookmarks and cleared. This will occur based on the timeframe you have set";
chosen_time_frame = getOption();
console.log(chosen_time_frame);
chrome.alarms.create('myAlarm', {
delayInMinutes: chosen_time_frame, // Set the delay to chosen time frame
periodInMinutes: chosen_time_frame // Set the period to chosen time frame
});
});
function getOption() {
let selectElement = document.querySelector('#select_tag');
let time_frame = selectElement.options[selectElement.selectedIndex].value;
let time_frame_int = 0;
if (time_frame == "30Mins")
time_frame_int = 30;
else if (time_frame == "Weekly")
time_frame_int = 7*24*60;
else if (time_frame == "Bi_Monthly")
time_frame_int = 14*24*60
else
time_frame_int = 30*24*60;
return time_frame_int;
}