cm-chessboard 3.16.9 → 3.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/styles/cm-chessboard.css +1 -1
- package/assets/styles/cm-chessboard.css.map +1 -1
- package/assets/styles/cm-chessboard.scss +45 -0
- package/examples/enable-input.html +3 -2
- package/examples/many-boards.html +1 -0
- package/package.json +1 -1
- package/src/cm-chessboard/Chessboard.js +4 -1
- package/src/cm-chessboard/ChessboardState.js +27 -1
- package/src/cm-chessboard/ChessboardView.js +31 -0
- package/src/cm-chessboard/ChessboardViewAccessible.js +109 -0
- package/test/TestState.js +27 -0
- package/test/index.html +2 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.cm-chessboard .board.input-enabled .square{cursor:pointer}.cm-chessboard .markers .marker.markerFrame,.cm-chessboard .markers .marker.marker-frame{stroke:black;stroke-width:1.8px;opacity:0.5}.cm-chessboard .markers .marker.markerFrameRed,.cm-chessboard .markers .marker.marker-frame-red{stroke:#aa0000;stroke-width:1.8px;opacity:0.4}.cm-chessboard .markers .marker.markerSquare,.cm-chessboard .markers .marker.marker-square{fill:black;opacity:0.11}.cm-chessboard .markers .marker.markerDot,.cm-chessboard .markers .marker.marker-dot{fill:black;opacity:0.3}.cm-chessboard .markers .marker.markerCircle,.cm-chessboard .markers .marker.marker-circle{stroke:#000055;stroke-width:3px;opacity:0.4}.cm-chessboard .markers .marker.markerCircleRed,.cm-chessboard .markers .marker.marker-circle-red{stroke:#aa0000;stroke-width:3px;opacity:0.4}.cm-chessboard .pieces,.cm-chessboard .markers{pointer-events:none}.cm-chessboard.default .board .square.white{fill:#ecdab9}.cm-chessboard.default .board .square.black{fill:#c5a076}.cm-chessboard.default.border-type-thin .board .border{stroke:#c5a076;stroke-width:0.7%;fill:transparent}.cm-chessboard.default.border-type-frame .board .border{fill:#ecdab9;stroke:none}.cm-chessboard.default.border-type-frame .board .border-inner{fill:transparent;stroke:#c5a076;stroke-width:0.7%}.cm-chessboard.default .coordinates{pointer-events:none;user-select:none}.cm-chessboard.default .coordinates .coordinate{fill:#c5a076;font-size:7px;cursor:default}.cm-chessboard.default .coordinates .coordinate.black{fill:#ecdab9}.cm-chessboard.default .coordinates .coordinate.white{fill:#c5a076}.cm-chessboard.green .board .square.white{fill:#E0DDCC}.cm-chessboard.green .board .square.black{fill:#4c946a}.cm-chessboard.green.border-type-thin .board .border{stroke:#4c946a;stroke-width:0.7%;fill:transparent}.cm-chessboard.green.border-type-frame .board .border{fill:#E0DDCC;stroke:none}.cm-chessboard.green.border-type-frame .board .border-inner{fill:transparent;stroke:#4c946a;stroke-width:0.7%}.cm-chessboard.green .coordinates{pointer-events:none;user-select:none}.cm-chessboard.green .coordinates .coordinate{fill:#4c946a;font-size:7px;cursor:default}.cm-chessboard.green .coordinates .coordinate.black{fill:#E0DDCC}.cm-chessboard.green .coordinates .coordinate.white{fill:#4c946a}.cm-chessboard.blue .board .square.white{fill:#d8ecfb}.cm-chessboard.blue .board .square.black{fill:#86afcf}.cm-chessboard.blue.border-type-thin .board .border{stroke:#86afcf;stroke-width:0.7%;fill:transparent}.cm-chessboard.blue.border-type-frame .board .border{fill:#d8ecfb;stroke:none}.cm-chessboard.blue.border-type-frame .board .border-inner{fill:transparent;stroke:#86afcf;stroke-width:0.7%}.cm-chessboard.blue .coordinates{pointer-events:none;user-select:none}.cm-chessboard.blue .coordinates .coordinate{fill:#86afcf;font-size:7px;cursor:default}.cm-chessboard.blue .coordinates .coordinate.black{fill:#d8ecfb}.cm-chessboard.blue .coordinates .coordinate.white{fill:#86afcf}.cm-chessboard.chess-club .board .square.white{fill:#E6D3B1}.cm-chessboard.chess-club .board .square.black{fill:#AF6B3F}.cm-chessboard.chess-club.border-type-thin .board .border{stroke:#692e2b;stroke-width:0.7%;fill:transparent}.cm-chessboard.chess-club.border-type-frame .board .border{fill:#692e2b;stroke:none}.cm-chessboard.chess-club.border-type-frame .board .border-inner{fill:transparent;stroke:#692e2b;stroke-width:0.7%}.cm-chessboard.chess-club .coordinates{pointer-events:none;user-select:none}.cm-chessboard.chess-club .coordinates .coordinate{fill:#E6D3B1;font-size:7px;cursor:default}.cm-chessboard.chess-club .coordinates .coordinate.black{fill:#E6D3B1}.cm-chessboard.chess-club .coordinates .coordinate.white{fill:#AF6B3F}.cm-chessboard.chessboard-js .board .square.white{fill:#f0d9b5}.cm-chessboard.chessboard-js .board .square.black{fill:#b58863}.cm-chessboard.chessboard-js.border-type-thin .board .border{stroke:#404040;stroke-width:0.7%;fill:transparent}.cm-chessboard.chessboard-js.border-type-frame .board .border{fill:#f0d9b5;stroke:none}.cm-chessboard.chessboard-js.border-type-frame .board .border-inner{fill:transparent;stroke:#404040;stroke-width:0.7%}.cm-chessboard.chessboard-js .coordinates{pointer-events:none;user-select:none}.cm-chessboard.chessboard-js .coordinates .coordinate{fill:#404040;font-size:7px;cursor:default}.cm-chessboard.chessboard-js .coordinates .coordinate.black{fill:#f0d9b5}.cm-chessboard.chessboard-js .coordinates .coordinate.white{fill:#b58863}.cm-chessboard.black-and-white .board .square.white{fill:#fff}.cm-chessboard.black-and-white .board .square.black{fill:#9c9c9c}.cm-chessboard.black-and-white.border-type-thin .board .border{stroke:#9c9c9c;stroke-width:0.7%;fill:transparent}.cm-chessboard.black-and-white.border-type-frame .board .border{fill:#fff;stroke:none}.cm-chessboard.black-and-white.border-type-frame .board .border-inner{fill:transparent;stroke:#9c9c9c;stroke-width:0.7%}.cm-chessboard.black-and-white .coordinates{pointer-events:none;user-select:none}.cm-chessboard.black-and-white .coordinates .coordinate{fill:#9c9c9c;font-size:7px;cursor:default}.cm-chessboard.black-and-white .coordinates .coordinate.black{fill:#fff}.cm-chessboard.black-and-white .coordinates .coordinate.white{fill:#9c9c9c}
|
|
1
|
+
.cm-chessboard .board.input-enabled .square{cursor:pointer}.cm-chessboard .markers .marker.markerFrame,.cm-chessboard .markers .marker.marker-frame{stroke:black;stroke-width:1.8px;opacity:0.5}.cm-chessboard .markers .marker.markerFrameRed,.cm-chessboard .markers .marker.marker-frame-red{stroke:#aa0000;stroke-width:1.8px;opacity:0.4}.cm-chessboard .markers .marker.markerSquare,.cm-chessboard .markers .marker.marker-square{fill:black;opacity:0.11}.cm-chessboard .markers .marker.markerDot,.cm-chessboard .markers .marker.marker-dot{fill:black;opacity:0.3}.cm-chessboard .markers .marker.markerCircle,.cm-chessboard .markers .marker.marker-circle{stroke:#000055;stroke-width:3px;opacity:0.4}.cm-chessboard .markers .marker.markerCircleRed,.cm-chessboard .markers .marker.marker-circle-red{stroke:#aa0000;stroke-width:3px;opacity:0.4}.cm-chessboard .pieces,.cm-chessboard .markers{pointer-events:none}.cm-chessboard-content .list-inline{padding-left:0;list-style:none}.cm-chessboard-content .list-inline-item{display:inline-block}.cm-chessboard-content .list-inline-item:not(:last-child){margin-right:1rem}.cm-chessboard-content .list-inline{padding-left:0;list-style:none}.cm-chessboard-content .list-inline-item{display:inline-block}.cm-chessboard-content .list-inline-item:not(:last-child){margin-right:1rem}.cm-chessboard-content.visually-hidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.cm-chessboard.default .board .square.white{fill:#ecdab9}.cm-chessboard.default .board .square.black{fill:#c5a076}.cm-chessboard.default.border-type-thin .board .border{stroke:#c5a076;stroke-width:0.7%;fill:transparent}.cm-chessboard.default.border-type-frame .board .border{fill:#ecdab9;stroke:none}.cm-chessboard.default.border-type-frame .board .border-inner{fill:transparent;stroke:#c5a076;stroke-width:0.7%}.cm-chessboard.default .coordinates{pointer-events:none;user-select:none}.cm-chessboard.default .coordinates .coordinate{fill:#c5a076;font-size:7px;cursor:default}.cm-chessboard.default .coordinates .coordinate.black{fill:#ecdab9}.cm-chessboard.default .coordinates .coordinate.white{fill:#c5a076}.cm-chessboard.green .board .square.white{fill:#E0DDCC}.cm-chessboard.green .board .square.black{fill:#4c946a}.cm-chessboard.green.border-type-thin .board .border{stroke:#4c946a;stroke-width:0.7%;fill:transparent}.cm-chessboard.green.border-type-frame .board .border{fill:#E0DDCC;stroke:none}.cm-chessboard.green.border-type-frame .board .border-inner{fill:transparent;stroke:#4c946a;stroke-width:0.7%}.cm-chessboard.green .coordinates{pointer-events:none;user-select:none}.cm-chessboard.green .coordinates .coordinate{fill:#4c946a;font-size:7px;cursor:default}.cm-chessboard.green .coordinates .coordinate.black{fill:#E0DDCC}.cm-chessboard.green .coordinates .coordinate.white{fill:#4c946a}.cm-chessboard.blue .board .square.white{fill:#d8ecfb}.cm-chessboard.blue .board .square.black{fill:#86afcf}.cm-chessboard.blue.border-type-thin .board .border{stroke:#86afcf;stroke-width:0.7%;fill:transparent}.cm-chessboard.blue.border-type-frame .board .border{fill:#d8ecfb;stroke:none}.cm-chessboard.blue.border-type-frame .board .border-inner{fill:transparent;stroke:#86afcf;stroke-width:0.7%}.cm-chessboard.blue .coordinates{pointer-events:none;user-select:none}.cm-chessboard.blue .coordinates .coordinate{fill:#86afcf;font-size:7px;cursor:default}.cm-chessboard.blue .coordinates .coordinate.black{fill:#d8ecfb}.cm-chessboard.blue .coordinates .coordinate.white{fill:#86afcf}.cm-chessboard.chess-club .board .square.white{fill:#E6D3B1}.cm-chessboard.chess-club .board .square.black{fill:#AF6B3F}.cm-chessboard.chess-club.border-type-thin .board .border{stroke:#692e2b;stroke-width:0.7%;fill:transparent}.cm-chessboard.chess-club.border-type-frame .board .border{fill:#692e2b;stroke:none}.cm-chessboard.chess-club.border-type-frame .board .border-inner{fill:transparent;stroke:#692e2b;stroke-width:0.7%}.cm-chessboard.chess-club .coordinates{pointer-events:none;user-select:none}.cm-chessboard.chess-club .coordinates .coordinate{fill:#E6D3B1;font-size:7px;cursor:default}.cm-chessboard.chess-club .coordinates .coordinate.black{fill:#E6D3B1}.cm-chessboard.chess-club .coordinates .coordinate.white{fill:#AF6B3F}.cm-chessboard.chessboard-js .board .square.white{fill:#f0d9b5}.cm-chessboard.chessboard-js .board .square.black{fill:#b58863}.cm-chessboard.chessboard-js.border-type-thin .board .border{stroke:#404040;stroke-width:0.7%;fill:transparent}.cm-chessboard.chessboard-js.border-type-frame .board .border{fill:#f0d9b5;stroke:none}.cm-chessboard.chessboard-js.border-type-frame .board .border-inner{fill:transparent;stroke:#404040;stroke-width:0.7%}.cm-chessboard.chessboard-js .coordinates{pointer-events:none;user-select:none}.cm-chessboard.chessboard-js .coordinates .coordinate{fill:#404040;font-size:7px;cursor:default}.cm-chessboard.chessboard-js .coordinates .coordinate.black{fill:#f0d9b5}.cm-chessboard.chessboard-js .coordinates .coordinate.white{fill:#b58863}.cm-chessboard.black-and-white .board .square.white{fill:#fff}.cm-chessboard.black-and-white .board .square.black{fill:#9c9c9c}.cm-chessboard.black-and-white.border-type-thin .board .border{stroke:#9c9c9c;stroke-width:0.7%;fill:transparent}.cm-chessboard.black-and-white.border-type-frame .board .border{fill:#fff;stroke:none}.cm-chessboard.black-and-white.border-type-frame .board .border-inner{fill:transparent;stroke:#9c9c9c;stroke-width:0.7%}.cm-chessboard.black-and-white .coordinates{pointer-events:none;user-select:none}.cm-chessboard.black-and-white .coordinates .coordinate{fill:#9c9c9c;font-size:7px;cursor:default}.cm-chessboard.black-and-white .coordinates .coordinate.black{fill:#fff}.cm-chessboard.black-and-white .coordinates .coordinate.white{fill:#9c9c9c}
|
|
2
2
|
|
|
3
3
|
/*# sourceMappingURL=cm-chessboard.css.map */
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"_cm-chessboard-theme.scss"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAGA,AAGM,cAHQ,CACZ,MAAM,AACH,cAAc,CACb,OAAO,AAAC,CACN,MAAM,CAAE,OAAO,CAChB,AALP,
|
|
9
|
+
"mappings": "AAGA,AAGM,cAHQ,CACZ,MAAM,AACH,cAAc,CACb,OAAO,AAAC,CACN,MAAM,CAAE,OAAO,CAChB,AALP,AAYM,cAZQ,CASZ,QAAQ,CACN,OAAO,AAEJ,YAAY,CAZnB,cAAc,CASZ,QAAQ,CACN,OAA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CCzEd,AAnDT,AAoDQ,cApDM,AAAA,gBAAgB,CAyC1B,YAAY,CAIV,WAAW,AAOR,MAAM,AAAC,CACN,IAAI,CDuEW,OAAO,CCtEvB"
|
|
10
10
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
.markers {
|
|
13
14
|
.marker {
|
|
14
15
|
// use the second, the hyphens syntax
|
|
@@ -17,24 +18,29 @@
|
|
|
17
18
|
stroke-width: 1.8px;
|
|
18
19
|
opacity: 0.5;
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
&.markerFrameRed, &.marker-frame-red {
|
|
21
23
|
stroke: #aa0000;
|
|
22
24
|
stroke-width: 1.8px;
|
|
23
25
|
opacity: 0.4;
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
&.markerSquare, &.marker-square {
|
|
26
29
|
fill: black;
|
|
27
30
|
opacity: 0.11;
|
|
28
31
|
}
|
|
32
|
+
|
|
29
33
|
&.markerDot, &.marker-dot {
|
|
30
34
|
fill: black;
|
|
31
35
|
opacity: 0.3;
|
|
32
36
|
}
|
|
37
|
+
|
|
33
38
|
&.markerCircle, &.marker-circle {
|
|
34
39
|
stroke: #000055;
|
|
35
40
|
stroke-width: 3px;
|
|
36
41
|
opacity: 0.4;
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
&.markerCircleRed, &.marker-circle-red {
|
|
39
45
|
stroke: #aa0000;
|
|
40
46
|
stroke-width: 3px;
|
|
@@ -42,11 +48,50 @@
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
}
|
|
51
|
+
|
|
45
52
|
.pieces, .markers {
|
|
46
53
|
// important for the proper function
|
|
47
54
|
pointer-events: none;
|
|
48
55
|
}
|
|
49
56
|
}
|
|
57
|
+
.cm-chessboard-content {
|
|
58
|
+
.list-inline {
|
|
59
|
+
padding-left: 0;
|
|
60
|
+
list-style: none;
|
|
61
|
+
}
|
|
62
|
+
.list-inline-item {
|
|
63
|
+
display: inline-block;
|
|
64
|
+
|
|
65
|
+
&:not(:last-child) {
|
|
66
|
+
margin-right: 1rem;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.cm-chessboard-content {
|
|
72
|
+
.list-inline {
|
|
73
|
+
padding-left: 0;
|
|
74
|
+
list-style: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.list-inline-item {
|
|
78
|
+
display: inline-block;
|
|
79
|
+
|
|
80
|
+
&:not(:last-child) {
|
|
81
|
+
margin-right: 1rem;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&.visually-hidden {
|
|
86
|
+
position: absolute;
|
|
87
|
+
left: -10000px;
|
|
88
|
+
top: auto;
|
|
89
|
+
width: 1px;
|
|
90
|
+
height: 1px;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
50
95
|
|
|
51
96
|
// define themes
|
|
52
97
|
@include cm-chessboard-theme(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html lang="
|
|
2
|
+
<html lang="de">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<title>cm-chessboard</title>
|
|
@@ -40,6 +40,7 @@ function inputHandler(event) {
|
|
|
40
40
|
import {INPUT_EVENT_TYPE, Chessboard} from "../src/cm-chessboard/Chessboard.js"
|
|
41
41
|
|
|
42
42
|
window.board = new Chessboard(document.getElementById("board"), {
|
|
43
|
+
accessible: true,
|
|
43
44
|
position: "start",
|
|
44
45
|
sprite: {url: "../assets/images/chessboard-sprite-staunty.svg"}
|
|
45
46
|
})
|
|
@@ -67,4 +68,4 @@ function inputHandler(event) {
|
|
|
67
68
|
}
|
|
68
69
|
</script>
|
|
69
70
|
</body>
|
|
70
|
-
</html>
|
|
71
|
+
</html>
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {SQUARE_COORDINATES, ChessboardView} from "./ChessboardView.js"
|
|
8
8
|
import {ChessboardState} from "./ChessboardState.js"
|
|
9
|
+
import {ChessboardViewAccessible} from "./ChessboardViewAccessible.js"
|
|
9
10
|
|
|
10
11
|
export const COLOR = {
|
|
11
12
|
white: "w",
|
|
@@ -48,6 +49,7 @@ export class Chessboard {
|
|
|
48
49
|
let defaultProps = {
|
|
49
50
|
position: "empty", // set as fen, "start" or "empty"
|
|
50
51
|
orientation: COLOR.white, // white on bottom
|
|
52
|
+
accessible: false, // render additional information to improve the usage for people using screen readers (beta)
|
|
51
53
|
style: {
|
|
52
54
|
cssClass: "default",
|
|
53
55
|
showCoordinates: true, // show ranks and files
|
|
@@ -91,7 +93,8 @@ export class Chessboard {
|
|
|
91
93
|
this.state = new ChessboardState()
|
|
92
94
|
this.state.orientation = this.props.orientation
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
const viewType = this.props.accessible ? ChessboardViewAccessible : ChessboardView
|
|
97
|
+
this.view = new viewType(this, (view) => {
|
|
95
98
|
if (this.props.position === "start") {
|
|
96
99
|
this.state.setPosition(FEN_START_POSITION)
|
|
97
100
|
} else if (this.props.position === "empty" || this.props.position === undefined) {
|
|
@@ -16,6 +16,26 @@ export class ChessboardState {
|
|
|
16
16
|
this.squareSelectEnabled = false
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
getPieces() {
|
|
20
|
+
const pieces = []
|
|
21
|
+
const sortBy = ['k', 'q', 'r', 'b', 'n', 'p']
|
|
22
|
+
const sort = (a, b) => {
|
|
23
|
+
return sortBy.indexOf(a.name) - sortBy.indexOf(b.name)
|
|
24
|
+
}
|
|
25
|
+
for(let i=0; i<64; i++) {
|
|
26
|
+
const piece = this.squares[i]
|
|
27
|
+
if(piece) {
|
|
28
|
+
pieces.push({
|
|
29
|
+
name: piece.charAt(1),
|
|
30
|
+
color: piece.charAt(0),
|
|
31
|
+
position: this.indexToSquare(i)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
pieces.sort(sort)
|
|
36
|
+
return pieces
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
setPiece(index, piece) {
|
|
20
40
|
this.squares[index] = piece
|
|
21
41
|
}
|
|
@@ -109,4 +129,10 @@ export class ChessboardState {
|
|
|
109
129
|
return 8 * rank + file
|
|
110
130
|
}
|
|
111
131
|
|
|
112
|
-
|
|
132
|
+
indexToSquare(index) {
|
|
133
|
+
const file = String.fromCharCode(index % 8 + 97)
|
|
134
|
+
const rank = Math.floor(index / 8) + 1
|
|
135
|
+
return file + rank
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
@@ -8,6 +8,37 @@ import {ChessboardMoveInput} from "./ChessboardMoveInput.js"
|
|
|
8
8
|
import {COLOR, INPUT_EVENT_TYPE, BORDER_TYPE} from "./Chessboard.js"
|
|
9
9
|
import {ChessboardPiecesAnimation} from "./ChessboardPiecesAnimation.js"
|
|
10
10
|
|
|
11
|
+
export const piecesTranslations = {
|
|
12
|
+
en: {
|
|
13
|
+
colors: {
|
|
14
|
+
w: "w", b: "b"
|
|
15
|
+
},
|
|
16
|
+
colors_long: {
|
|
17
|
+
w: "White", b: "Black"
|
|
18
|
+
},
|
|
19
|
+
pieces: {
|
|
20
|
+
p: "p", n: "n", b: "b", r: "r", q: "q", k: "k"
|
|
21
|
+
},
|
|
22
|
+
pieces_long: {
|
|
23
|
+
p: "Pawn", n: "Knight", b: "Bishop", r: "Rook", q: "Queen", k: "King"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
de: {
|
|
27
|
+
colors: {
|
|
28
|
+
w: "w", b: "s"
|
|
29
|
+
},
|
|
30
|
+
colors_long: {
|
|
31
|
+
w: "Weiß", b: "Schwarz"
|
|
32
|
+
},
|
|
33
|
+
pieces: {
|
|
34
|
+
p: "b", n: "s", b: "l", r: "t", q: "d", k: "k"
|
|
35
|
+
},
|
|
36
|
+
pieces_long: {
|
|
37
|
+
p: "Bauer", n: "Springer", b: "Läufer", r: "Turm", q: "Dame", k: "König"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
11
42
|
export const SQUARE_COORDINATES = [
|
|
12
43
|
"a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
|
|
13
44
|
"a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author and copyright: Stefan Haack (https://shaack.com)
|
|
3
|
+
* Repository: https://github.com/shaack/cm-chessboard
|
|
4
|
+
* License: MIT, see file 'LICENSE'
|
|
5
|
+
*/
|
|
6
|
+
import {ChessboardView} from "./ChessboardView.js"
|
|
7
|
+
import {COLOR} from "./Chessboard.js"
|
|
8
|
+
import {piecesTranslations} from "./ChessboardView.js"
|
|
9
|
+
|
|
10
|
+
let count = 0
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const hlTranslations = {
|
|
14
|
+
en: {
|
|
15
|
+
pieces_lists: "Pieces lists",
|
|
16
|
+
board_as_table: "Chessboard as table"
|
|
17
|
+
},
|
|
18
|
+
de: {
|
|
19
|
+
pieces_lists: "Figurenlisten",
|
|
20
|
+
board_as_table: "Schachbrett als Tabelle"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ChessboardViewAccessible extends ChessboardView {
|
|
25
|
+
|
|
26
|
+
constructor(chessboard, callbackAfterCreation) {
|
|
27
|
+
super(chessboard, callbackAfterCreation)
|
|
28
|
+
this.lang = document.documentElement.getAttribute("lang")
|
|
29
|
+
if (this.lang !== "de" && this.lang !== "en") {
|
|
30
|
+
this.lang = "en"
|
|
31
|
+
}
|
|
32
|
+
this.translations = piecesTranslations
|
|
33
|
+
this.t = this.translations[this.lang]
|
|
34
|
+
this.th = hlTranslations[this.lang]
|
|
35
|
+
this.piecesListContainer = this.createElement(`<div class="cm-chessboard-content visually-hidden"><h3>${this.th.pieces_lists}</h3><div class="list"></div></div>`)
|
|
36
|
+
this.piecesList = this.piecesListContainer.querySelector(".list")
|
|
37
|
+
this.chessboard.element.appendChild(this.piecesListContainer)
|
|
38
|
+
this.boardAsTableContainer = this.createElement(`<div class="cm-chessboard-content visually-hidden"><h3>${this.th.board_as_table}</h3><div class="table"></div></div>`)
|
|
39
|
+
this.boardAsTable = this.boardAsTableContainer.querySelector(".table")
|
|
40
|
+
this.chessboard.element.appendChild(this.boardAsTableContainer)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
drawPieces(squares = this.chessboard.state.squares) {
|
|
44
|
+
super.drawPieces(squares)
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this.redrawPiecesLists()
|
|
47
|
+
this.redrawBoardAsTable()
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
redrawPiecesLists() {
|
|
52
|
+
const pieces = this.chessboard.state.getPieces()
|
|
53
|
+
let listW = ""
|
|
54
|
+
let listB = ""
|
|
55
|
+
for (const piece of pieces) {
|
|
56
|
+
if (piece.color === "w") {
|
|
57
|
+
listW += `<li class="list-inline-item">${this.t.pieces_long[piece.name]} ${piece.position}</li>`
|
|
58
|
+
} else {
|
|
59
|
+
listB += `<li class="list-inline-item">${this.t.pieces_long[piece.name]} ${piece.position}</li>`
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
count++
|
|
63
|
+
this.piecesList.innerHTML = `
|
|
64
|
+
<h4 id="white-${count}">${this.t.colors_long.w}</h4>
|
|
65
|
+
<ul aria-labelledby="white-${count}" class="list-inline">${listW}</ul>
|
|
66
|
+
<h4 id="black-${count}">${this.t.colors_long.b}</h4>
|
|
67
|
+
<ul aria-labelledby="black-${count}" class="list-inline">${listB}</ul>`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
redrawBoardAsTable() {
|
|
71
|
+
const squares = this.chessboard.state.squares.slice()
|
|
72
|
+
const ranks = ["a", "b", "c", "d", "e", "f", "g", "h"]
|
|
73
|
+
const files = ["1", "2", "3", "4", "5", "6", "7", "8"]
|
|
74
|
+
if (this.chessboard.state.orientation === COLOR.black) {
|
|
75
|
+
ranks.reverse()
|
|
76
|
+
files.reverse()
|
|
77
|
+
squares.reverse()
|
|
78
|
+
}
|
|
79
|
+
let html = `<table><caption>${this.t.board_as_table}</caption><tr><th></th>`
|
|
80
|
+
for (const rank of ranks) {
|
|
81
|
+
html += `<th scope='col'>${rank}</th>`
|
|
82
|
+
}
|
|
83
|
+
html += "</tr>"
|
|
84
|
+
for (let x = 7; x >= 0; x--) {
|
|
85
|
+
html += `<tr><th scope="row">${files[7 - x]}</th>`
|
|
86
|
+
for (let y = 0; y < 8; y++) {
|
|
87
|
+
const pieceCode = squares[y % 8 + x * 8]
|
|
88
|
+
let color, name
|
|
89
|
+
if(pieceCode) {
|
|
90
|
+
color = pieceCode.charAt(0)
|
|
91
|
+
name = pieceCode.charAt(1)
|
|
92
|
+
html += `<td>${this.t.pieces_long[name]} ${this.t.colors_long[color]}</td>`
|
|
93
|
+
} else {
|
|
94
|
+
html += `<td></td>`
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
html += "</tr>"
|
|
98
|
+
}
|
|
99
|
+
html += "</table>"
|
|
100
|
+
this.boardAsTable.innerHTML = html
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
createElement(html) {
|
|
104
|
+
const template = document.createElement('template')
|
|
105
|
+
template.innerHTML = html.trim()
|
|
106
|
+
return template.content.firstChild
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author and copyright: Stefan Haack (https://shaack.com)
|
|
3
|
+
* Repository: https://github.com/shaack/cm-chessboard
|
|
4
|
+
* License: MIT, see file 'LICENSE'
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
+
import {ChessboardState} from "../src/cm-chessboard/ChessboardState.js"
|
|
9
|
+
|
|
10
|
+
describe("TestState", () => {
|
|
11
|
+
it("should convert square to index", () => {
|
|
12
|
+
const state = new ChessboardState()
|
|
13
|
+
assert.equals(state.squareToIndex("a1"), 0)
|
|
14
|
+
assert.equals(state.squareToIndex("h1"), 7)
|
|
15
|
+
assert.equals(state.squareToIndex("a8"), 56)
|
|
16
|
+
assert.equals(state.squareToIndex("g5"), 38)
|
|
17
|
+
assert.equals(state.squareToIndex("h8"), 63)
|
|
18
|
+
})
|
|
19
|
+
it("should convert index to square", () => {
|
|
20
|
+
const state = new ChessboardState()
|
|
21
|
+
assert.equals(state.indexToSquare(0), "a1")
|
|
22
|
+
assert.equals(state.indexToSquare(7), "h1")
|
|
23
|
+
assert.equals(state.indexToSquare(56), "a8")
|
|
24
|
+
assert.equals(state.indexToSquare(38), "g5")
|
|
25
|
+
assert.equals(state.indexToSquare(63), "h8")
|
|
26
|
+
})
|
|
27
|
+
})
|