-
Notifications
You must be signed in to change notification settings - Fork 2
/
timer.html
89 lines (70 loc) · 1.75 KB
/
timer.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>#пккбпв timer</title>
<style>
* { margin: 0; padding: 0; }
html {
background: no-repeat center center fixed;
background-image: url(gifs/0.gif);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#page-wrap {
width: 400px;
height: 400px;
position:absolute;
left:50%;
top:50%;
margin:-200px 0 0 -200px;
font: 180px Arial;
text-align: center;
line-height: 400px;
color: #fff;
text-shadow: 2px 2px 5px #000;
/*background: rgba(255,255,255,0.2); */
background: rgba(0,0,0,0.2);
-moz-box-shadow: 0 0 20px black;
-webkit-box-shadow: 0 0 20px black;
box-shadow: 0 0 20px black;
}
</style>
</head>
<body>
<div id="page-wrap">
</div>
<script>
function setSec(sec) {
document.getElementById("page-wrap").innerHTML=sec;// + " sec remaining";
}
function nextImage() {
return 'url(gifs/' + Math.floor((Math.random()*24)) + '.gif)';
}
var currentTimer = {};
function run(time) {
clearInterval(currentTimer);
var count=time;
setSec(count);
currentTimer=setInterval(timer, 1000); //1000 will run it every 1 second
function timer() {
count = count - 1;
if (count <= 0) {
clearInterval(currentTimer);
setSec('Boo!');
//counter ended, do something here
return;
}
if (count % 4 == 0) {
var htmlElement = document.getElementsByTagName("html")[0];
htmlElement.style.backgroundImage = nextImage();
}
setSec(count);
}
}
run(90);
</script>
</body></html>