-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
57 lines (48 loc) · 1.63 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<!-- Try double clicking. -->
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
a { text-decoration: none; color: #f00; }
body { font-family: Helvetica, sans-serif; background: #222; color: #fff; }
h1, p { margin: 20px; text-shadow: 1px 1px 1px #000; }
.box {
border-radius: 20px;
padding-top: 40px;
margin: 20px;
display:inline-block;
width: 110px;
height: 60px;
color: #fff;
background-color: #444;
text-align: center;
border-top: 1px solid #111;
border-bottom: 1px solid #666;
}
</style>
</head>
<body>
<h1>Click to see how latency feels.</h1>
<div id="demo"></div>
<p>Originally <a href="http://benzilla.galbraiths.org/">Ben Galbraith</a>'s idea. But his version is down.</p>
<script>
var j, delay = [0, 10, 25, 50, 100, 200, 300, 400, 500, 750];
var timeouts = {};
for (j in delay) {
var i = delay[j];
$('#demo').append('<a href="#" class="box" id=' + i + '>'+i+' ms</a>');
(function(i) {
$('#'+i).toggle(function() {
clearTimeout(timeouts[i]);
timeouts[i] = setTimeout(function() { $('#'+i).css('background-color','#fff')}, i);
},function() {
clearTimeout(timeouts[i]);
timeouts[i] = setTimeout(function() { $('#'+i).css('background-color', 'red')}, i);
});
})(i)
}
</script>
<a href="http://github.com/ryanwitt/latency-demo/"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/71eeaab9d563c2b3c590319b398dd35683265e85/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub"></a>
</body>
</html>