-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
86 lines (65 loc) · 2.72 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!doctype html>
<html ng-app>
<head>
<title>Game of Life</title>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div class="cf" id="header">
<h1 id="icon">Game of Life</h1>
<div id="grid-input">
<span>Grid Size</span>
<input type="text" id="gridsize" value="20" />
</div>
<button id="startAnimation">start</button>
<button id="clearGrid">clear</button>
<!--
<ul class="cf" id="nav">
<li><a id="noOfGrids" href="javascript: void 0">50</a></li>
<li><a id="timeElapsed" href="javascript: void 0">Time Elapsed</a></li>
<li><a href="javascript: void 0">Some Link</a></li>
<li><a href="javascript: void 0">Some other link</a></li>
</ul>
-->
</div>
<div id="gameCanvas"></div>
<div id="timerTag">0 ms</div>
<script src="js/plugin.js"></script>
<script>
var
canvas = document.querySelector('#gameCanvas')
, startAnimation = document.querySelector('#startAnimation')
, animationStarted = false
, gridSize = document.querySelector('#gridsize')
, clearGrid = document.querySelector('#clearGrid')
, timerTag = document.querySelector('#timerTag')
;
$$.init ( canvas, {
gridSize : gridSize.value,
deadColor : '#FFFFFF',
aliveColor : '#000000',
borderColor : '#4878B8',
timerTag : timerTag,
});
$$.registerListener( gridSize , 'keyup', function ( e ) {
if ( e.which == 13 || e.keyCode == 13 ) {
$$.reinit ( gridSize.value );
}
}, false );
$$.registerListener( clearGrid , 'click', function ( e ) {
animationStarted = $$.clear();
startAnimation.innerHTML = 'start';
}, false );
$$.registerListener( startAnimation , 'click', function ( e ) {
if (!animationStarted) {
this.innerHTML = 'stop';
animationStarted = $$.start ();
}
else {
this.innerHTML = 'start';
animationStarted = $$.stop();
}
}, false );
</script>
</body>
</html>