-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
112 lines (108 loc) · 3.01 KB
/
main.js
File metadata and controls
112 lines (108 loc) · 3.01 KB
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
$(document).ready(function(){
var count = parseInt($("#clock-minute").html());
var breakT = parseInt($("#breakTime").html());
var buzzer = $("#buzzer")[0];
//click on start
$("#start").click(function(){
$("#totSub").unbind();
$("#totAdd").unbind();
$("#breakSub").unbind();
$("#breakAdd").unbind();
$("#start").unbind();
let counter = setInterval(timer,1000);
//reset timer
$("#reset").click(function(){
location.reload();
});
var stopTimer = function(){
clearInterval(counter) // clear the interval and stop the clock
}
count*=60;
breakT*= 60;
function timer(){
$(".time-display").hide();
$("#clock-minute").show();
$("#loading").html("The Remainig Time");
count -= 1;
if(count ===1){
clearInterval(counter);
buzzer.play();
var startBreak = setInterval(breakTimer, 1000);
}
if(count%60>=0){
$("#clock-minute").html(Math.floor(count/60)+":"+count%60);
}else{
$("#clock-minute").html(Math.floor(count/60)+":"+"0"+count%60);
}
function breakTimer(){
$("#loading").html("BreakTime");
$("#breakTime").show();
breakT -= 1;
if(breakT%60>=0){
$("#clock-minute").html(Math.floor(breakT/60)+":"+breakT%60);
}else{
$("#clock-minute").html(Math.floor(breakT/60)+":"+"0"+breakT%60);
}
if(breakT===0){
clearInterval(startBreak);
}}
}
});
$("#totSub").click(function(){
if(count > 0){
count -= 1;
$("#totTime , #clock-minute").html(count);
}
if(count == 0){
$('#totTime').css({"color": "red"});
}else {
$('#totTime').css({"color": "white"});
}
if(count == 0){
$("#zerop2").text('You can not set the Session Time less than Zero.');
$("#zerop2").css({"color": "red"});
}
});
$("#totAdd").click(function(){
count += 1;
$("#totTime, #clock-minute").html(count);
if(count == 0){
$('#totTime').css({"color": "red"});
}else {
$('#totTime').css({"color": "white"});
}
if(count > 0){
$("#zerop2").text('');
}
});
//break time
$("#breakSub").click(function(){
if(breakT > 0){
breakT -= 1;
$("#breakTime, #clock-minute").html(breakT);
}
if(breakT == 0){
$('#breakTime').css({"color": "red"});
}else {
$('#breakTime').css({"color": "white"});
}
if(breakT <= 0){
$("#zerop").text('You can not set the Break Time less than Zero.');
$("#zerop").css({"color": "red"});
}else {
$("#zerop").text('');
}
});
$("#breakAdd").click(function(){
breakT += 1;
$("#breakTime, #clock-minute").html(breakT);
if(breakT == 0){
$('#breakTime').css({"color": "red"});
}else {
$('#breakTime').css({"color": "white"});
}
if(breakT >= 1){
$("#zerop").text('');
}
});
});