-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathdemo.html
60 lines (45 loc) · 1.42 KB
/
demo.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
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<style>
html,body, #container {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
(function(){
var touchstartTime;
var pageContents = '<h1>Click anywhere</h1>';
if(window.location.search.indexOf('energizeractive') !== -1) {
pageContents += '<h2>(energize.js is <a href="?">ACTIVE</a>)</h2>';
var script = document.createElement('script');
script.src = 'energize.js';
document.body.appendChild(script);
} else {
pageContents += '<h2>(energize.js is <a href="?energizeractive">INACTIVE)</a></h2>';
}
pageContents += '<div id="stats"></div>';
document.getElementById('container').innerHTML = pageContents;
var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
document.getElementById('container').addEventListener('click', function(e){
document.body.setAttribute('style', 'background-color: ' + colors[Math.floor(Math.random() * colors.length)]);
document.getElementById('stats').innerHTML = 'Click took ' + (Date.now() - touchstartTime) + 'ms';
touchstartTime = 0;
}, false);
document.getElementById('container').addEventListener('touchstart', function(e){
touchstartTime = Date.now();
}, false);
})();
</script>
</body>
</html>