-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClockReminder.js
165 lines (141 loc) · 5.28 KB
/
ClockReminder.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
let array = [];
class Reminder {
constructor(hrs, mins, ap, rem) {
if (hrs > 12) {
throw 'Parameter is not valid!';
}
this.hours = hrs;
if (mins > 59) {
throw 'Parameter is not valid!';
} else {
this.minutes = mins;
}
this.ampm = ap;
if (this.ampm === "PM") {
if (this.hours !== 12) {
this.hours += 12;
}
} else {
}
this.remind = rem;
}
toString() {
let s = "Reminder: ";
s += this.remind + " at ";
if (this.hours > 12) {
s += (this.hours - 12) + ":" + this.minutes + " " + this.ampm;
} else {
s += this.hours + ":" + this.minutes + " " + this.ampm;
}
return s;
}
}
function addReminder(Reminder r){
array.push(r);
}
function timeChecker() {
let today = new Date();
let hours = today.getHours();
let minutes = today.getMinutes();
for (let i = 0; i < array.length; i++) {
if (array[i].hours === hours && array[i].minutes === minutes) {
document.getElementById("rand_reminder").innerHTML = array[i].toString();
let x = array[i];
let y = array[array.length-1];
array[i] = y;
array[array.length-1] = x;
array.pop();
}
}
if (hours === 20 && minutes === 45) {
document.getElementById("rand_reminder").innerHTML = "Test Case Up";
}
if (hours === 9 && minutes === 0) {
document.getElementById("rand_reminder").innerHTML = "Have you woken up yet?";
} else if (hours === 10 && minutes === 0) {
document.getElementById("rand_reminder").innerHTML = "Have you eaten yet?";
} else if (hours === 11 && minutes === 0) {
document.getElementById("rand_reminder").innerHTML = "Remember to take a break!";
} else if (hours === 12 && minutes === 0) {
let msg = getMessage();
if (msg === "Would you like to set a reminder?: ") {
document.getElementById("rand_reminder").innerHTML = msg;
} else {
document.getElementById("rand_reminder").innerHTML = msg;
}
} else if (hours === 13 && minutes === 0) {
console.log("Have you eaten yet? If you haven't, eat!");
} else if (hours === 13 && minutes === 30) {
console.log("Remember to stay hydrated!");
} else if (hours === 14 && minutes === 0) {
console.log("It's good to take breaks every once in a while!");
} else if (hours === 15 && minutes === 0) {
let msg = getMessage();
console.log(msg);
if (msg === "Would you like to set a reminder?: ") {
const input = prompt();
if (input === "yes" || input === "Yes") {
}
}
} else if (hours === 15 && minutes === 30) {
console.log("Remember to stay hydrated!")
} else if (hours === 16 && minutes === 0) {
let msg = getMessage();
console.log(msg);
if (msg === "Would you like to set a reminder?: ") {
}
} else if (hours === 16 && minutes === 30) {
console.log("Have you eaten yet? If you haven't, eat!");
} else if (hours === 17 && minutes === 15) {
console.log("Remember to take a break!");
} else if (hours === 18 && minutes === 0) {
let msg = getMessage();
console.log(msg);
if (msg === "Would you like to set a reminder?: ") {
const input = prompt();
if (input === "yes" || input === "Yes") {
}
}
} else if (hours === 18 && minutes === 30) {
console.log("Remember to stay hydrated!");
} else if (hours === 19 && minutes === 30) {
console.log("Have you eaten yet? Remember to eat");
} else if (hours === 20 && minutes === 30) {
let msg = getMessage();
console.log(msg);
if (msg === "Would you like to set a reminder?: ") {
const input = prompt();
if (input === "yes" || input === "Yes") {
}
}
} else if (hours === 21 && minutes === 30) {
console.log("Remember to stay hydrated");
} else if (hours === 22 && minutes === 0) {
let msg = getMessage();
console.log(msg);
if (msg === "Would you like to set a reminder?: ") {
const input = prompt();
if (input === "yes" || input === "Yes") {
}
}
} else if (hours === 23 && minutes === 0) {
console.log("Remember to take a break sometimes");
} else if (hours === 0 && minutes === 0) {
console.log("Its late! Remember to get a good night's sleep!");
}
}
timeChecker();
setInterval(function() {
timeChecker();
}, 60 * 1000);
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
function getMessage() {
const messages = ["You're doing great!", "Keep up the good work!",
"Virtual Hug uwu", "Keep Calm and Carry on!", "You're worth something!",
"It's gonna be ok", "You'll make it through!", "You've got this",
"Would you like to set a reminder?: "];
let i = getRandomInt(messages.length);
return messages[i];
}