-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathindex.html
More file actions
84 lines (81 loc) · 3.68 KB
/
index.html
File metadata and controls
84 lines (81 loc) · 3.68 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>cm-chessboard</title>
<link rel="stylesheet" href="assets/chessboard.css"/>
<link rel="stylesheet" href="examples/styles/examples.css"/>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0"/>
</head>
<body>
<h1>cm-chessboard</h1>
<p>A JavaScript chessboard which is</p>
<ul>
<li>lightweight and ES6 module based</li>
<li>responsive and SVG rendered</li>
<li><b>without dependencies</b> 🥳</li>
<li>tested and it works</li>
</ul>
<p>cm-chessboard is the chessboard of <b><a href="https://www.chessmail.de">chessmail.de</a></b> and is used every day by <b>thousands of players</b>.</p>
<p class="text-info">cm-chessboard is easy to use: <a href="https://github.com/shaack/cm-chessboard">Repository and documentation on GitHub</a></p>
<div>
<h2>Examples</h2>
<ul>
<li><a href="examples/extensions/right-click-annotator.html">Draw Arrows and Markers with right-click</a> 🆕🔥</li>
<li><a href="examples/simple-boards.html">Simple chessboards, view only</a></li>
<li><a href="examples/responsive-board.html">Responsive chessboard</a></li>
<li><a href="examples/enable-input.html">Input enabled without validation</a></li>
<li><a href="examples/validate-moves.html">Input enabled, with move validation and promotion dialog</a> 🔥</li>
<li><a href="examples/pieces-animation.html">Set different positions, with animation</a></li>
<li><a href="examples/different-styles.html">Different styles and piece sets</a> 🎨</li>
<li><a href="examples/destroy-many-boards.html">Stress test, 5000 boards created and destroyed</a> 🤓 👍</li>
</ul>
<h3>Examples for the shipped cm-chessboard extensions</h3>
<ul>
<li>
Draw arrows and markers on the board with
<a href="examples/extensions/right-click-annotator.html">RightClickAnnotator extension</a> 🆕🔥
<ul>
<li><a href="examples/extensions/markers-extension.html">Markers extension</a></li>
<li><a href="examples/extensions/arrows-extension.html">Arrows extension</a></li>
</ul>
</li>
<li>Draw HTML over the board with the <a href="examples/extensions/html-layer-extension.html">HTML Layer extension</a></li>
<li>Allow displaying a promotion dialog with the <a href="examples/extensions/promotion-dialog-extension.html">PromotionDialog extension</a></li>
<li>Make the board accessible, add screen-reader support with the <a href="examples/extensions/accessibility-extension.html">Accessibility extension</a></li>
</ul>
</div>
<h2>Chessboard</h2>
<div class="board" id="board"></div>
<script type="module">
import {Chessboard} from "./src/Chessboard.js"
import {FEN} from "./src/model/Position.js"
import {Chess} from "https://cdn.jsdelivr.net/npm/chess.mjs@1/src/chess.mjs/Chess.js"
const chess = new Chess()
const board = new Chessboard(document.getElementById("board"), {
position: FEN.start
})
const interval = setInterval(() => {
makeRandomMove()
board.setPosition(chess.fen(), true)
}, 500)
function makeRandomMove() {
if(chess.game_over()) {
chess.reset()
}
const possibleMoves = chess.moves()
if (possibleMoves.length === 0) {
clearInterval(interval)
return
}
const randomIndex = Math.floor(Math.random() * possibleMoves.length)
chess.move(possibleMoves[randomIndex])
}
</script>
<div class="clearfix"></div>
<h2>Tests</h2>
<ul>
<li><a href="test/">Run the unit tests</a></li>
</ul>
</body>
</html>