-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.js
87 lines (86 loc) · 2.54 KB
/
timer.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
$(document).ready(function(){
var countS = 25;
$("#session").html(countS);
var countB = 5;
$("#break").html(countB);
var pos = "pomodoro";
var countLama;
var posLama;
var count;
$("#stats").html(pos);
var clock = $(".timer").FlipClock(0, {
countdown: true,
clockFace: 'MinuteCounter',
autoStart: false,
callbacks: {
interval: function(){
if (clock.getTime() == 0){
if (pos == "session"){
clock.setTime(countB*60);
clock.start();
pos = "break";
$("#stats").html(pos);
} else if (pos == "break"){
clock.setTime(countS*60);
clock.start();
pos = "session";
$("#stats").html(pos);
}
}
}
}
});
//SESSION
$("#sessInc").on("click", function(){
if ($("#session").html() > 0){
countS = parseInt($("#session").html());
countS+=1;
$("#session").html(countS);
}
});
$("#sessDec").on("click", function(){
if ($("#session").html() > 1){
countS = parseInt($("#session").html());
countS-=1;
$("#session").html(countS);
}
});
//BREAK
$("#breakInc").on("click", function(){
if ($("#break").html() > 0){
countB = parseInt($("#break").html());
countB+=1;
$("#break").html(countB);
}
});
$("#breakDec").on("click", function(){
if ($("#break").html() > 1){
countB = parseInt($("#break").html());
countB-=1;
$("#break").html(countB);
}
});
$("#start").on("click", function(){
if (count != countS || clock.getTime()==0){
clock.setTime(countS*60);
pos="session";
$("#stats").html(pos);
} else {
pos = posLama;
$("#stats").html(pos);
}
count = countS;
clock.start();
});
$("#stop").on("click", function(){
clock.stop();
countLama = clock.getTime();
posLama = $("#stats").html();
});
$("#clear").on("click", function(){
clock.stop();
pos = "pomodoro";
$("#stats").html(pos);
clock.setTime(0);
});
});