-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.html
64 lines (60 loc) · 1.94 KB
/
test.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
<!DOCTYPE html>
<html>
<body>
<h3>Hangout Timer</h3>
<p>You can close this panel by clicking on the Hourglass icon, on the app list (left of the screen).
<canvas id="img" width="100" height="100"></canvas>
<button id="start2s">start 2s</button>
<button id="start10s">start 10s</button>
<button id="start30s">start 30s</button>
<button id="stop">stop</button>
<!--<script src="Hourglass.js"></script>-->
<script>
var include = (function(){
var FINAL_STATES = {"loaded": true, "complete": true, 4: true},
head = document.getElementsByTagName("head")[0],
pending = {};
return function(src, cb){
if (pending[src]) return;
pending[src] = true;
var inc = document.createElement("script");
inc.onload = inc.onreadystatechange = function() {
if (pending[src] && (!inc.readyState || FINAL_STATES[inc.readyState])) {
cb && cb();
delete pending[src];
}
};
inc.src = src;
head.appendChild(inc);
};
})();
var CANVAS = document.getElementById("img");
include("src/Hourglass.js?_t" + Date.now(), function(){
var radius = CANVAS.height / 12;
console.log(CANVAS, radius, CANVAS.width / 2, CANVAS.height - radius * 3);
var hourglass = new Hourglass(CANVAS, radius, CANVAS.width / 2, CANVAS.height - radius * 3);
//var hourglass = new Hourglass(CANVAS);
var stopwatch = new Stopwatch();
function makeSet(duration){
return function(){
if (duration){
var ms = duration * 1000;
stopwatch.reset(ms);
hourglass.clear();
stopwatch.handler = function(){
hourglass.drawToDataUrl(stopwatch.elapsed / ms);
};
stopwatch.start();
}
else
stopwatch.stop();
};
}
document.getElementById("start2s").onclick = makeSet(2);
document.getElementById("start10s").onclick = makeSet(10);
document.getElementById("start30s").onclick = makeSet(30);
document.getElementById("stop").onclick = makeSet();
});
</script>
</body>
</html>