-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquickTimer.html
47 lines (45 loc) · 1.47 KB
/
quickTimer.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
<html>
<head>
<!--Load Jqueary and Moment-->
<script type="text/javascript" src="jqueary.js"></script>
<script type="text/javascript" src="moment.js"></script>
<link type="text/css" href="main.css" rel="stylesheet">
<script type="text/javascript">
var i = 0;
var start, best, statement;
best = null;
statement = "1000th's of a second"
function game(){
$("#unit").text(statement)
$("#best").removeClass("red");
if(i==0){
start = moment();
$(".button").val("Finish")
i++;
}else{
var end = moment();
var time = end-start;
$(".button").val("Start")
console.log(time);
$("#time").text(time);
if (best == null || best > time) {
$("#best").text(time).addClass("red")
$("#unit").text("new high score!")
best = time;
}
i = 0;
}
}
// window.onload = function(){
// refresh()
// };
</script>
</head>
<body>
<div class="center"><p class="center" id="time">Press the button once to start and again to stop the timer, shortest time wins</p><p class="inline small" id="unit"></p></div>
<div class="center">
<input type="button" class="button" onclick="game()" value="Start">
<p id="best"></p>
</div>
</body>
</html>