-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
62 lines (50 loc) · 2 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
54
55
56
57
58
59
60
61
62
// By pressing this button it should read all the fields
const ele = document.getElementById("btn")
ele.addEventListener("click", () => {
sendMsg('1',30);
sendMsg('2',60);
// Activation button for the Pomodoro method:
sendMsg('3',10);
sendMsg('4',23);
});
// Water break set
const water_alarm = document.getElementById("water_break");
water_alarm.addEventListener("click", () => {sendMsg('1',parseFloat(document.getElementById("waterNum").value));
clearInput("waterNum");
});
// Screen break set
const screen_alarm = document.getElementById("screen_break");
screen_alarm.addEventListener("click", () => {sendMsg('2',parseFloat(document.getElementById("screenNum").value));
clearInput("screenNum")
});
// Activation for the Pomodoro method:
const pomodoroButton = document.getElementById("pomodoro_timer");
pomodoroButton.addEventListener("click", () => {sendMsg('3',1)});
// Sleep reminder
const sleepButton = document.getElementById("sleep_reminder");
sleepButton.addEventListener("click", () => {sendMsg('4',parseFloat(document.getElementById("sleepNum").value));
clearInput("sleepNum")
});
//Stop water alarms
const stopWater = document.getElementById("stopWater");
stopWater.addEventListener("click", () => {sendMsg('5',0)});
//Stop screen alarms
const stopScreen = document.getElementById("stopScreen");
stopScreen.addEventListener("click", () => {sendMsg('6',0)});
//Stop pomodoro alarms
const stopPomodoro = document.getElementById("stopPomodoro");
stopPomodoro.addEventListener("click", () => {sendMsg('7',0)});
//Stop sleep alarms
const stopSleepReminder = document.getElementById("stopSleepReminder");
stopSleepReminder.addEventListener("click", () => {sendMsg('8',0)});
//Stop ALL ALARMS
const stopAllReminders = document.getElementById("stopAllReminders");
stopAllReminders.addEventListener("click", () => {sendMsg('9',0);});
//helper
function sendMsg(t, rep){
chrome.runtime.sendMessage({time: t, repeat: rep}, function (response) {
});
};
function clearInput(name){
document.getElementById(name).value = "";
}