-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathblink2.html
65 lines (61 loc) · 2 KB
/
blink2.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8">
<meta name="description" content="Koalas to the Max, a site made with love by Vadim Ogievetsky for Annie Albagli">
<meta name="keywords" content="Clcoks">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="google" content="notranslate">
<title>Blink</title>
<style type="text/css">
body {
background: #111;
margin: 0;
}
#msg {
color: white;
font-family: sans-serif;
padding: 10px;
}
</style>
</head>
<body>
<div id="msg">-</div>
<script>
var preTime = new Date().valueOf();
var serverTime;
var postTime;
var serverOffset;
function st(v) {
serverTime = new Date(v.dateString).valueOf();
postTime = new Date().valueOf();
serverOffset = serverTime - Math.floor((postTime + preTime) / 2);
}
</script>
<script type="text/javascript" src="http://www.timeapi.org/utc/now.json?\FT\T.\L&callback=st"></script>
<script>
var INTERVAL = 3000;
var body = document.getElementsByTagName('body')[0];
var msg = document.getElementById('msg');
function blick(now) {
body.style.background = 'red';
msg.innerText = '' + now + ' (' + serverOffset + ')';
document.title = '💥 ' + (now % INTERVAL) + 'ms';
setTimeout(function() {
body.style.background = null;
document.title = 'Blink';
}, 400);
}
function next() {
var now = new Date().valueOf() + serverOffset;
var offset = now % INTERVAL;
setTimeout(next, INTERVAL - offset);
if (offset < 25) blick(now);
}
next();
</script>
</body>
</html>