-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
56 lines (49 loc) · 1.76 KB
/
clock.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
<script type="text/javascript">
var imageclock=new Object()
imageclock.digits=["clock/c0.png", "clock/c1.png", "clock/c2.png", "clock/c3.png", "clock/c4.png", "clock/c5.png", "clock/c6.png", "clock/c7.png", "clock/c8.png", "clock/c9.png", "clock/cc.png"]
imageclock.instances=0
var preloadimages=[]
for (var i=0; i<imageclock.digits.length; i++){
preloadimages[i]=new Image()
preloadimages[i].src=imageclock.digits[i]
}
imageclock.imageHTML=function(timestring){
var sections=timestring.split(":")
for (var i=0; i<sections.length; i++){
if (sections[i].length==1)
sections[i]='<img src="'+imageclock.digits[0]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i])]+'" />'
else
sections[i]='<img src="'+imageclock.digits[parseInt(sections[i].charAt(0))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(1))]+'" />'
}
return sections[0]+'<img src="'+imageclock.digits[10]+'" />'+sections[1]+'<img src="'+imageclock.digits[10]+'" />'+sections[2]
}
imageclock.display=function(){
var clockinstance=this
this.spanid="clockspan"+(imageclock.instances++)
document.write('<span id="'+this.spanid+'"></span>')
this.update()
setInterval(function(){clockinstance.update()}, 1000)
}
imageclock.display.prototype.update=function(){
var dateobj=new Date()
var currenttime=dateobj.getHours()+":"+dateobj.getMinutes()+":"+dateobj.getSeconds()
var currenttimeHTML=imageclock.imageHTML(currenttime)
document.getElementById(this.spanid).innerHTML=currenttimeHTML
}
</script>
<style>
.center {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 10vw;
padding: 20vw;
}
</style>
<body bgcolor="black">
<div class="center">
<script type="text/javascript">
new imageclock.display()
</script>
</div>