This repository was archived by the owner on Aug 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.js
More file actions
95 lines (79 loc) · 2.9 KB
/
Timer.js
File metadata and controls
95 lines (79 loc) · 2.9 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
(function ($) {
$.fn.stopwatch = function () {
var clock = this;
timer = 0;
phptime = 0;
clock.addClass('stopwatch');
clock.html('<div class="span12 well timer" style="text-align:center;"><span class="hr">00</span>:<span class="min">00</span>:<span class="sec">00</span></div>');
clock.append('<input type="button" class="start btn btn-large btn-success" value="Start" style="margin-right:5px;" />');
clock.append('<input type="button" class="stop btn btn-large btn-danger" value="Stop" style="margin-right:5px;" />');
clock.append('<input type="button" class="quick btn btn-large btn-primary" value="Quick" style="margin-right:5px;" />');
clock.append('<input type="button" class="reset btn btn-large btn-warning" value="Reset" />');
h = clock.find('.hr');
m = clock.find('.min');
s = clock.find('.sec');
var start = clock.find('.start');
var stop = clock.find('.stop');
var quick = clock.find('.quick');
var reset = clock.find('.reset');
stop.hide();
quick.hide();
start.bind('click', function () {
timer = setInterval(do_time, 1000);
quick.show();
stop.show();
start.hide();
if(phptime === 0)
{
$.ajaxSetup({async:false});
$.get('currtime.php', function (data) {
$("#tstart").val(data);
phptime = data;
$.ajaxSetup({async:true});
});
}
console.log("Timer Started at " + phptime);
});
quick.bind('click', function () {
$('#EntryModal').modal('show');
});
stop.bind('click', function () {
clearInterval(timer);
quick.hide();
stop.hide();
start.show();
});
reset.bind('click', function () {
clearInterval(timer);
timer = 0;
phptime = 0;
h.html("00");
m.html("00");
s.html("00");
stop.hide();
start.show();
quick.hide();
});
function do_time() {
hour = parseFloat(h.text());
minute = parseFloat(m.text());
second = parseFloat(s.text());
second++;
if (second > 59) {
second = 0;
minute = minute + 1;
}
if (minute > 59) {
minute = 0;
hour = hour + 1;
}
// if(minute % 1 === 0 && second === 0)
h.html("0".substring(hour >= 10) + hour);
m.html("0".substring(minute >= 10) + minute);
s.html("0".substring(second >= 10) + second);
if (minute % 15 === 0 && second === 0) {
$('#EntryModal').modal('show');
}
}
};
})(jQuery);