-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (45 loc) · 1.29 KB
/
Copy pathscript.js
File metadata and controls
63 lines (45 loc) · 1.29 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
var top;
var left;
var count = 0;
function jump() {
jumpTop();
jumpLeft();
count++;
document.getElementById('number').innerHTML=count;
}
function jumpTop() {
function getRandomInRangeTop(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
top = getRandomInRangeTop(5, 645) + "px";
document.getElementById('circle').style.top = top;
}
function jumpLeft() {
function getRandomInRangeLeft(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
left = getRandomInRangeLeft(5, 345) + "px";
document.getElementById('circle').style.left = left;
}
function getTimeRemaining(endtime) {
var t = Date.parse(endtime) - Date.parse(new Date());
var seconds = Math.floor((t / 1000) % 60);
return {
'seconds': seconds
};
}
function initializeClock(id, endtime) {
var clock = document.getElementById(id);
var secondsSpan = clock.querySelector('.seconds');
function updateClock() {
var t = getTimeRemaining(endtime);
secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);
if (t.total <= 0) {
clearInterval(timeinterval);
}
}
updateClock();
var timeinterval = setInterval(updateClock, 1000);
}
var deadline = new Date(Date.parse(new Date()) + 10 * 1000); // for endless timer
initializeClock('seconds', deadline);