-
Notifications
You must be signed in to change notification settings - Fork 0
/
beat.html
55 lines (47 loc) · 1.27 KB
/
beat.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
<!DOCTYPE html>
<html>
<head>
<style>
p {
text-align: center;
font-size: 15vw;
margin-top: 30px;
margin-bottom: 10px;
color: lavender;
}
p.link {
text-align: center;
font-size: 3vw;
color: lightgray;
}
</style>
</head>
<body bgcolor='#121212'>
<p id="beat"></p>
<p class="link">Fork me in github: <a href="https://github.com/tonyskapunk/beat">.beat</a></p>
<script>
function internettime(h, m, s, centibeats=true) {
var itime = (( s + (m * 60) + ((h + 1) * 3600)) / 86.4) % 1000
var beats = ""
if (centibeats) {
beats = itime.toFixed(3)
} else {
beats = Math.floor(itime)
}
return `@${beats}`
}
function beats_now() {
var d = new Date()
var beats = internettime(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds())
return beats
}
// Updates the displayed time every centibeat (864 miliseconds)
var x = setInterval(function() {
// Call beats_now
var beats = beats_now()
// Output the result:
document.getElementById("beat").innerHTML = `${beats}`
}, 864);
</script>
</body>
</html>