-
Notifications
You must be signed in to change notification settings - Fork 33
/
example.html
112 lines (98 loc) · 3.07 KB
/
example.html
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
<!doctype html>
<html>
<head>
<title>Tock</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="tock.js"></script>
<style>
#laptimes {
border: 1px solid #ddd;
padding: 10px;
width: 200px;
}
</style>
<script>
window.onload = function() {
var timer = new Tock({
callback: function () {
$('#clockface').val(timer.msToTime(timer.lap()));
}
});
$('#start').on('click', function () {
timer.start($('#clockface').val());
});
$('#lap').on('click', function () {
$('#laptimes').append(timer.msToTime(timer.lap()) + '<br>');
});
$('#pause').on('click', function () {
timer.pause();
});
$('#stop').on('click', function () {
timer.stop();
});
$('#reset').on('click', function () {
timer.reset();
$('#clockface').val('');
$('#laptimes').html('');
});
var countdown = Tock({
countdown: true,
interval: 250,
callback: function () {
console.log(countdown.lap() / 1000);
$('#countdown_clock').val(timer.msToTime(countdown.lap()));
},
complete: function () {
console.log('end');
alert("Time's up!");
}
});
$('#startCountdown').on('click', function () {
countdown.start($('#countdown_clock').val());
});
$('#pauseCountdown').on('click', function () {
countdown.pause();
});
$('#stopCountdown').on('click', function () {
countdown.stop();
});
$('#resetCountdown').on('click', function () {
countdown.stop();
$('#countdown_clock').val('00:02');
});
}
</script>
</head>
<body>
<h1>Tock</h1>
<p>
by <a href="http://github.com/mrchimp/tock">Mr Chimp</a>
</p>
<section>
<h2>Timer</h2>
<p>
<button id="start">Start</button>
<button id="lap">Lap</button>
<button id="pause">Pause</button>
<button id="stop">Stop</button>
<button id="reset">Reset</button>
</p>
<p>
<input id="clockface" placeholder="00:00:00">
</p>
<p>
<div id="laptimes"></div>
</p>
</section>
<section>
<h2>Countdown</h2>
<p>
<button id="startCountdown">Start</button>
<button id="stopCountdown">Stop</button>
<button id="pauseCountdown">Pause</button>
<button id="resetCountdown">Reset</button>
<input id="countdown_clock" placeholder="00:00" value="00:02">
</p>
</section>
</body>
</html>