-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
112 lines (94 loc) · 2.44 KB
/
script.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
$(function(){
//$("#buzzer")[0].play();imes up sound
$("#reset").hide();
var count = +($("#num").html());
var breakcount = +($("#breaknum").html());/* num and breaknum are stored in variables so that they can be compared t.i count > 5 */
console.log(count);
$("#minus5Clock").on("click",function(){
if(count>5){
count -=5;
$("#num").html(count);
console.log(count);
}
})
$("#add5Clock").on("click",function(){
if(count < 25){
count += 5 ;
$("#num").html(count);
console.log(count);
}
})
$("#add5Break").on("click",function(){
if(breakcount < 10){
breakcount +=5 ;
$("#breaknum").html(breakcount);
console.log(breakcount);
}
})
$("#minus5Break").on("click",function(){
if(breakcount > 5){
breakcount -= 5;
$("#breaknum").html(breakcount);
console.log(breakcount);
}
})
$("#start").on("click",function(){
$("#start,#title1,#title2,#minus5Clock,#add5Clock,#minus5Break,#add5Break,#num,#breaknum").hide();
var counter = setInterval(timer,1000);
count *= 60;
breakcount *=60;
function timer(){
$("#timeType").show();
$("#timeType").html("Session Time: ");
$("#num").show();
count -= 1 ;
if(count === 0){
var buzzer = $("#buzzer")[0].play();
clearInterval(counter);//to break the count we use this
var startBreak = setInterval(breakTimer,1000);
$("#num").hide();
}
if(count%60>=10){
$("#num").html(Math.floor(count/60)+":"+count%60);
}
else{
$("#num").html(Math.floor(count/60)+":"+count%60);
}
/*$("#num").html(count);
console.log(count);*/
function breakTimer(){
$("#timeType").show();
$("#timeType").html("Break Time: ");
$("#breaknum").show();
breakcount -= 1;
if(breakcount === 0){
$("#breakbuzzer")[0].play();
clearInterval(startBreak);
$("#timeType,#breaknum").hide();
$("#reset").show();
}
if(breakcount%60>=10){
$("#breaknum").html(Math.floor(breakcount/60)+":"+breakcount%60);
}
else{
$("#breaknum").html(Math.floor(breakcount/60)+":"+breakcount%60);
}
/*$("#breaknum").html(breakcount);
console.log(breakcount);*/
}
}
$("#reset").on("click",function(){
$("#title1,#title2,#num,#breaknum,#add5Clock,#add5Break,#minus5Break,#minus5Clock,#start").show();
$("#reset").hide();
count = 1;
breakcount = 5;
$("#num").html(count);
$("#breaknum").html(breakcount);
})
})
})
/* (or)
$(function(){
var buzzer = $("#buzzer")[0];
buzzer.play();
})*/