-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup.js
683 lines (629 loc) · 29.1 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
// Initialize important pomodoro, connection, and task/link list variables
var pomodoro_work;
var timeLeft;
var port = chrome.runtime.connect({ name: "conn" }); // establishes connection to background.js
var pom_port = chrome.runtime.connect({ name: "pomodoro" });
var task_counter = 0;
var link_counter = 0;
// top slider to change tabs
var slider = document.getElementById("choose-tab");
var current = "1";
slider.addEventListener("change", function () {
current = slider.value;
changetab();
});
// change tabs
function changetab() {
port.postMessage({ action: "Change tab", tab: current });
if (current.charAt(0) === '1') { // Tab #1
document.getElementById("tasks").style.display = "block";
document.getElementById("classes").style.display = "none";
document.getElementById("pomodoro").style.display = "none";
document.getElementById("blocker").style.display = "none";
}
else if (current.charAt(0) === '2') { // Tab #2
document.getElementById("tasks").style.display = "none";
document.getElementById("classes").style.display = "block";
document.getElementById("pomodoro").style.display = "none";
document.getElementById("blocker").style.display = "none";
}
else if (current.charAt(0) === '3') { // Tab #3
document.getElementById("tasks").style.display = "none";
document.getElementById("classes").style.display = "none";
document.getElementById("pomodoro").style.display = "block";
document.getElementById("blocker").style.display = "none";
set_task_list();
}
else { // Tab #4
document.getElementById("tasks").style.display = "none";
document.getElementById("classes").style.display = "none";
document.getElementById("pomodoro").style.display = "none";
document.getElementById("blocker").style.display = "block";
}
}
// Get Theme Mode from options file
function getTheme() {
chrome.storage.sync.get(['mainbgcolor', 'elementcolor', 'textcolor', 'sliderlight', 'sliderdark', 'radiofill', 'timermain'], function (data) {
document.documentElement.style.setProperty('--main-bg-color', data.mainbgcolor);
document.documentElement.style.setProperty('--element-color', data.elementcolor);
document.documentElement.style.setProperty('--text-color', data.textcolor);
document.documentElement.style.setProperty('--slider-light', data.sliderlight);
document.documentElement.style.setProperty('--slider-dark', data.sliderdark);
document.documentElement.style.setProperty('--radio-fill', data.radiofill);
document.documentElement.style.setProperty('--timer-main', data.timermain);
});
}
// adds a subsection with input box and collapsible header
function section_setup(section) {
// possibly at some point add way to change placeholder to add a link/class meeting time/whatever if it's in class
if (section.parentElement.id === "class-list" || section.parentElement.id === "new-class") {
console.log(section.nextElementSibling);
section.nextElementSibling.innerHTML = section.nextElementSibling.innerHTML +
'<label for="days">Choose class days:</label><br>' +
'<select name="days" class="days"><option value="Monday">Monday</option>' +
'<option value="Tuesday">Tuesday</option><option value="Wednesday">Wednesday</option>' +
'<option value="Thursday">Thursday</option><option value="Friday">Friday</option>' +
'<option value="Saturday">Saturday</option><option value="Sunday">Sunday</option></select>' +
'<select name="time" class="time"><option value="9">9:00</option>' +
'<option value="10">10:00</option><option value="11">11:00</option>' +
'<option value="12">12:00</option><option value="1">1:00</option>' +
'<option value="2">2:00</option><option value="3">3:00</option></select>' +
'<br><input type="submit" value="Submit" class="submit"><br><br>';
port.postMessage({ action: "Update classes", class: section.textContent.substring(2) });
} else {
section.nextElementSibling.innerHTML = section.nextElementSibling.innerHTML +
'<input type="text" id="' + section.textContent.substring(2) +
'" class="new-todo" placeholder=" New todo item" style="font-size: 16px; "></input>';
}
section.id = section.textContent.substring(2);
section.addEventListener("click", function () {
var content = this.nextElementSibling;
// change + and - when list is expanded vs. not expanded
if (content.style.display === "block") {
content.style.display = "none";
this.textContent = this.textContent.replace('-', '+');
} else {
content.style.display = "block";
this.textContent = this.textContent.replace('+', '-');
}
});
}
// adds an input box which can add text to the section (new task, link, etc.)
function add_todo_input() {
$(".new-todo").focus(function () {
$(this).keypress(function (event) {
if (event.which == 13) {
var content = $(this).val();
if (content != "") {
// if it's a valid link
if (
content.includes("http") ||
content.includes("https") ||
content.includes("www")
) {
var has_spaces = $.trim(content).split(" ");
if (has_spaces.length == 1) {
if (!content.includes("http") || content.includes("https"))
content = "http://" + content;
$(this).after('<br><a href="' + content + '" target = "_blank">' + content + "</a>");
$(this).val("");
} else {
to_add_to_list =
'<br><label id="task' + task_counter + '" style="font-size:17px;"><input type="checkbox" class="task"></input><span>';
add_to_end = "</span></label>";
for (var i = 0; i < has_spaces.length; i++) {
if (
has_spaces[i].includes("http") ||
has_spaces[i].includes("https") ||
has_spaces[i].includes("www")
) {
if (!has_spaces[i].includes("http") || has_spaces[i].includes("https"))
has_spaces[i] = "http://" + has_spaces[i];
to_add_to_list +=
'<a href="' +
has_spaces[i] +
'" target = "_blank">' +
has_spaces[i] +
"</a>";
} else {
to_add_to_list += has_spaces[i] + " ";
}
}
to_add_to_list = to_add_to_list + add_to_end;
$(this).after(to_add_to_list);
$(this).val("");
}
}
//if it's not a link
else {
$(this).after(
'<br><label id="task' + task_counter
+ '" style="font-size:17px;"><input type="checkbox" class="task" id="checkbox'
+ task_counter + '"></input><span>'
+ content +
'</span><input type = "button" class="remove" value ="×"></input></label>'
);
$(this).val("");
}
// add to background list
var section_id = this.id;
port.postMessage({
action: "Update tasks",
task: content,
checked: false,
section: section_id,
});
// listener for check
$("#checkbox" + task_counter).click(function () {
port.postMessage({ action: "Update tasks", task: content, checked: this.checked, section: section_id });
});
// listener for removing items
$(".remove").off("click");
$(".remove").click(function () {
var to_be_removed = $(this).parentsUntil('div');
port.postMessage({ action: "Remove task", task: content, section: section_id });
$(to_be_removed[0]).prev().remove();
for (var i = 0; i < to_be_removed.length; i++) {
to_be_removed[i].remove();
}
});
// update task_counter
task_counter++;
}
}
});
});
}
// add blocked links to Website Blocker Tab
$("#add-blocked").focus(function () {
$(this).keypress(function (event) {
if (event.which == 13) {
var content = $(this).val();
if (content != "") {
// if it's a valid link
if (
content.includes("http") ||
content.includes("https") ||
content.includes("www")
) {
var has_spaces = $.trim(content).split(" ");
if (has_spaces.length == 1) {
if (!content.includes("http") || content.includes("https"))
content = "http://" + content;
$(this).after('<br><a href="' + content + '" target = "_blank">' + content + "</a>");
$(this).val("");
port.postMessage({
action: "Update links",
link: content
});
} else {
alert("Please enter only the link of the website you would like to block.");
}
}
//if it's not a link
else {
alert("Please enter a valid link.");
}
}
}
});
});
// finds all unchecked items and adds them to pomodoro task list
function set_task_list() {
var task_list = [];
port.postMessage({ action: "Get tasks", signature: "set_task_list" });
port.onMessage.addListener(function (msg) {
if (msg.signature === "set_task_list") {
task_list = msg.tasks;
$('option').remove();
for (var i = 0; i < task_list.length; i++) {
if (!task_list[i][1]) {
$('#inputGroupSelect01').append('<option>' + task_list[i][0] + '</option>');
}
}
}
});
}
// chooses a message to display for pomodoro
function get_message(work) {
back_messages = [
"Did you enjoy your break?",
"Hope you had a restful break!",
"Did you have a good break?",
"Some time off is always nice, but...",
"How was your break?",
];
work_messages = [
"Time to get back to work!",
"Let's get cracking again!",
"Are you ready to get some more work done?",
"Your work is waiting for you!",
"Get ready to focus again!",
"Let's get back to work now!",
"Ready... Set... Work!",
];
break_messages = [
"Let's take a break now!",
"Good work! You deserve some rest now!",
"Now seems like a good time for a quick walk!",
"Nice work! Have you had some water lately?",
"Great job! Maybe you should hydrate now!",
"Awesome work! Take a quick break now!",
"You've been focusing so well! You should take a break now.",
"You've been working so hard! Do you want to stretch?",
];
if (work) {
return (
back_messages[Math.floor(Math.random() * back_messages.length)] +
" " +
work_messages[Math.floor(Math.random() * work_messages.length)]
);
} else {
return (
break_messages[Math.floor(Math.random() * break_messages.length)] + " :)"
);
}
}
// Display meet dates for each class list
function meet_setup() {
$('.submit').off('click');
$('.submit').click(function () {
console.log('submitted days');
sibs = $(this).siblings();
console.log(sibs);
var content = "Meets on ";
select_list = [];
for (var i = 0; i < sibs.length; i++) {
if ($(sibs[i]).hasClass('days') || $(sibs[i]).hasClass('time')) {
select_list = select_list.concat(sibs[i]);
console.log(select_list);
}
}
// for (var i = 0; i < select_list.length; i++) {
// if ($(select_list[i]).is("option:selected") && (i != select_list.length - 1))
content += String($(select_list[0][select_list[0].selectedIndex]).attr('value')) + "s ";
// else if ($(select_list[i]).is("option:selected"))
content += "at " + String($(select_list[1][select_list[1].selectedIndex]).attr('value'));
// }
console.log(content);
$(this).after('<br><label id="task"><input type="checkbox" class="task" id="checkbox"></input><span>'
+ content + '</span><input type = "button" class="remove" value ="×"></input></label>');
$(".remove").click(function () {
var to_be_removed = $(this).parentsUntil('div');
// port.postMessage({ action: "Remove task", task: content, section: section_id });
$(to_be_removed[0]).prev().remove();
for (var i = 0; i < to_be_removed.length; i++) {
to_be_removed[i].remove();
}
});
});
}
// pomodoro timer
let progressBar = document.querySelector(".e-c-progress");
let indicator = document.getElementById("e-indicator");
let pointer = document.getElementById("e-pointer");
let length = Math.PI * 2 * 100;
progressBar.style.strokeDasharray = length;
function update(value, timePercent) {
var offset = -length - (length * value) / timePercent;
progressBar.style.strokeDashoffset = offset;
pointer.style.transform = `rotate(${(360 * value) / timePercent}deg)`;
}
//circle ends
const displayOutput = document.querySelector(".display-remain-time");
const pauseBtn = document.getElementById("pause");
const setterBtns = document.querySelectorAll("button[data-setter]");
const workInput = document.getElementById("work-period");
const breakInput = document.getElementById("break-period");
let intervalTimer;
//let wholeTime = 25;
let workTime = document.getElementById("work-period").value * 60; // manage this to set the whole time
let breakTime = document.getElementById("break-period").value * 60;
let isPaused = false;
let isStarted = false;
let timer_zero = false;
let remainTime = 0;
function timer(seconds) {
//counts time, takes seconds
port.postMessage({ signature: "Timer", action: "Timer", seconds: seconds });
isStarted = true;
isPaused = false;
remainTime = Date.now() + seconds * 1000;
displayTimeLeft(seconds);
}
function pauseTimer(event) {
if (isStarted === false) {
// Play
timer(pomodoro_work ? workTime : breakTime);
isStarted = true;
this.classList.remove("play");
this.classList.add("pause");
console.log(pomodoro_work ? "Work" : "Break");
} else if (isPaused) {
// Play from pause
this.classList.remove("play");
this.classList.add("pause");
timer(timeLeft);
isPaused = false;
} else {
// Pause
this.classList.remove("pause");
this.classList.add("play");
port.postMessage({ signature: "Timer", action: "Stop Timer" })
isPaused = true;
}
}
function displayTimeLeft(timeLeft) {
//displays time on the input
let minutes = Math.floor(timeLeft / 60);
let seconds = timeLeft % 60;
let displayString = `${minutes < 10 ? "0" : ""}${minutes}:${
seconds < 10 ? "0" : ""
}${seconds}`;
displayOutput.textContent = displayString;
update(timeLeft, pomodoro_work ? workTime : breakTime);
}
// initialize the popup with saved data
function pop_init() {
port.postMessage({ action: "Get tasks", signature: "pop_init" });
port.onMessage.addListener(function (msg) {
if (msg.signature === "pop_init") {
var task_list = msg.tasks;
console.log(task_list);
// task section headers
sections = [];
for (var i = task_list.length - 1; i >= 0; i--) {
if (!sections.includes(task_list[i][2])) {
$('#task-list').prepend('<h5 class="section-header"><span>+ </span>' + task_list[i][2] + '</h5><div class="task-section lead"></div>');
section_setup(document.getElementsByClassName("section-header")[0]);
sections = sections.concat(document.getElementsByClassName("section-header")[0].id);
}
// add tasks
var label_content = "";
// if it's a valid link
if (task_list[i][0].includes("http") || task_list[i][0].includes("https") || task_list[i][0].includes("www")) {
var has_spaces = $.trim(task_list[i][0]).split(" ");
if (has_spaces.length == 1) {
label_content = ('<br><a href="' + task_list[i][0] + '" target = "_blank">' + task_list[i][0] + "</a>");
} else {
to_add_to_list =
'<br><label id="task' + task_counter + '"><input type="checkbox" class="task"></input><span>';
add_to_end = "</span></label>";
for (var j = 0; j < has_spaces.length; j++) {
if (has_spaces[j].includes("http") || has_spaces[j].includes("https") || has_spaces[j].includes("www")) {
to_add_to_list += '<a href="' + has_spaces[j] + '" target = "_blank">' +
has_spaces[j] + "</a>";
} else {
to_add_to_list += has_spaces[j] + " ";
}
}
label_content = to_add_to_list + add_to_end;
}
}
//if it's not a link
else {
label_content =
'<br><label id="task' + task_counter
+ '"><input type="checkbox" class="task" id="checkbox'
+ task_counter + '"></input><span>'
+ task_list[i][0] +
'</span><input type = "button" class="remove" value ="x"></input></label>';
}
document.getElementById(task_list[i][2]).nextElementSibling.innerHTML += label_content;
// check task
if (task_list[i][1]) {
$("#checkbox" + task_counter).attr("checked", true);
}
task_counter++;
}
// add listener for click
$(".task").click(function () {
port.postMessage({ action: "Update tasks", task: this.nextElementSibling.textContent, checked: this.checked, section: this.parentElement.parentElement.previousElementSibling.id });
})
// add input boxes
add_todo_input();
//allow the calendar to return a to-do of the days the class meets
meet_setup();
// listener for removing items
$(".remove").click(function () {
var to_be_removed = $(this).parentsUntil('div');
console.log(to_be_removed[0].parentElement.previousElementSibling.id);
port.postMessage({ action: "Remove task", task: to_be_removed[0].textContent, section: to_be_removed[0].parentElement.previousElementSibling.id });
$(to_be_removed[0]).prev().remove();
for (var i = 0; i < to_be_removed.length; i++) {
to_be_removed[i].remove();
}
});
// find out if timer is running
chrome.runtime.sendMessage({ get: "timer" }, function (response) {
timeLeft = response.timeLeft;
pomodoro_work = response.pomodoro_work;
port.postMessage({ action: "Get times", signature: "getting times" });
port.onMessage.addListener(function (msg) {
if (msg.signature === "getting times") {
workTime = msg.work_time * 60;
breakTime = msg.break_time * 60;
document.getElementById("work-period").value = workTime / 60;
document.getElementById("break-period").value = breakTime / 60;
}
})
if (timeLeft < 0) {
update(
pomodoro_work ? workTime : breakTime,
pomodoro_work ? workTime : breakTime
); //refreshes progress bar
displayTimeLeft(pomodoro_work ? workTime : breakTime);
}
else {
update(timeLeft, pomodoro_work ? workTime : breakTime);
displayTimeLeft(timeLeft);
if (response.timer_running) {
isStarted = true;
isPaused = false;
document.getElementById('pause').classList.remove("play");
document.getElementById('pause').classList.add("pause");
port.postMessage({ signature: "Timer", action: "Stop Timer" })
timer(timeLeft);
} else {
isStarted = true;
isPaused = true;
}
}
// set tab to last opened
current = response.current;
slider.value = current;
changetab();
});
}
});
// New class list selection for user
// port.postMessage({ action: "Get classes", signature: "class_init" });
// port.onMessage.addListener(function (msg) {
// if (msg.signature === "class_init") {
// classes = msg.classes;
// for (var i = 0; i < classes.length; i++) {
// console.log(i);
// $('#new-class').append('<h5 class="class-header"><span>+ </span>' +
// classes[i] + '</h5><div class="task-section lead"><label for="days">Choose class days:</label><br>' +
// '<select name="days" class="days"><option value="Monday">Monday</option>' +
// '<option value="Tuesday">Tuesday</option><option value="Wednesday">Wednesday</option>' +
// '<option value="Thursday">Thursday</option><option value="Friday">Friday</option>' +
// '<option value="Saturday">Saturday</option><option value="Sunday">Sunday</option></select>' +
// '<select name="time" class="time"><option value="9">9:00</option>' +
// '<option value="10">10:00</option><option value="11">11:00</option>' +
// '<option value="12">12:00</option><option value="1">1:00</option>' +
// '<option value="2">2:00</option><option value="3">3:00</option></select>' +
// '<br><input type="submit" value="Submit" class="submit"><br><br><div>');
// }
// }
// });
// reload all existing links, if any
port.postMessage({ action: "Get links", signature: "pop_init_links" });
port.onMessage.addListener(function (msg) {
if (msg.signature === "pop_init_links") {
var link_list = msg.links;
console.log(link_list);
for (var i = link_list.length - 1; i >= 0; i--) {
// add list of links
var link_content = "";
link_content = ('<br><a href="' + link_list[i] + '" id="' + link_list[i] + '" target = "_blank">' + link_list[i] + "</a>");
$('#link-list').append(link_content);
link_counter++;
}
};
});
getTheme();
}
var remove_class;
// basic function that runs at the load-in stage
$(document).ready(function () {
pop_init();
let tasks = document.getElementsByClassName("task");
let sections = document.getElementsByClassName("section-header");
let classes = document.getElementsByClassName("classes");
let classSections = document.getElementsByClassName("class-header");
for (var i = 0; i < sections.length; i++) {
section_setup(sections[i]);
}
for (var i = 0; i < classSections.length; i++) {
section_setup(classSections[i]);
}
// tasks
$(".new-section").focus(function () {
$(this).keypress(function (event) {
if (event.which == 13) {
var content = $(this).val();
if (content != "") {
$("#task-list").prepend(
'<h5 class="section-header"><span>+ </span>' +
content +
'</h5><div class="task-section lead"></div>'
);
$(this).val("");
section_setup(document.getElementsByClassName("section-header")[0]);
add_todo_input();
}
}
});
});
// classes
$(".new-class").focus(function () {
$(this).keypress(function (event) {
if (event.which == 13) {
var content = $(this).val();
if (content != "") {
$("#class-list").prepend(
'<h5 class="class-header" id="' + content +
'"><span>+ </span>' + content +
'</h5><div class="task-section lead"></div>'
);
$("#task-list").prepend(
'<h5 class="section-header"><span>+ </span>' +
content +
'</h5><div class="task-section lead"></div>'
);
$(this).val("");
section_setup(document.getElementsByClassName("class-header")[0]);
meet_setup();
section_setup(document.getElementsByClassName("section-header")[0]);
add_todo_input();
}
}
});
});
add_todo_input();
// Listener for timer
port.onMessage.addListener(function (msg) {
if (msg.signature === "Timer") {
timeLeft = msg.timeLeft;
timer_zero = (msg.finished);
displayTimeLeft(timeLeft);
if (timer_zero) {
// move to other part of the pomodoro
pomodoro_work = !pomodoro_work;
displayTimeLeft(pomodoro_work ? workTime : breakTime);
port.postMessage({ signature: "Timer", action: "Stop Timer" });
alert(get_message(pomodoro_work));
timer(pomodoro_work ? workTime : breakTime);
return;
}
}
if (msg.signature === "End Timer") {
}
});
// pause button
pauseBtn.addEventListener("click", pauseTimer);
workInput.addEventListener("change", function timerReset() {
if (document.getElementById("work-period").value < 0) {
alert("Timer value must be greater than or equal to zero!");
workTime = 0;
document.getElementById("work-period").value = 0;
} else {
workTime = document.getElementById("work-period").value * 60;
document.getElementById("work-period").value = workTime / 60;
port.postMessage({ action: "Update times", break_time: breakTime / 60, work_time: workTime / 60 });
}
if (pomodoro_work) {
timeLeft = timeLeft < workTime ? timeLeft : workTime;
displayTimeLeft(timeLeft);
update(timeLeft, workTime);
}
});
// break timer input
breakInput.addEventListener("change", function timerReset() {
if (document.getElementById("break-period").value < 0) {
alert("Timer value must be greater than or equal to zero!");
breakTime = 0;
document.getElementById("break-period").value = 0;
} else {
breakTime = document.getElementById("break-period").value * 60;
document.getElementById("break-period").value = breakTime / 60;
port.postMessage({ action: "Update times", break_time: breakTime / 60, work_time: workTime / 60 });
}
if (!pomodoro_work) {
timeLeft = timeLeft < breakTime ? timeLeft : breakTime;
displayTimeLeft(timeLeft);
update(breakTime, breakTime);
}
});
});