Skip to content

Commit 73e9a5c

Browse files
committed
static chessboard finished
1 parent cbaa091 commit 73e9a5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+909
-59
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
*.xcodeproj
33
.settings
4+
typings/

Chess/application.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../typings/angular2/angular2.d.ts" />
1+
/// <reference path="typings/angular2/angular2.d.ts" />
22
/// <reference path="chessboard.ts" />
33
import {Component, View, bootstrap} from 'angular2/angular2';
44
import {ChessUI} from "./chessboard";

Chess/cheat.sheet

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
npm install -g tsd@^0.6.0
3+
tsd install angular2 es6-promise rx rx-lite
4+
15
Compilation:
26
- built-in with Visual Studio Code
37
- built-in with Atom

Chess/chessboard.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div *ng-for="#row of fields; var rowindex=index" style="width: 630px; height: 68px; overflow: hidden;" >
2+
<field *ng-for="#col of row; var colindex=index" [row]=rowindex [col]=colindex [piece]=col >
3+
</div>
4+
</div>

Chess/chessboard.js

+3-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/chessboard.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/chessboard.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
/// <reference path="../typings/angular2/angular2.d.ts" />
1+
/// <reference path="typings/angular2/angular2.d.ts" />
22
/// <reference path="field.ts" />
33
import {Component, View, NgFor, bootstrap} from 'angular2/angular2';
4+
import {FieldComponent} from './field';
45

56
export module ChessUI {
67
// Annotation section
78
@Component({
89
selector: 'chessboard'
910
})
1011
@View({
11-
directives: [NgFor],
12-
template: '<div *ng-for="#row of fields; var rowindex=index" style="width: 630px; height: 68px; overflow: hidden;" >\
13-
<div *ng-for="#col of row; var colindex=index" style="position: relative; left: 0; top: 0; width: 68px; height: 68px; margin-right:-4px; display: inline-block" >\
14-
<div style="position: relative; top: 0; left: 0;"><img style="width:70px;height:70px" src="{{backgroundFileName(rowindex,colindex)}}" /></div>\
15-
<div style="position: absolute; top: 0px; left: 0px;"><img style="width:70px;height:70px" src="{{fileName(col)}}" /></div>\
16-
</div>\
17-
</div>'
12+
directives: [NgFor, FieldComponent],
13+
templateUrl: 'chessboard.html'
1814
})
1915
// Component controller
2016
export class ChessBoardComponent {
@@ -37,7 +33,6 @@ export module ChessUI {
3733
return "wikimediaimages/b_empty.png"
3834
else
3935
return "wikimediaimages/w_empty.png"
40-
4136
}
4237

4338
private fileName(piece: number) {
@@ -57,10 +52,7 @@ export module ChessUI {
5752
return "wikimediaimages/" + prefix + pieceName + ".png";
5853
}
5954

60-
61-
6255
constructor() {
63-
6456
}
6557
}
6658
}

Chess/field.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div style="position: relative; left: 0; top: 0; width: 68px; height: 68px; margin-right:-4px; display: inline-block" >
2+
<div style="position: relative; top: 0; left: 0;">
3+
<img style="width:70px;height:70px" src="{{backgroundFileName(row,col)}}" />
4+
</div>
5+
<div style="position: absolute; top: 0px; left: 0px;">
6+
<img style="width:70px;height:70px" src="{{fileName(piece)}}" />
7+
</div>
8+
</div>

Chess/field.js

+4-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/field.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/field.ts

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
1-
/// <reference path="../typings/angular2/angular2.d.ts" />
1+
/// <reference path="typings/angular2/angular2.d.ts" />
22
import {Component, Attribute, View, NgFor, bootstrap} from 'angular2/angular2';
33

4-
54
// Annotation section
65
@Component({
76
selector: 'field',
8-
properties: ['title: title','row: row']
7+
properties: ['piece','row: row', 'col']
98
})
109
@View({
1110
directives: [NgFor],
12-
template: '\
13-
<div style="position: relative; left: 0; top: 0; width: 68px; height: 68px; margin-right:-4px; display: inline-block" >\
14-
<div style="position: relative; top: 0; left: 0;">\
15-
<img style="width:70px;height:70px" src="{{backgroundFileName(row,col)}}" />\
16-
</div>\
17-
<div style="position: absolute; top: 0px; left: 0px;">\
18-
piece={{piece}}<img style="width:70px;height:70px" src="{{fileName(piece)}}" />\
19-
</div>\
20-
</div>'
11+
templateUrl: 'field.html'
2112
})
22-
// Component controller
2313
export class FieldComponent {
24-
title: string = "Hallo Welt"
2514
_row: string;
26-
set row(val:string) {this._row=val; console.log("Setter!");}
27-
get row(): string { console.log(this.title); console.log("getter!"); return this._row;}
15+
set row(val:string) {this._row=val; }
16+
get row(): string {return this._row;}
2817
piece: string;
2918
col: string;
3019

@@ -52,7 +41,3 @@ export class FieldComponent {
5241
return "wikimediaimages/" + prefix + pieceName + ".png";
5342
}
5443
}
55-
56-
57-
58-
// bootstrap(Chess.ChessBoardComponent);

Chess/index.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
<title>AngularJS 2.0 learns to play chess!</title>
55
<script src="https://github.jspm.io/jmcriffey/[email protected]/traceur-runtime.js"></script>
66
<script src="https://jspm.io/[email protected]"></script>
7-
<script src="https://code.angularjs.org/2.0.0-alpha.35/angular2.dev.js"></script>
7+
<script src="https://code.angularjs.org/2.0.0-alpha.36/angular2.dev.js"></script>
88
</head>
99
<body>
1010
<application>
1111
</application>
12-
<script>System.import('chessboard');</script>
13-
<!-- <script>System.import('field');</script> -->
1412
<script>System.import('application');</script>
1513
</body>
1614
</html>

0 commit comments

Comments
 (0)