-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.html
72 lines (71 loc) · 3.29 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
<!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><i>A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.</i></p>
<p>cm-chessboard is the chessboard of <a href="https://www.chessmail.de">chessmail</a> and is used every day by thousands of players.
It works, it is cool and it is easy to use. 👍</p>
<p><a href="https://github.com/shaack/cm-chessboard">Repository and documentation on GitHub</a></p>
<div>
<h2>Examples</h2>
<ul>
<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/extensions/markers-extension.html">Context input, mark squares and detect clicks on fields</a></li>
<li><a href="examples/different-styles.html">Different styles and piece sets</a> 🎨</li>
<li><a href="examples/pointer-events.html">Pointer events on squares</a> 🆕</li>
<li><a href="examples/destroy-many-boards.html">Stress test, 5000 boards created and destroyed</a> 🤓 👍</li>
</ul>
<h3>Examples using the cm-chessboard extensions</h3>
<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>
<li><a href="examples/extensions/html-layer-extension.html">HTML Layer extension</a></li>
<li><a href="examples/extensions/promotion-dialog-extension.html">PromotionDialog extension</a></li>
<li><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>