Skip to content

Commit 30519eb

Browse files
bod -> body again, use consts for ids
1 parent 1b47e1d commit 30519eb

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

mankala/Game.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ module Mankala {
1010
export var NoScore = 31;
1111
export var NoMove = -1;
1212

13+
const bodyId = "body";
14+
const humanScoreId = "humscore";
15+
const computerScoreId = "compscore"
16+
1317
export interface IPositionList extends Base.IList {
1418
data: Position;
1519
push(pos: Position);
@@ -32,7 +36,7 @@ module Mankala {
3236
export function testBrowser() {
3337
var game = new Game();
3438
game.interactive();
35-
var body = <HTMLBodyElement>document.getElementById("bod");
39+
var body = <HTMLBodyElement>document.getElementById(bodyId);
3640
body.onresize = () => { game.resize(); };
3741
}
3842

@@ -47,12 +51,12 @@ module Mankala {
4751

4852
private features = new Features();
4953
private nextSeedCounts: number[] = new Array<number>(14);
50-
private bod: Element;
54+
private body: Element;
5155
private boardElm: Element = null;
5256

5357
public resize() {
5458
if (this.boardElm != null) {
55-
this.bod.removeChild(this.boardElm);
59+
this.body.removeChild(this.boardElm);
5660
}
5761
this.showMove();
5862
}
@@ -77,7 +81,7 @@ module Mankala {
7781
if (!this.step()) {
7882
this.finish();
7983
}
80-
this.bod.removeChild(this.boardElm);
84+
this.body.removeChild(this.boardElm);
8185
this.showMove();
8286
}, 1000);
8387
}
@@ -94,15 +98,15 @@ module Mankala {
9498

9599
private auto() {
96100
// initialize
97-
this.bod = document.getElementById("bod");
101+
this.body = document.getElementById(bodyId);
98102
this.showMove();
99103
// run with timeout
100104
this.setStep();
101105
}
102106

103107
private showMove(): void {
104-
var hsc = document.getElementById("humscore");
105-
var csc = document.getElementById("compscore");
108+
var hsc = document.getElementById(humanScoreId);
109+
var csc = document.getElementById(computerScoreId);
106110

107111
var g = this;
108112
if (!this.isInteractive) {
@@ -114,7 +118,7 @@ module Mankala {
114118
((this.position.turn == 0) ? " <-Turn" : "");
115119
csc.innerText = this.position.seedCounts[storeHouses[1]] +
116120
((this.position.turn == 1) ? " <-Turn" : "");
117-
this.bod.appendChild(this.boardElm);
121+
this.body.appendChild(this.boardElm);
118122
}
119123

120124
public humanMove(seed: number) {
@@ -123,7 +127,7 @@ module Mankala {
123127
this.position = new DisplayPosition(this.nextSeedCounts.slice(0), NoMove,
124128
this.features.turnContinues ? this.position.turn : 1 - this.position.turn);
125129
this.position.config = this.prevConfig;
126-
this.bod.removeChild(this.boardElm);
130+
this.body.removeChild(this.boardElm);
127131
this.showMove();
128132
if (this.position.turn == 1) {
129133
this.setStep();
@@ -133,7 +137,7 @@ module Mankala {
133137

134138
public interactive() {
135139
this.isInteractive = true;
136-
this.bod = document.getElementById("bod");
140+
this.body = document.getElementById(bodyId);
137141
this.showMove();
138142
}
139143

mankala/Position.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ module Mankala {
182182

183183
public toCircleSVG(game: Game) {
184184
var seedDivisions = 14;
185-
var bod = document.getElementById("bod");
186185
var board = document.createElementNS(svgNS, "svg");
187186
var w = window.innerWidth - 40;
188187
var h = window.innerHeight - 40;

mankala/play.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script type="text/javascript" src="game.js"></script>
99
<link rel="stylesheet" type="text/css" href="play.css"/>
1010
</head>
11-
<body id="bod" onload="Mankala.testBrowser()">
11+
<body id="body" onload="Mankala.testBrowser()">
1212
<div class="hscore">Human: <span id="humscore">0</span></div>
1313
<div class="cscore">Computer: <span id="compscore">0</span></div>
1414
</body>

0 commit comments

Comments
 (0)