-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsDed.js
69 lines (61 loc) · 1.36 KB
/
jsDed.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
var startTime;
var stopTime;
var interval;
function timeUpdate () {
var num = new Date();
var hours;
var minutes;
var seconds;
var milli;
if (num.getHours() < 10) {
hours = "0" + num.getHours().toString();
}
else {
hours = num.getHours().toString();
}
if (num.getMinutes() < 10) {
minutes = "0" + num.getMinutes().toString();
}
else {
minutes = num.getMinutes().toString();
}
if (num.getSeconds() < 10) {
seconds = "0" + num.getSeconds().toString();
}
else {
seconds = num.getSeconds().toString();
}
if (Math.floor(num.getMilliseconds()/10) < 10) {
milli = "0" + Math.floor(num.getMilliseconds()/10).toString();
}
else {
milli = Math.floor(num.getMilliseconds()/10).toString();
}
$('.stuff').text(hours + " " + minutes + " " + seconds + " " + milli);
}
var main = function() {
$("#time").hover( function(){
$(this).addClass('stuff',100);
startTime = Date.now();
//if(typeof stopTime === 'undefined'){
interval = setInterval(timeUpdate,100);
//}
//else {
// $(this).removeClass('stuff',100);
// $(this).text("End");
//}
//console.log(startTime - stopTime);
},
function(){
//if(typeof stopTime === 'undefined'){
clearInterval(interval);
$(this).removeClass('stuff',100);
$(this).text("Mouseover for the time.");
stopTime = Date.now();
//}
//else {
// return false;
//}
});
}
$(document).ready(main);