-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (58 loc) · 1.45 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
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Game of Life</title>
<link rel="stylesheet/less" href="style.less" type="text/css"/>
<script src="lib/less.min.js"></script>
<script src="src/life.js"></script>
<script src="src/patterns.js"></script>
</head>
<body>
<div class="panes">
<div class="pane top">
<div class="controls">
<button type="button" class="stop-start">Stop</button>
</div>
</div>
<div class="pane left">
<div class="controls">
<button type="button" class="stop-start">Stop</button>
</div>
</div>
<div class="pane right">
<div class="controls">
<button type="button" class="stop-start">Stop</button>
</div>
</div>
<div class="pane bottom">
<div class="controls">
<button type="button" class="stop-start">Stop</button>
</div>
</div>
</div>
<script>
(function (window) {
var panes = Array.prototype.slice.call(document.querySelectorAll(".pane")),
games = [];
panes.forEach(function (pane) {
var game = new GameOfLife({
element: pane
});
pane.querySelector(".stop-start").addEventListener("click", function (event) {
var running = game.running;
if (running) {
game.pause();
this.textContent = "Start";
} else {
game.run();
this.textContent = "Stop";
}
}, false);
games.push(game);
});
window.games = games;
})(this);
</script>
</body>
</html>