├── .editorconfig ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── data ├── docs.json └── releases.json ├── examples ├── 1000-empty-board.example ├── 1001-start-position.example ├── 1002-fen.example ├── 1003-position-object.example ├── 1004-multiple-boards.example ├── 2000-config-position.example ├── 2001-config-orientation.example ├── 2002-config-notation.example ├── 2003-draggable-snapback.example ├── 2004-piece-theme-string.example ├── 2005-animation-speed.example ├── 2006-spare-pieces.example ├── 2030-piece-theme-function.example ├── 2044-position-fen.example ├── 2063-position-object.example ├── 2082-draggable-trash.example ├── 3000-get-position.example ├── 3001-set-position.example ├── 3002-set-position-instant.example ├── 3003-clear.example ├── 3004-move-pieces.example ├── 3005-orientation.example ├── 3006-destroy.example ├── 3007-resize.example ├── 4000-onchange.example ├── 4001-ondragstart.example ├── 4002-ondragstart-prevent-drag.example ├── 4003-ondragmove.example ├── 4004-ondrop.example ├── 4005-ondrop-snapback.example ├── 4006-ondrop-trash.example ├── 4011-onsnapbackend.example ├── 4012-onmoveend.example ├── 5000-legal-moves.example ├── 5001-play-random-computer.example ├── 5002-random-vs-random.example ├── 5003-highlight-legal-moves.example ├── 5004-piece-highlight1.example └── 5005-piece-highlight2.example ├── lib ├── chessboard.css └── chessboard.js ├── package.json ├── scripts ├── build.js ├── rename.js └── website.js ├── templates ├── _footer.mustache ├── _head.mustache ├── _header.mustache ├── docs.mustache ├── download.mustache ├── examples.mustache ├── homepage.mustache ├── license.mustache └── single-example.mustache ├── website ├── .htaccess ├── 192.png ├── 512.png ├── apple-touch-icon.png ├── css │ └── website2.css ├── favicon.ico ├── icon.svg ├── img │ ├── board-background.png │ ├── chesspieces │ │ ├── alpha │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ │ ├── uscf │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ │ └── wikipedia │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bK.svg │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ ├── favicon.ico │ ├── link.svg │ └── satinweave.png ├── js │ ├── chess-0.10.2.min.js │ ├── examples.js │ ├── jquery-3.4.1.min.js │ ├── jquery.color-2.1.2.min.js │ └── prettify.min.js ├── manifest.webmanifest └── releases │ ├── 0.1.0 │ ├── LICENSE.txt │ ├── chessboard-0.1.0.zip │ ├── css │ │ ├── chessboard-0.1.0.css │ │ └── chessboard-0.1.0.min.css │ ├── img │ │ └── chesspieces │ │ │ └── wikipedia │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ └── js │ │ ├── chessboard-0.1.0.js │ │ └── chessboard-0.1.0.min.js │ ├── 0.2.0 │ ├── LICENSE.txt │ ├── chessboardjs-0.2.0.zip │ ├── css │ │ ├── chessboard-0.2.0.css │ │ └── chessboard-0.2.0.min.css │ ├── img │ │ └── chesspieces │ │ │ └── wikipedia │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ └── js │ │ ├── chessboard-0.2.0.js │ │ └── chessboard-0.2.0.min.js │ ├── 0.3.0 │ ├── LICENSE.txt │ ├── chessboardjs-0.3.0.zip │ ├── css │ │ ├── chessboard-0.3.0.css │ │ └── chessboard-0.3.0.min.css │ ├── img │ │ └── chesspieces │ │ │ └── wikipedia │ │ │ ├── bB.png │ │ │ ├── bK.png │ │ │ ├── bN.png │ │ │ ├── bP.png │ │ │ ├── bQ.png │ │ │ ├── bR.png │ │ │ ├── wB.png │ │ │ ├── wK.png │ │ │ ├── wN.png │ │ │ ├── wP.png │ │ │ ├── wQ.png │ │ │ └── wR.png │ └── js │ │ ├── chessboard-0.3.0.js │ │ └── chessboard-0.3.0.min.js │ └── chessboardjs-1.0.0.zip └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs. 2 | # More information at http://EditorConfig.org 3 | 4 | # Do not check for any .editorconfig files above this directory 5 | root = true 6 | 7 | # All files 8 | [*] 9 | charset = utf-8 10 | end_of_line = lf 11 | indent_size = 2 12 | indent_style = space 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | 16 | [*.{html,mustache}] 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # git diff files 2 | *.diff 3 | 4 | dist/ 5 | node_modules/ 6 | 7 | website/*.html 8 | website/css/chessboard.css 9 | website/js/chessboard.js 10 | website/examples/ 11 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | data/ 2 | examples/ 3 | scripts/ 4 | templates/ 5 | website/ 6 | .editorconfig 7 | changes.diff 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # chessboard.js Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## [1.0.0] - 2019-06-11 6 | - Orientation methods now return current orientation. [Issue #64] 7 | - Drop support for IE8 8 | - Do not check for `window.JSON` (Error #1004) 9 | - Rename `ChessBoard` to `Chessboard` (`ChessBoard` is still supported, however) 10 | - id query selectors are now supported as the first argument to `Chessboard()` 11 | - Remove Error #1002 12 | - Format code according to [StandardJS] 13 | - Bump minimum jQuery version to 1.8.3 14 | - Throttle piece drag functions 15 | 16 | ## [0.3.0] - 2013-08-10 17 | - Added `appearSpeed` animation config property 18 | - Added `onSnapbackEnd` event 19 | - Added `onMoveEnd` event 20 | 21 | ## [0.2.0] - 2013-08-05 22 | - Added `onMouseoverSquare` and `onMouseoutSquare` events 23 | - Added `onSnapEnd` event 24 | - Added square code as CSS class on the squares 25 | - Added [chess.js] integration examples 26 | 27 | ## [0.1.0] - 2013-05-21 28 | - Initial release 29 | 30 | [chess.js]:https://github.com/jhlywa/chess.js 31 | [Issue #64]:https://github.com/oakmac/chessboardjs/issues/64 32 | [StandardJS]:https://standardjs.com/ 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2019 Chris Oakman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chessboard.js [![npm](https://img.shields.io/npm/v/@chrisoakman/chessboardjs.svg)](https://www.npmjs.com/package/@chrisoakman/chessboardjs) [![MIT License](https://img.shields.io/npm/l/@chrisoakman/chessboardjs)](https://github.com/oakmac/chessboardjs/blob/master/LICENSE.md) 2 | 3 | > **NOTE:** chessboard.js can be found on npm as `@chrisoakman/chessboardjs` 4 | 5 | chessboard.js is a JavaScript chessboard component. It depends on [jQuery] v3.4.1 (or higher). 6 | 7 | Please see [chessboardjs.com] for documentation and examples. 8 | 9 | ## Project Status (Dec 2022) 10 | 11 | I am currently focusing my efforts on [chessboard2]. 12 | 13 | [chessboard2]:https://github.com/oakmac/chessboard2 14 | 15 | ## What is chessboard.js? 16 | 17 | chessboard.js is a standalone JavaScript Chess Board. It is designed to be "just 18 | a board" and expose a powerful API so that it can be used in different ways. 19 | Here's a non-exhaustive list of things you can do with chessboard.js: 20 | 21 | - Use chessboard.js to show game positions alongside your expert commentary. 22 | - Use chessboard.js to have a tactics website where users have to guess the best 23 | move. 24 | - Integrate chessboard.js and [chess.js] with a PGN database and allow people to 25 | search and playback games (see [Example 5000]) 26 | - Build a chess server and have users play their games out using the 27 | chessboard.js board. 28 | 29 | chessboard.js is flexible enough to handle any of these situations with relative 30 | ease. 31 | 32 | ## What can chessboard.js **not** do? 33 | 34 | The scope of chessboard.js is limited to "just a board." This is intentional and 35 | makes chessboard.js flexible for building a variety of chess-related 36 | applications. 37 | 38 | To be specific, chessboard.js does not understand anything about how the game of 39 | chess is played: how a knight moves, whose turn is it, is White in check?, etc. 40 | 41 | Fortunately, the [chess.js] library deals with exactly this sort of problem and 42 | plays nicely with chessboard.js's flexible API. Some examples of chessboard.js 43 | combined with chess.js: [Example 5000], [Example 5001], [Example 5002] 44 | 45 | ## Docs and Examples 46 | 47 | - Docs - 48 | - Examples - 49 | 50 | ## Developer Tools 51 | 52 | ```sh 53 | # create a build in the build/ directory 54 | npm run build 55 | 56 | # re-build the website 57 | npm run website 58 | ``` 59 | 60 | ## License 61 | 62 | [MIT License](LICENSE.md) 63 | 64 | [jQuery]:https://jquery.com/ 65 | [chessboardjs.com]:https://chessboardjs.com 66 | [chess.js]:https://github.com/jhlywa/chess.js 67 | [Example 5000]:https://chessboardjs.com/examples#5000 68 | [Example 5001]:https://chessboardjs.com/examples#5001 69 | [Example 5002]:https://chessboardjs.com/examples#5002 70 | -------------------------------------------------------------------------------- /data/releases.json: -------------------------------------------------------------------------------- 1 | [ 2 | "-----------------------------------------------------------------", 3 | { 4 | "released":false, 5 | "version":"0.3.1", 6 | "date":"10 Aug 2013", 7 | "changes":[ 8 | "Orientation methods now return current orientation (GitHub Issue #64)" 9 | ], 10 | "files":[ 11 | { "name":"chessboardjs-0.3.1.zip", "size":"44.6 KB" } 12 | ] 13 | }, 14 | "-----------------------------------------------------------------", 15 | { 16 | "version":"0.3.0", 17 | "date":"10 Aug 2013", 18 | "changes":[ 19 | "Added appearSpeed animation config", 20 | "Added onSnapbackEnd event", 21 | "Added onMoveEnd event" 22 | ], 23 | "files":[ 24 | { "name":"chessboardjs-0.3.0.zip", "size":"44.6 KB" } 25 | ] 26 | }, 27 | "-----------------------------------------------------------------", 28 | { 29 | "version":"0.2.0", 30 | "date":"05 Aug 2013", 31 | "changes":[ 32 | "Added onMouseoverSquare and onMouseoutSquare events", 33 | "Added onSnapEnd event", 34 | "Added square code as CSS class on the squares", 35 | "chess.js integration examples" 36 | ], 37 | "files":[ 38 | { "name":"chessboardjs-0.2.0.zip", "size":"44.6 KB" } 39 | ] 40 | }, 41 | "-----------------------------------------------------------------", 42 | { 43 | "version":"0.1.0", 44 | "date":"21 Jul 2013", 45 | "changes":[ 46 | "Initial release" 47 | ], 48 | "files":[ 49 | { "name":"chessboard-0.1.0.zip", "size":"44.0 KB" } 50 | ] 51 | }, 52 | "-----------------------------------------------------------------" 53 | ] -------------------------------------------------------------------------------- /examples/1000-empty-board.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 1000 3 | 4 | ===== Name 5 | Empty Board 6 | 7 | ===== Description 8 | Chessboard.js initializes to an empty board with no second argument. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var board = Chessboard('myBoard') 15 | -------------------------------------------------------------------------------- /examples/1001-start-position.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 1001 3 | 4 | ===== Name 5 | Start Position 6 | 7 | ===== Description 8 | Pass 'start' as the second argument to initialize 9 | the board to the start position. 10 | 11 | ===== HTML 12 |
13 | 14 | ===== JS 15 | var board = Chessboard('myBoard', 'start') 16 | -------------------------------------------------------------------------------- /examples/1002-fen.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 1002 3 | 4 | ===== Name 5 | FEN String 6 | 7 | ===== Description 8 | Pass a FEN String as the second argument to 9 | initialize the board to a specific position. 10 | 11 | ===== HTML 12 |
13 | 14 | ===== JS 15 | var ruyLopez = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R' 16 | var board = Chessboard('myBoard', ruyLopez) 17 | -------------------------------------------------------------------------------- /examples/1003-position-object.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 1003 3 | 4 | ===== Name 5 | Position Object 6 | 7 | ===== Description 8 | Pass a Position Object as the second argument to initialize the board to a specific position. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var position = { 15 | d6: 'bK', 16 | d4: 'wP', 17 | e4: 'wK' 18 | } 19 | var board = Chessboard('myBoard', position) 20 | -------------------------------------------------------------------------------- /examples/1004-multiple-boards.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 1004 3 | 4 | ===== Name 5 | Multiple Boards 6 | 7 | ===== Description 8 | You can have multiple boards on the same page. 9 | 10 | ===== CSS 11 | .small-board { 12 | display: inline-block; 13 | margin-right: 5px; 14 | width: 200px; 15 | } 16 | 17 | ===== HTML 18 |
19 |
20 |
21 | 22 | ===== JS 23 | var board1 = Chessboard('board1', { 24 | position: 'start', 25 | showNotation: false 26 | }) 27 | 28 | var board2 = Chessboard('board2', { 29 | position: 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R', 30 | showNotation: false 31 | }) 32 | 33 | var board3 = Chessboard('board3', { 34 | position: 'r1k4r/p2nb1p1/2b4p/1p1n1p2/2PP4/3Q1NB1/1P3PPP/R5K1', 35 | showNotation: false 36 | }) 37 | -------------------------------------------------------------------------------- /examples/2000-config-position.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2000 3 | 4 | ===== Name 5 | Start Position 6 | 7 | ===== Description 8 | Set the position property to 'start' to initialize the board to the start position. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | position: 'start' 16 | } 17 | var board = Chessboard('myBoard', config) 18 | -------------------------------------------------------------------------------- /examples/2001-config-orientation.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2001 3 | 4 | ===== Name 5 | Orientation 6 | 7 | ===== Description 8 | Use the orientation property to set board orientation. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | orientation: 'black', 16 | position: 'start' 17 | } 18 | var board = Chessboard('myBoard', config) 19 | -------------------------------------------------------------------------------- /examples/2002-config-notation.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2002 3 | 4 | ===== Name 5 | Notation 6 | 7 | ===== Description 8 | Use the showNotation property to turn board notation on or off. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | showNotation: false, 16 | position: 'start' 17 | } 18 | var board = Chessboard('myBoard', config) 19 | -------------------------------------------------------------------------------- /examples/2003-draggable-snapback.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2003 3 | 4 | ===== Name 5 | Draggable Snapback 6 | 7 | ===== Description 8 | Set draggable to true to allow drag and drop of pieces. Pieces will return to their original square when dropped off the board (ie: the default for dropOffBoard is 'snapback'). 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | draggable: true, 16 | dropOffBoard: 'snapback', // this is the default 17 | position: 'start' 18 | } 19 | var board = Chessboard('myBoard', config) 20 | -------------------------------------------------------------------------------- /examples/2004-piece-theme-string.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2004 3 | 4 | ===== Name 5 | Piece Theme String 6 | 7 | ===== Description 8 | Use the pieceTheme property to set the source of piece images. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | pieceTheme: 'img/chesspieces/alpha/{piece}.png', 16 | position: 'start' 17 | } 18 | var board = Chessboard('myBoard', config) 19 | -------------------------------------------------------------------------------- /examples/2005-animation-speed.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2005 3 | 4 | ===== Name 5 | Animation Speed 6 | 7 | ===== Description 8 | You can control animation speeds with the moveSpeed, snapbackSpeed, snapSpeed, and trashSpeed properties. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | ===== JS 16 | var board = Chessboard('myBoard', { 17 | draggable: true, 18 | moveSpeed: 'slow', 19 | snapbackSpeed: 500, 20 | snapSpeed: 100, 21 | position: 'start' 22 | }) 23 | 24 | $('#ruyLopezBtn').on('click', function () { 25 | board.position('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R') 26 | }) 27 | $('#startBtn').on('click', board.start) 28 | -------------------------------------------------------------------------------- /examples/2006-spare-pieces.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2006 3 | 4 | ===== Name 5 | Spare Pieces 6 | 7 | ===== Description 8 | Set sparePieces to true to show spare pieces that can be dropped onto the board. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | ===== JS 16 | var board = Chessboard('myBoard', { 17 | draggable: true, 18 | dropOffBoard: 'trash', 19 | sparePieces: true 20 | }) 21 | 22 | $('#startBtn').on('click', board.start) 23 | $('#clearBtn').on('click', board.clear) 24 | -------------------------------------------------------------------------------- /examples/2030-piece-theme-function.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2030 3 | 4 | ===== Name 5 | Piece Theme Function 6 | 7 | ===== Description 8 | pieceTheme can be a function. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | function pieceTheme (piece) { 15 | // wikipedia theme for white pieces 16 | if (piece.search(/w/) !== -1) { 17 | return 'img/chesspieces/wikipedia/' + piece + '.png' 18 | } 19 | 20 | // alpha theme for black pieces 21 | return 'img/chesspieces/alpha/' + piece + '.png' 22 | } 23 | 24 | var config = { 25 | pieceTheme: pieceTheme, 26 | position: 'start' 27 | } 28 | var board = Chessboard('myBoard', config) 29 | -------------------------------------------------------------------------------- /examples/2044-position-fen.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2044 3 | 4 | ===== Name 5 | Position FEN 6 | 7 | ===== Description 8 | You can set the position property to a FEN string. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | position: 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R' 16 | } 17 | var board = Chessboard('myBoard', config) 18 | -------------------------------------------------------------------------------- /examples/2063-position-object.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2063 3 | 4 | ===== Name 5 | Position Object 6 | 7 | ===== Description 8 | You can set the position property with a Position Object. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | position: { 16 | d4: 'wP', 17 | d6: 'bK', 18 | e4: 'wK' 19 | } 20 | }; 21 | var board = Chessboard('myBoard', config) 22 | -------------------------------------------------------------------------------- /examples/2082-draggable-trash.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 2082 3 | 4 | ===== Name 5 | Draggable Trash 6 | 7 | ===== Description 8 | Set dropOffBoard to 'trash' to remove pieces when they are dropped outside the board. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | var config = { 15 | draggable: true, 16 | dropOffBoard: 'trash', 17 | position: 'start' 18 | } 19 | var board = Chessboard('myBoard', config) 20 | -------------------------------------------------------------------------------- /examples/3000-get-position.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3000 3 | 4 | ===== Name 5 | Get Position 6 | 7 | ===== Description 8 | Use the position and fen methods to retrieve the current position of the board. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | ===== JS 15 | var config = { 16 | draggable: true, 17 | position: 'start' 18 | } 19 | var board = Chessboard('myBoard', config) 20 | 21 | function clickShowPositionBtn () { 22 | console.log('Current position as an Object:') 23 | console.log(board.position()) 24 | 25 | console.log('Current position as a FEN string:') 26 | console.log(board.fen()) 27 | } 28 | 29 | $('#showPositionBtn').on('click', clickShowPositionBtn) 30 | -------------------------------------------------------------------------------- /examples/3001-set-position.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3001 3 | 4 | ===== Name 5 | Set Position 6 | 7 | ===== Description 8 | Use the start and position methods to set the board position. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | 16 | ===== JS 17 | var board = Chessboard('myBoard') 18 | 19 | $('#setRuyLopezBtn').on('click', function () { 20 | board.position('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R') 21 | }) 22 | 23 | $('#setStartBtn').on('click', board.start) 24 | 25 | $('#setRookCheckmateBtn').on('click', function () { 26 | board.position({ 27 | a4: 'bK', 28 | c4: 'wK', 29 | a7: 'wR' 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /examples/3002-set-position-instant.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3002 3 | 4 | ===== Name 5 | Set Position Instantly 6 | 7 | ===== Description 8 | Pass false as the second argument to the start and position methods to set the board position instantly. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | 16 | ===== JS 17 | var board = Chessboard('myBoard') 18 | 19 | $('#setRuyLopezBtn').on('click', function () { 20 | var ruyLopez = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R' 21 | board.position(ruyLopez, false) 22 | }) 23 | 24 | $('#setStartBtn').on('click', function () { 25 | board.start(false) 26 | }) 27 | 28 | $('#setRookCheckmateBtn').on('click', function () { 29 | var rookCheckmate = { 30 | a4: 'bK', 31 | c4: 'wK', 32 | a7: 'wR' 33 | } 34 | board.position(rookCheckmate, false) 35 | }) 36 | -------------------------------------------------------------------------------- /examples/3003-clear.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3003 3 | 4 | ===== Name 5 | Clear Board 6 | 7 | ===== Description 8 | Use the clear method to remove all the pieces from the board. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | 16 | ===== JS 17 | var board = Chessboard('myBoard', 'start') 18 | 19 | $('#clearBoardBtn').on('click', board.clear) 20 | 21 | $('#startPositionBtn').on('click', board.start) 22 | 23 | $('#clearBoardInstantBtn').on('click', function () { 24 | board.clear(false) 25 | }) 26 | -------------------------------------------------------------------------------- /examples/3004-move-pieces.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3004 3 | 4 | ===== Name 5 | Move Pieces 6 | 7 | ===== Description 8 | Use the move method to make one or more moves on the board. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | 16 | ===== JS 17 | var board = Chessboard('myBoard', 'start') 18 | 19 | $('#move1Btn').on('click', function () { 20 | board.move('e2-e4') 21 | }) 22 | 23 | $('#move2Btn').on('click', function () { 24 | board.move('d2-d4', 'g8-f6') 25 | }) 26 | 27 | $('#startPositionBtn').on('click', board.start) 28 | -------------------------------------------------------------------------------- /examples/3005-orientation.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3005 3 | 4 | ===== Name 5 | Orientation 6 | 7 | ===== Description 8 | Use the orientation method to retrieve and set the orientation. Use the flip method to flip orientation. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 |
15 | 16 | 17 | 18 | ===== JS 19 | var ruyLopez = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R' 20 | var board = Chessboard('myBoard', ruyLopez) 21 | 22 | $('#showOrientationBtn').on('click', function () { 23 | console.log('Board orientation is: ' + board.orientation()) 24 | }) 25 | 26 | $('#flipOrientationBtn').on('click', board.flip) 27 | 28 | $('#whiteOrientationBtn').on('click', function () { 29 | board.orientation('white') 30 | }) 31 | 32 | $('#blackOrientationBtn').on('click', function () { 33 | board.orientation('black') 34 | }) 35 | -------------------------------------------------------------------------------- /examples/3006-destroy.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3006 3 | 4 | ===== Name 5 | Destroy Board 6 | 7 | ===== Description 8 | Use the destroy method to kill the board and remove it from the DOM. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | ===== JS 15 | var board = Chessboard('myBoard', 'start') 16 | 17 | $('#destroyBtn').on('click', board.destroy) 18 | -------------------------------------------------------------------------------- /examples/3007-resize.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 3007 3 | 4 | ===== Name 5 | Resize 6 | 7 | ===== Description 8 | Use the resize method to recalculate and redraw the board based on the size of it's parent element. See the full effect of this example in a new window. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // NOTE: click "View example in new window." to see the full effect of this example 15 | var board = Chessboard('myBoard', 'start') 16 | $(window).resize(board.resize) 17 | -------------------------------------------------------------------------------- /examples/4000-onchange.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4000 3 | 4 | ===== Name 5 | onChange 6 | 7 | ===== Description 8 | The onChange event fires when the board position changes. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | ===== JS 16 | function onChange (oldPos, newPos) { 17 | console.log('Position changed:') 18 | console.log('Old position: ' + Chessboard.objToFen(oldPos)) 19 | console.log('New position: ' + Chessboard.objToFen(newPos)) 20 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 21 | } 22 | 23 | var config = { 24 | draggable: true, 25 | position: 'start', 26 | onChange: onChange 27 | } 28 | var board = Chessboard('myBoard', config) 29 | 30 | $('#ruyLopezBtn').on('click', function () { 31 | var ruyLopez = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R' 32 | board.position(ruyLopez) 33 | }) 34 | 35 | $('#startPositionBtn').on('click', board.start) 36 | -------------------------------------------------------------------------------- /examples/4001-ondragstart.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4001 3 | 4 | ===== Name 5 | onDragStart 6 | 7 | ===== Description 8 | The onDragStart event fires every time a piece is picked up. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | function onDragStart (source, piece, position, orientation) { 15 | console.log('Drag started:') 16 | console.log('Source: ' + source) 17 | console.log('Piece: ' + piece) 18 | console.log('Position: ' + Chessboard.objToFen(position)) 19 | console.log('Orientation: ' + orientation) 20 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 21 | } 22 | 23 | var config = { 24 | draggable: true, 25 | position: 'start', 26 | onDragStart: onDragStart, 27 | sparePieces: true 28 | } 29 | var board = Chessboard('myBoard', config) 30 | -------------------------------------------------------------------------------- /examples/4002-ondragstart-prevent-drag.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4002 3 | 4 | ===== Name 5 | onDragStart Prevent Drag 6 | 7 | ===== Description 8 | Prevent the drag action by returning false from the onDragStart function. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | ===== JS 15 | // only allow pieces to be dragged when the board is oriented 16 | // in their direction 17 | function onDragStart (source, piece, position, orientation) { 18 | if ((orientation === 'white' && piece.search(/^w/) === -1) || 19 | (orientation === 'black' && piece.search(/^b/) === -1)) { 20 | return false 21 | } 22 | } 23 | 24 | var config = { 25 | draggable: true, 26 | position: 'start', 27 | onDragStart: onDragStart 28 | } 29 | var board = Chessboard('myBoard', config) 30 | 31 | $('#flipOrientationBtn').on('click', board.flip) 32 | -------------------------------------------------------------------------------- /examples/4003-ondragmove.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4003 3 | 4 | ===== Name 5 | onDragMove 6 | 7 | ===== Description 8 | The onDragMove event fires every time a piece changes location. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | function onDragMove (newLocation, oldLocation, source, 15 | piece, position, orientation) { 16 | console.log('New location: ' + newLocation) 17 | console.log('Old location: ' + oldLocation) 18 | console.log('Source: ' + source) 19 | console.log('Piece: ' + piece) 20 | console.log('Position: ' + Chessboard.objToFen(position)) 21 | console.log('Orientation: ' + orientation) 22 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 23 | } 24 | 25 | var config = { 26 | draggable: true, 27 | position: 'start', 28 | onDragMove: onDragMove, 29 | sparePieces: true 30 | } 31 | var board = Chessboard('myBoard', config) 32 | -------------------------------------------------------------------------------- /examples/4004-ondrop.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4004 3 | 4 | ===== Name 5 | onDrop 6 | 7 | ===== Description 8 | The onDrop event fires every time a piece is dropped. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | function onDrop (source, target, piece, newPos, oldPos, orientation) { 15 | console.log('Source: ' + source) 16 | console.log('Target: ' + target) 17 | console.log('Piece: ' + piece) 18 | console.log('New position: ' + Chessboard.objToFen(newPos)) 19 | console.log('Old position: ' + Chessboard.objToFen(oldPos)) 20 | console.log('Orientation: ' + orientation) 21 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 22 | } 23 | 24 | var config = { 25 | draggable: true, 26 | position: 'start', 27 | onDrop: onDrop, 28 | sparePieces: true 29 | } 30 | var board = Chessboard('myBoard', config) 31 | -------------------------------------------------------------------------------- /examples/4005-ondrop-snapback.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4005 3 | 4 | ===== Name 5 | onDrop Snapback 6 | 7 | ===== Description 8 | If 'snapback' is returned from the onDrop function, the dragged piece will return to it's source square. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // snapback black pieces when they are dropped 15 | function onDrop (source, target, piece, newPos, oldPos, orientation) { 16 | if (piece.search(/b/) !== -1) { 17 | return 'snapback' 18 | } 19 | } 20 | 21 | var config = { 22 | draggable: true, 23 | position: 'start', 24 | onDrop: onDrop 25 | } 26 | var board = Chessboard('myBoard', config) 27 | -------------------------------------------------------------------------------- /examples/4006-ondrop-trash.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4006 3 | 4 | ===== Name 5 | onDrop Trash 6 | 7 | ===== Description 8 | If 'trash' is returned from the onDrop function, the dragged piece will be removed. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // trash black pieces when they are dropped 15 | function onDrop (source, target, piece, newPos, oldPos, orientation) { 16 | if (piece.search(/b/) !== -1) { 17 | return 'trash' 18 | } 19 | } 20 | 21 | var config = { 22 | draggable: true, 23 | position: 'start', 24 | onDrop: onDrop 25 | } 26 | var board = Chessboard('myBoard', config) 27 | -------------------------------------------------------------------------------- /examples/4011-onsnapbackend.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4011 3 | 4 | ===== Name 5 | onSnapbackEnd 6 | 7 | ===== Description 8 | The onSnapbackEnd event fires after a piece has snapped back to it's original square. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | function onSnapbackEnd (piece, square, position, orientation) { 15 | console.log('Piece: ' + piece) 16 | console.log('Square: ' + square) 17 | console.log('Position: ' + Chessboard.objToFen(position)) 18 | console.log('Orientation: ' + orientation) 19 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 20 | } 21 | 22 | var config = { 23 | draggable: true, 24 | position: 'start', 25 | onSnapbackEnd: onSnapbackEnd 26 | } 27 | var board = Chessboard('myBoard', config) 28 | -------------------------------------------------------------------------------- /examples/4012-onmoveend.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 4012 3 | 4 | ===== Name 5 | onMoveEnd 6 | 7 | ===== Description 8 | The onMoveEnd event fires at the end of animations when the board position changes. 9 | 10 | ===== HTML 11 |
12 | 13 | 14 | 15 | 16 | 17 | ===== JS 18 | function onMoveEnd (oldPos, newPos) { 19 | console.log('Move animation complete:') 20 | console.log('Old position: ' + Chessboard.objToFen(oldPos)) 21 | console.log('New position: ' + Chessboard.objToFen(newPos)) 22 | console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') 23 | } 24 | 25 | var config = { 26 | position: 'start', 27 | onMoveEnd: onMoveEnd 28 | } 29 | var board = Chessboard('myBoard', config) 30 | 31 | $('#ruyLopezBtn').on('click', function () { 32 | board.position('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R') 33 | }) 34 | $('#moveBtn').on('click', function () { 35 | board.move('a2-a4', 'h7-h5') 36 | }) 37 | $('#startBtn').on('click', board.start) 38 | $('#clearBtn').on('click', board.clear) 39 | -------------------------------------------------------------------------------- /examples/5000-legal-moves.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5000 3 | 4 | ===== Name 5 | Only Allow Legal Moves 6 | 7 | ===== Description 8 | You can integrate chessboard.js with the chess.js library to only allow legal moves. 9 | 10 | ===== HTML 11 |
12 | 13 |
14 | 15 |
16 | 17 |
18 | 19 | ===== JS 20 | // NOTE: this example uses the chess.js library: 21 | // https://github.com/jhlywa/chess.js 22 | 23 | var board = null 24 | var game = new Chess() 25 | var $status = $('#status') 26 | var $fen = $('#fen') 27 | var $pgn = $('#pgn') 28 | 29 | function onDragStart (source, piece, position, orientation) { 30 | // do not pick up pieces if the game is over 31 | if (game.game_over()) return false 32 | 33 | // only pick up pieces for the side to move 34 | if ((game.turn() === 'w' && piece.search(/^b/) !== -1) || 35 | (game.turn() === 'b' && piece.search(/^w/) !== -1)) { 36 | return false 37 | } 38 | } 39 | 40 | function onDrop (source, target) { 41 | // see if the move is legal 42 | var move = game.move({ 43 | from: source, 44 | to: target, 45 | promotion: 'q' // NOTE: always promote to a queen for example simplicity 46 | }) 47 | 48 | // illegal move 49 | if (move === null) return 'snapback' 50 | 51 | updateStatus() 52 | } 53 | 54 | // update the board position after the piece snap 55 | // for castling, en passant, pawn promotion 56 | function onSnapEnd () { 57 | board.position(game.fen()) 58 | } 59 | 60 | function updateStatus () { 61 | var status = '' 62 | 63 | var moveColor = 'White' 64 | if (game.turn() === 'b') { 65 | moveColor = 'Black' 66 | } 67 | 68 | // checkmate? 69 | if (game.in_checkmate()) { 70 | status = 'Game over, ' + moveColor + ' is in checkmate.' 71 | } 72 | 73 | // draw? 74 | else if (game.in_draw()) { 75 | status = 'Game over, drawn position' 76 | } 77 | 78 | // game still on 79 | else { 80 | status = moveColor + ' to move' 81 | 82 | // check? 83 | if (game.in_check()) { 84 | status += ', ' + moveColor + ' is in check' 85 | } 86 | } 87 | 88 | $status.html(status) 89 | $fen.html(game.fen()) 90 | $pgn.html(game.pgn()) 91 | } 92 | 93 | var config = { 94 | draggable: true, 95 | position: 'start', 96 | onDragStart: onDragStart, 97 | onDrop: onDrop, 98 | onSnapEnd: onSnapEnd 99 | } 100 | board = Chessboard('myBoard', config) 101 | 102 | updateStatus() 103 | -------------------------------------------------------------------------------- /examples/5001-play-random-computer.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5001 3 | 4 | ===== Name 5 | Play Random Computer 6 | 7 | ===== Description 8 | You can integrate chessboard.js with the chess.js library to play against random moves. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // NOTE: this example uses the chess.js library: 15 | // https://github.com/jhlywa/chess.js 16 | 17 | var board = null 18 | var game = new Chess() 19 | 20 | function onDragStart (source, piece, position, orientation) { 21 | // do not pick up pieces if the game is over 22 | if (game.game_over()) return false 23 | 24 | // only pick up pieces for White 25 | if (piece.search(/^b/) !== -1) return false 26 | } 27 | 28 | function makeRandomMove () { 29 | var possibleMoves = game.moves() 30 | 31 | // game over 32 | if (possibleMoves.length === 0) return 33 | 34 | var randomIdx = Math.floor(Math.random() * possibleMoves.length) 35 | game.move(possibleMoves[randomIdx]) 36 | board.position(game.fen()) 37 | } 38 | 39 | function onDrop (source, target) { 40 | // see if the move is legal 41 | var move = game.move({ 42 | from: source, 43 | to: target, 44 | promotion: 'q' // NOTE: always promote to a queen for example simplicity 45 | }) 46 | 47 | // illegal move 48 | if (move === null) return 'snapback' 49 | 50 | // make random legal move for black 51 | window.setTimeout(makeRandomMove, 250) 52 | } 53 | 54 | // update the board position after the piece snap 55 | // for castling, en passant, pawn promotion 56 | function onSnapEnd () { 57 | board.position(game.fen()) 58 | } 59 | 60 | var config = { 61 | draggable: true, 62 | position: 'start', 63 | onDragStart: onDragStart, 64 | onDrop: onDrop, 65 | onSnapEnd: onSnapEnd 66 | } 67 | board = Chessboard('myBoard', config) 68 | -------------------------------------------------------------------------------- /examples/5002-random-vs-random.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5002 3 | 4 | ===== Name 5 | Random vs Random 6 | 7 | ===== Description 8 | Who will win in this riveting game of Math.random() vs Math.random()? 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // NOTE: this example uses the chess.js library: 15 | // https://github.com/jhlywa/chess.js 16 | 17 | var board = null 18 | var game = new Chess() 19 | 20 | function makeRandomMove () { 21 | var possibleMoves = game.moves() 22 | 23 | // exit if the game is over 24 | if (game.game_over()) return 25 | 26 | var randomIdx = Math.floor(Math.random() * possibleMoves.length) 27 | game.move(possibleMoves[randomIdx]) 28 | board.position(game.fen()) 29 | 30 | window.setTimeout(makeRandomMove, 500) 31 | } 32 | 33 | board = Chessboard('myBoard', 'start') 34 | 35 | window.setTimeout(makeRandomMove, 500) 36 | -------------------------------------------------------------------------------- /examples/5003-highlight-legal-moves.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5003 3 | 4 | ===== Name 5 | Highlight Legal Moves 6 | 7 | ===== Description 8 | Use the onMouseoverSquare and onMouseoutSquare events to highlight legal squares. 9 | 10 | ===== HTML 11 |
12 | 13 | ===== JS 14 | // NOTE: this example uses the chess.js library: 15 | // https://github.com/jhlywa/chess.js 16 | 17 | var board = null 18 | var game = new Chess() 19 | var whiteSquareGrey = '#a9a9a9' 20 | var blackSquareGrey = '#696969' 21 | 22 | function removeGreySquares () { 23 | $('#myBoard .square-55d63').css('background', '') 24 | } 25 | 26 | function greySquare (square) { 27 | var $square = $('#myBoard .square-' + square) 28 | 29 | var background = whiteSquareGrey 30 | if ($square.hasClass('black-3c85d')) { 31 | background = blackSquareGrey 32 | } 33 | 34 | $square.css('background', background) 35 | } 36 | 37 | function onDragStart (source, piece) { 38 | // do not pick up pieces if the game is over 39 | if (game.game_over()) return false 40 | 41 | // or if it's not that side's turn 42 | if ((game.turn() === 'w' && piece.search(/^b/) !== -1) || 43 | (game.turn() === 'b' && piece.search(/^w/) !== -1)) { 44 | return false 45 | } 46 | } 47 | 48 | function onDrop (source, target) { 49 | removeGreySquares() 50 | 51 | // see if the move is legal 52 | var move = game.move({ 53 | from: source, 54 | to: target, 55 | promotion: 'q' // NOTE: always promote to a queen for example simplicity 56 | }) 57 | 58 | // illegal move 59 | if (move === null) return 'snapback' 60 | } 61 | 62 | function onMouseoverSquare (square, piece) { 63 | // get list of possible moves for this square 64 | var moves = game.moves({ 65 | square: square, 66 | verbose: true 67 | }) 68 | 69 | // exit if there are no moves available for this square 70 | if (moves.length === 0) return 71 | 72 | // highlight the square they moused over 73 | greySquare(square) 74 | 75 | // highlight the possible squares for this piece 76 | for (var i = 0; i < moves.length; i++) { 77 | greySquare(moves[i].to) 78 | } 79 | } 80 | 81 | function onMouseoutSquare (square, piece) { 82 | removeGreySquares() 83 | } 84 | 85 | function onSnapEnd () { 86 | board.position(game.fen()) 87 | } 88 | 89 | var config = { 90 | draggable: true, 91 | position: 'start', 92 | onDragStart: onDragStart, 93 | onDrop: onDrop, 94 | onMouseoutSquare: onMouseoutSquare, 95 | onMouseoverSquare: onMouseoverSquare, 96 | onSnapEnd: onSnapEnd 97 | } 98 | board = Chessboard('myBoard', config) 99 | -------------------------------------------------------------------------------- /examples/5004-piece-highlight1.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5004 3 | 4 | ===== Name 5 | Piece Highlighting 1 6 | 7 | ===== Description 8 | Use CSS to show piece highlighting. 9 | 10 | ===== HTML 11 | 19 |
20 | 21 | ===== JS 22 | // NOTE: this example uses the chess.js library: 23 | // https://github.com/jhlywa/chess.js 24 | 25 | var board = null 26 | var $board = $('#myBoard') 27 | var game = new Chess() 28 | var squareClass = 'square-55d63' 29 | var squareToHighlight = null 30 | var colorToHighlight = null 31 | 32 | function makeRandomMove () { 33 | var possibleMoves = game.moves({ 34 | verbose: true 35 | }) 36 | 37 | // exit if the game is over 38 | if (game.game_over()) return 39 | 40 | var randomIdx = Math.floor(Math.random() * possibleMoves.length) 41 | var move = possibleMoves[randomIdx] 42 | 43 | if (move.color === 'w') { 44 | $board.find('.' + squareClass).removeClass('highlight-white') 45 | $board.find('.square-' + move.from).addClass('highlight-white') 46 | squareToHighlight = move.to 47 | colorToHighlight = 'white' 48 | } else { 49 | $board.find('.' + squareClass).removeClass('highlight-black') 50 | $board.find('.square-' + move.from).addClass('highlight-black') 51 | squareToHighlight = move.to 52 | colorToHighlight = 'black' 53 | } 54 | 55 | game.move(possibleMoves[randomIdx].san) 56 | board.position(game.fen()) 57 | 58 | window.setTimeout(makeRandomMove, 1200) 59 | } 60 | 61 | function onMoveEnd () { 62 | $board.find('.square-' + squareToHighlight) 63 | .addClass('highlight-' + colorToHighlight) 64 | } 65 | 66 | var config = { 67 | position: 'start', 68 | onMoveEnd: onMoveEnd 69 | } 70 | board = Chessboard('myBoard', config) 71 | 72 | window.setTimeout(makeRandomMove, 500) 73 | -------------------------------------------------------------------------------- /examples/5005-piece-highlight2.example: -------------------------------------------------------------------------------- 1 | ===== id 2 | 5005 3 | 4 | ===== Name 5 | Piece Highlighting 2 6 | 7 | ===== Description 8 | Use CSS to show piece highlighting. 9 | 10 | ===== HTML 11 | 19 |
20 | 21 | ===== JS 22 | // NOTE: this example uses the chess.js library: 23 | // https://github.com/jhlywa/chess.js 24 | 25 | var board = null 26 | var $board = $('#myBoard') 27 | var game = new Chess() 28 | var squareToHighlight = null 29 | var squareClass = 'square-55d63' 30 | 31 | function removeHighlights (color) { 32 | $board.find('.' + squareClass) 33 | .removeClass('highlight-' + color) 34 | } 35 | 36 | function onDragStart (source, piece, position, orientation) { 37 | // do not pick up pieces if the game is over 38 | if (game.game_over()) return false 39 | 40 | // only pick up pieces for White 41 | if (piece.search(/^b/) !== -1) return false 42 | } 43 | 44 | function makeRandomMove () { 45 | var possibleMoves = game.moves({ 46 | verbose: true 47 | }) 48 | 49 | // game over 50 | if (possibleMoves.length === 0) return 51 | 52 | var randomIdx = Math.floor(Math.random() * possibleMoves.length) 53 | var move = possibleMoves[randomIdx] 54 | game.move(move.san) 55 | 56 | // highlight black's move 57 | removeHighlights('black') 58 | $board.find('.square-' + move.from).addClass('highlight-black') 59 | squareToHighlight = move.to 60 | 61 | // update the board to the new position 62 | board.position(game.fen()) 63 | } 64 | 65 | function onDrop (source, target) { 66 | // see if the move is legal 67 | var move = game.move({ 68 | from: source, 69 | to: target, 70 | promotion: 'q' // NOTE: always promote to a queen for example simplicity 71 | }) 72 | 73 | // illegal move 74 | if (move === null) return 'snapback' 75 | 76 | // highlight white's move 77 | removeHighlights('white') 78 | $board.find('.square-' + source).addClass('highlight-white') 79 | $board.find('.square-' + target).addClass('highlight-white') 80 | 81 | // make random move for black 82 | window.setTimeout(makeRandomMove, 250) 83 | } 84 | 85 | function onMoveEnd () { 86 | $board.find('.square-' + squareToHighlight) 87 | .addClass('highlight-black') 88 | } 89 | 90 | // update the board position after the piece snap 91 | // for castling, en passant, pawn promotion 92 | function onSnapEnd () { 93 | board.position(game.fen()) 94 | } 95 | 96 | var config = { 97 | draggable: true, 98 | position: 'start', 99 | onDragStart: onDragStart, 100 | onDrop: onDrop, 101 | onMoveEnd: onMoveEnd, 102 | onSnapEnd: onSnapEnd 103 | } 104 | board = Chessboard('myBoard', config) 105 | -------------------------------------------------------------------------------- /lib/chessboard.css: -------------------------------------------------------------------------------- 1 | /*! chessboard.js v@VERSION | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */ 2 | 3 | .clearfix-7da63 { 4 | clear: both; 5 | } 6 | 7 | .board-b72b1 { 8 | border: 2px solid #404040; 9 | box-sizing: content-box; 10 | } 11 | 12 | .square-55d63 { 13 | float: left; 14 | position: relative; 15 | 16 | /* disable any native browser highlighting */ 17 | -webkit-touch-callout: none; 18 | -webkit-user-select: none; 19 | -khtml-user-select: none; 20 | -moz-user-select: none; 21 | -ms-user-select: none; 22 | user-select: none; 23 | } 24 | 25 | .white-1e1d7 { 26 | background-color: #f0d9b5; 27 | color: #b58863; 28 | } 29 | 30 | .black-3c85d { 31 | background-color: #b58863; 32 | color: #f0d9b5; 33 | } 34 | 35 | .highlight1-32417, .highlight2-9c5d2 { 36 | box-shadow: inset 0 0 3px 3px yellow; 37 | } 38 | 39 | .notation-322f9 { 40 | cursor: default; 41 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 42 | font-size: 14px; 43 | position: absolute; 44 | } 45 | 46 | .alpha-d2270 { 47 | bottom: 1px; 48 | right: 3px; 49 | } 50 | 51 | .numeric-fc462 { 52 | top: 2px; 53 | left: 2px; 54 | } 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Chris Oakman (http://chrisoakman.com/)", 3 | "name": "@chrisoakman/chessboardjs", 4 | "description": "JavaScript chessboard widget", 5 | "homepage": "https://chessboardjs.com", 6 | "license": "MIT", 7 | "version": "1.0.0", 8 | "repository": { 9 | "type": "git", 10 | "url": "git://github.com/oakmac/chessboardjs.git" 11 | }, 12 | "files": ["dist/"], 13 | "dependencies": { 14 | "jquery": ">=3.4.1" 15 | }, 16 | "devDependencies": { 17 | "csso": "3.5.1", 18 | "fs-plus": "3.1.1", 19 | "kidif": "1.1.0", 20 | "mustache": "2.3.0", 21 | "standard": "10.0.2", 22 | "uglify-js": "3.6.0" 23 | }, 24 | "scripts": { 25 | "build": "standard lib/chessboard.js && node scripts/build.js", 26 | "standard": "standard --fix lib/*.js website/js/*.js", 27 | "website": "node scripts/website.js" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // This file creates a build in the dist/ folder 3 | // ----------------------------------------------------------------------------- 4 | 5 | // libraries 6 | const fs = require('fs-plus') 7 | const csso = require('csso') 8 | const uglify = require('uglify-js') 9 | 10 | const encoding = {encoding: 'utf8'} 11 | 12 | const package = JSON.parse(fs.readFileSync('package.json', encoding)) 13 | const version = package.version 14 | const year = new Date().getFullYear() 15 | const cssSrc = fs.readFileSync('lib/chessboard.css', encoding) 16 | .replace('@VERSION', version) 17 | const jsSrc = fs.readFileSync('lib/chessboard.js', encoding) 18 | .replace('@VERSION', version) 19 | .replace('RUN_ASSERTS = true', 'RUN_ASSERTS = false') 20 | 21 | // TODO: need to remove the RUN_ASSERTS calls from the non-minified file 22 | 23 | const minifiedCSS = csso.minify(cssSrc).css 24 | const uglifyResult = uglify.minify(jsSrc) 25 | const minifiedJS = uglifyResult.code 26 | 27 | // quick sanity checks 28 | console.assert(!uglifyResult.error, 'error minifying JS!') 29 | console.assert(typeof minifiedCSS === 'string' && minifiedCSS !== '', 'error minifying CSS!') 30 | 31 | // add license to the top of minified files 32 | const minifiedJSWithBanner = banner() + minifiedJS 33 | 34 | // create a fresh dist/ folder 35 | fs.removeSync('dist') 36 | fs.makeTreeSync('dist') 37 | 38 | // copy lib files to dist/ 39 | fs.writeFileSync('dist/chessboard-' + version + '.css', cssSrc, encoding) 40 | fs.writeFileSync('dist/chessboard-' + version + '.min.css', minifiedCSS, encoding) 41 | fs.writeFileSync('dist/chessboard-' + version + '.js', jsSrc, encoding) 42 | fs.writeFileSync('dist/chessboard-' + version + '.min.js', minifiedJSWithBanner, encoding) 43 | 44 | function banner () { 45 | return '/*! chessboard.js v' + version + ' | (c) ' + year + ' Chris Oakman | MIT License chessboardjs.com/license */\n' 46 | } 47 | -------------------------------------------------------------------------------- /scripts/rename.js: -------------------------------------------------------------------------------- 1 | // TODO: this is unfinished / not working 2 | 3 | var fs = require('fs') 4 | var glob = require('glob') 5 | 6 | var exampleFiles = glob.sync('examples/*.example') 7 | 8 | exampleFiles.forEach(processFile) 9 | 10 | function processFile (f) { 11 | var fileContents = fs.readFileSync(f, {encoding:'utf8'}) 12 | var lines = fileContents.split('\n') 13 | 14 | lines = lines.map(processLine) 15 | 16 | fs.writeFileSync(f, lines.join('\n')) 17 | } 18 | 19 | function processLine (line) { 20 | line = line.replace('docs#', 'docs.html#') 21 | return line 22 | } 23 | -------------------------------------------------------------------------------- /scripts/website.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | // ----------------------------------------------------------------------------- 4 | // This file builds the contents of the website/ folder. 5 | // ----------------------------------------------------------------------------- 6 | 7 | // libraries 8 | const fs = require('fs-plus') 9 | const kidif = require('kidif') 10 | const mustache = require('mustache') 11 | const docs = require('../data/docs.json') 12 | 13 | const encoding = {encoding: 'utf8'} 14 | 15 | // toggle development version 16 | const useDevFile = false 17 | const jsCDNLink = '' 18 | const cssCDNLink = 'https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.css' 19 | 20 | let chessboardJsScript = jsCDNLink 21 | if (useDevFile) { 22 | chessboardJsScript = '' 23 | } 24 | 25 | // grab some mustache templates 26 | const docsTemplate = fs.readFileSync('templates/docs.mustache', encoding) 27 | const downloadTemplate = fs.readFileSync('templates/download.mustache', encoding) 28 | const examplesTemplate = fs.readFileSync('templates/examples.mustache', encoding) 29 | const homepageTemplate = fs.readFileSync('templates/homepage.mustache', encoding) 30 | const singleExampleTemplate = fs.readFileSync('templates/single-example.mustache', encoding) 31 | const licensePageTemplate = fs.readFileSync('templates/license.mustache', encoding) 32 | const headTemplate = fs.readFileSync('templates/_head.mustache', encoding) 33 | const headerTemplate = fs.readFileSync('templates/_header.mustache', encoding) 34 | const footerTemplate = fs.readFileSync('templates/_footer.mustache', encoding) 35 | 36 | const latestChessboardJS = fs.readFileSync('lib/chessboard.js', encoding) 37 | const latestChessboardCSS = fs.readFileSync('lib/chessboard.css', encoding) 38 | 39 | // grab the examples 40 | const examplesArr = kidif('examples/*.example') 41 | console.assert(examplesArr, 'Could not load the Example files') 42 | console.assert(examplesArr.length > 1, 'Zero examples loaded') 43 | 44 | const examplesObj = examplesArr.reduce(function (examplesObj, example, idx) { 45 | examplesObj[example.id] = example 46 | return examplesObj 47 | }, {}) 48 | 49 | const examplesGroups = [ 50 | { 51 | name: 'Basic Usage', 52 | examples: [1000, 1001, 1002, 1003, 1004] 53 | }, 54 | { 55 | name: 'Config', 56 | examples: [2000, 2044, 2063, 2001, 2002, 2003, 2082, 2004, 2030, 2005, 2006] 57 | }, 58 | { 59 | name: 'Methods', 60 | examples: [3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007] 61 | }, 62 | { 63 | name: 'Events', 64 | examples: [4000, 4001, 4002, 4003, 4004, 4005, 4006, 4011, 4012] 65 | }, 66 | { 67 | name: 'Integration', 68 | examples: [5000, 5001, 5002, 5003, 5004, 5005] 69 | } 70 | ] 71 | 72 | const homepageExample1 = '' 73 | 74 | const homepageExample2 = ` 75 | var board2 = Chessboard('board2', { 76 | draggable: true, 77 | dropOffBoard: 'trash', 78 | sparePieces: true 79 | }) 80 | 81 | $('#startBtn').on('click', board2.start) 82 | $('#clearBtn').on('click', board2.clear)`.trim() 83 | 84 | function writeSrcFiles () { 85 | fs.writeFileSync('website/js/chessboard.js', latestChessboardJS, encoding) 86 | fs.writeFileSync('website/css/chessboard.css', latestChessboardCSS, encoding) 87 | } 88 | 89 | function writeHomepage () { 90 | const headHTML = mustache.render(headTemplate, {pageTitle: 'Homepage'}) 91 | 92 | const html = mustache.render(homepageTemplate, { 93 | chessboardJsScript: chessboardJsScript, 94 | example2: homepageExample2, 95 | footer: footerTemplate, 96 | head: headHTML 97 | }) 98 | fs.writeFileSync('website/index.html', html, encoding) 99 | } 100 | 101 | function writeExamplesPage () { 102 | const headHTML = mustache.render(headTemplate, {pageTitle: 'Examples'}) 103 | const headerHTML = mustache.render(headerTemplate, {examplesActive: true}) 104 | 105 | const html = mustache.render(examplesTemplate, { 106 | chessboardJsScript: chessboardJsScript, 107 | examplesJavaScript: buildExamplesJS(), 108 | footer: footerTemplate, 109 | head: headHTML, 110 | header: headerHTML, 111 | nav: buildExamplesNavHTML() 112 | }) 113 | fs.writeFileSync('website/examples.html', html, encoding) 114 | } 115 | 116 | const configTableRowsHTML = docs.config.reduce(function (html, itm) { 117 | if (isString(itm)) return html 118 | return html + buildConfigDocsTableRowHTML('config', itm) 119 | }, '') 120 | 121 | const methodTableRowsHTML = docs.methods.reduce(function (html, itm) { 122 | if (isString(itm)) return html 123 | return html + buildMethodRowHTML(itm) 124 | }, '') 125 | 126 | const errorRowsHTML = docs.errors.reduce(function (html, itm) { 127 | if (isString(itm)) return html 128 | return html + buildErrorRowHTML(itm) 129 | }, '') 130 | 131 | function isIntegrationExample (example) { 132 | return (example.id + '').startsWith('5') 133 | } 134 | 135 | function writeSingleExamplePage (example) { 136 | if (isIntegrationExample(example)) { 137 | example.includeChessJS = true 138 | } 139 | example.chessboardJsScript = chessboardJsScript 140 | const html = mustache.render(singleExampleTemplate, example) 141 | fs.writeFileSync('website/examples/' + example.id + '.html', html, encoding) 142 | } 143 | 144 | function writeSingleExamplesPages () { 145 | examplesArr.forEach(writeSingleExamplePage) 146 | } 147 | 148 | function writeDocsPage () { 149 | const headHTML = mustache.render(headTemplate, {pageTitle: 'Documentation'}) 150 | const headerHTML = mustache.render(headerTemplate, {docsActive: true}) 151 | 152 | const html = mustache.render(docsTemplate, { 153 | configTableRows: configTableRowsHTML, 154 | errorRows: errorRowsHTML, 155 | footer: footerTemplate, 156 | head: headHTML, 157 | header: headerHTML, 158 | methodTableRows: methodTableRowsHTML 159 | }) 160 | fs.writeFileSync('website/docs.html', html, encoding) 161 | } 162 | 163 | function writeDownloadPage () { 164 | const headHTML = mustache.render(headTemplate, {pageTitle: 'Download'}) 165 | const headerHTML = mustache.render(headerTemplate, {downloadActive: true}) 166 | 167 | const html = mustache.render(downloadTemplate, { 168 | footer: footerTemplate, 169 | head: headHTML, 170 | header: headerHTML 171 | }) 172 | fs.writeFileSync('website/download.html', html, encoding) 173 | } 174 | 175 | function writeLicensePage () { 176 | const html = mustache.render(licensePageTemplate) 177 | fs.writeFileSync('website/license.html', html, encoding) 178 | } 179 | 180 | function writeWebsite () { 181 | writeSrcFiles() 182 | writeHomepage() 183 | writeExamplesPage() 184 | writeSingleExamplesPages() 185 | writeDocsPage() 186 | writeDownloadPage() 187 | writeLicensePage() 188 | } 189 | 190 | writeWebsite() 191 | 192 | // ----------------------------------------------------------------------------- 193 | // HTML 194 | // ----------------------------------------------------------------------------- 195 | 196 | function htmlEscape (str) { 197 | return (str + '') 198 | .replace(/&/g, '&') 199 | .replace(//g, '>') 201 | .replace(/"/g, '"') 202 | .replace(/'/g, ''') 203 | .replace(/\//g, '/') 204 | .replace(/`/g, '`') 205 | } 206 | 207 | function buildExampleGroupHTML (idx, groupName, examplesInGroup) { 208 | const groupNum = idx + 1 209 | let html = '

' + groupName + '

' + 210 | '' 218 | 219 | return html 220 | } 221 | 222 | function buildExamplesNavHTML () { 223 | let html = '' 224 | examplesGroups.forEach(function (group, idx) { 225 | html += buildExampleGroupHTML(idx, group.name, group.examples) 226 | }) 227 | return html 228 | } 229 | 230 | function buildExamplesJS () { 231 | let txt = 'window.CHESSBOARD_EXAMPLES = {}\n\n' 232 | 233 | examplesArr.forEach(function (ex) { 234 | txt += 'CHESSBOARD_EXAMPLES["' + ex.id + '"] = {\n' + 235 | ' description: ' + JSON.stringify(ex.description) + ',\n' + 236 | ' html: ' + JSON.stringify(ex.html) + ',\n' + 237 | ' name: ' + JSON.stringify(ex.name) + ',\n' + 238 | ' jsStr: ' + JSON.stringify(ex.js) + ',\n' + 239 | ' jsFn: function () {\n' + ex.js + '\n }\n' + 240 | '};\n\n' 241 | }) 242 | 243 | return txt 244 | } 245 | 246 | function buildConfigDocsTableRowHTML (propType, prop) { 247 | let html = '' 248 | 249 | // table row 250 | html += '' 251 | 252 | // property and type 253 | html += '' + buildPropertyAndTypeHTML(propType, prop.name, prop.type) + '' 254 | 255 | // default 256 | html += '

' + buildDefaultHTML(prop.default) + '

' 257 | 258 | // description 259 | html += '' + buildDescriptionHTML(prop.desc) + '' 260 | 261 | // examples 262 | html += '' + buildExamplesCellHTML(prop.examples) + '' 263 | 264 | html += '' 265 | 266 | return html 267 | } 268 | 269 | function buildMethodRowHTML (method) { 270 | const nameNoParens = method.name.replace(/\(.+$/, '') 271 | 272 | let html = '' 273 | 274 | // table row 275 | if (method.noId) { 276 | html += '' 277 | } else { 278 | html += '' 279 | } 280 | 281 | // name 282 | html += '

' + 283 | '' + method.name + '

' 284 | 285 | // args 286 | if (method.args) { 287 | html += '' 288 | method.args.forEach(function (arg) { 289 | html += '

' + arg[1] + '

' 290 | }) 291 | html += '' 292 | } else { 293 | html += 'none' 294 | } 295 | 296 | // description 297 | html += '' + buildDescriptionHTML(method.desc) + '' 298 | 299 | // examples 300 | html += '' + buildExamplesCellHTML(method.examples) + '' 301 | 302 | html += '' 303 | 304 | return html 305 | } 306 | 307 | function buildPropertyAndTypeHTML (section, name, type) { 308 | let html = '

' + 309 | '' + name + '

' + 310 | '

' + buildTypeHTML(type) + '

' 311 | return html 312 | } 313 | 314 | function buildTypeHTML (type) { 315 | if (!Array.isArray(type)) { 316 | type = [type] 317 | } 318 | 319 | let html = '' 320 | for (var i = 0; i < type.length; i++) { 321 | if (i !== 0) { 322 | html += ' or
' 323 | } 324 | html += type[i] 325 | } 326 | 327 | return html 328 | } 329 | 330 | function buildRequiredHTML (req) { 331 | if (!req) return 'no' 332 | if (req === true) return 'yes' 333 | return req 334 | } 335 | 336 | function buildDescriptionHTML (desc) { 337 | if (!Array.isArray(desc)) { 338 | desc = [desc] 339 | } 340 | 341 | let html = '' 342 | desc.forEach(function (d) { 343 | html += '

' + d + '

' 344 | }) 345 | 346 | return html 347 | } 348 | 349 | function buildDefaultHTML (defaultValue) { 350 | if (!defaultValue) { 351 | return 'n/a' 352 | } 353 | return defaultValue 354 | } 355 | 356 | function buildExamplesCellHTML (examplesIds) { 357 | if (!Array.isArray(examplesIds)) { 358 | examplesIds = [examplesIds] 359 | } 360 | 361 | let html = '' 362 | examplesIds.forEach(function (exampleId) { 363 | var example = examplesObj[exampleId] 364 | if (!example) return 365 | html += '

' + example.name + '

' 366 | }) 367 | 368 | return html 369 | } 370 | 371 | function buildErrorRowHTML (error) { 372 | let html = '' 373 | 374 | // table row 375 | html += '' 376 | 377 | // id 378 | html += '' + 379 | '

' + error.id + '

' 380 | 381 | // desc 382 | html += '

' + error.desc + '

' 383 | 384 | // more information 385 | if (error.fix) { 386 | if (!Array.isArray(error.fix)) { 387 | error.fix = [error.fix] 388 | } 389 | 390 | html += '' 391 | error.fix.forEach(function (p) { 392 | html += '

' + p + '

' 393 | }) 394 | html += '' 395 | } else { 396 | html += 'n/a' 397 | } 398 | 399 | html += '' 400 | 401 | return html 402 | } 403 | 404 | function isString (s) { 405 | return typeof s === 'string' 406 | } 407 | -------------------------------------------------------------------------------- /templates/_footer.mustache: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /templates/_head.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | chessboardjs.com » {{pageTitle}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /templates/_header.mustache: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 | Home 8 | Examples 9 | Docs 10 | Download 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /templates/docs.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{{head}}} 4 | 5 | {{{header}}} 6 | 7 |
8 |
9 | 10 | 11 |
12 |

Documentation

13 | 20 |
21 | 22 | 23 |
24 |

Config Properties

25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | {{{configTableRows}}} 35 |
Property / TypeDefaultDescriptionExample
36 |
37 | 38 | 39 |
40 |

Methods

41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {{{methodTableRows}}} 51 |
MethodArgumentsDescriptionExample
52 |
53 | 54 | 55 |
56 |

Position Object

57 |

You can use a JavaScript object to represent a board position.

58 |

The object property names must be algebraic squares (ie: e4, b2, c6, etc) and the values must be a valid piece codes (ie: wP, bK, wQ, etc).

59 |

See an example of using an object to represent a position here.

60 |

Chessboard.js exposes the Chessboard.objToFen method to help convert between Position Objects and FEN Strings.

61 |
62 | 63 | 64 |
65 |

FEN String

66 |

You can use Forsyth-Edwards Notation (FEN) to represent a board position.

67 |

Note that FEN notation captures more information than chessboard.js requires, like who's move it is and whether or not castling is allowed. This information will be ignored; only the position information is used.

68 |

See an example of using a FEN String to represent a position here and here.

69 |

Chessboard.js exposes the Chessboard.fenToObj method to help convert a FEN String to a Position Object.

70 |
71 | 72 | 73 |
74 |

Errors

75 |

Chessboard.js has an error system designed to inform you when you use the API incorrectly.

76 |

Every alert has a unique code associated with it and you can control how the errors are presented with the showErrors config option.

77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {{{errorRows}}} 86 |
Error IDError TextMore Information
87 |
88 | 89 | 90 |
91 |
92 | 93 | {{{footer}}} 94 | 95 | 96 | 97 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /templates/download.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{{head}}} 4 | 5 | {{{header}}} 6 | 7 |
8 |
9 | 10 |
11 |

Download

12 | 13 |
14 |

Latest

15 | Download Latest Version
v1.0.0
16 |
17 | 18 | 19 |
20 |

NPM / Yarn Package

21 |

chessboardjs is on npm under the name @chrisoakman/chessboardjs

22 |
# using npm
23 | npm install @chrisoakman/chessboardjs
24 | 25 |
# using yarn
26 | yarn add @chrisoakman/chessboardjs
27 |
28 | 29 |
30 |

Content Delivery Network

31 |

You can use chessboardjs via the unpkg CDN with the following links: 32 |

<link rel="stylesheet"
33 |       href="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.css"
34 |       integrity="sha384-q94+BZtLrkL1/ohfjR8c6L+A6qzNH9R2hBLwyoAfu3i/WCvQjzL2RQJ3uNHDISdU"
35 |       crossorigin="anonymous">
36 |
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
37 |         integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
38 |         crossorigin="anonymous"></script>
39 | 
40 | <script src="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.js"
41 |         integrity="sha384-8Vi8VHwn3vjQ9eUHUxex3JSN/NFqUg3QbPyX8kWyb93+8AC/pPWTzj+nHtbC5bxD"
42 |         crossorigin="anonymous"></script>
43 |

Please note that jQuery is a required dependency of chessboard.js and must be loaded on your webpage before the chessboard-1.0.0.min.js file.

44 |
45 | 46 |
47 |

Development

48 |

GitHub

49 |
50 | 51 |
52 | 53 |
54 |
55 | 56 | {{{footer}}} 57 | 58 | 59 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /templates/examples.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{{head}}} 4 | 5 | {{{header}}} 6 | 7 |
8 |
9 | 10 |
11 |
12 |
13 | 14 | {{{footer}}} 15 | 16 | 19 | 20 | 21 | {{{chessboardJsScript}}} 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /templates/homepage.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{{head}}} 4 | 5 | 6 |
7 |
8 | Black King 9 |

chessboard.js

10 |

The easiest way to embed a chess board on your site.

11 | Download v1.0.0 12 |
13 |
14 | 15 | 23 | 24 |
25 | 26 |
27 |
28 |

As easy as two lines.

29 |

HTML

30 |
<div id="board1" style="width: 400px"></div>
31 |

JavaScript

32 |
var board1 = Chessboard('board1', 'start')
33 |
34 |
35 |
36 |
37 |
38 | 39 |
40 |
41 |

Customize with a powerful API.

42 |

HTML

43 |
44 | <div id="board2" style="width: 400px"></div>
45 | <button id="startBtn">Start Position</button>
46 | <button id="clearBtn">Clear Board</button>
47 | 
48 |

JavaScript

49 |
{{{example2}}}
50 |
51 |
52 |
53 | 54 | 55 |
56 |
57 | 58 |
59 | 60 | {{{footer}}} 61 | 62 | 63 | 64 | {{{chessboardJsScript}}} 65 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /templates/license.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | chessboard.js MIT license 8 | 9 | 10 | -------------------------------------------------------------------------------- /templates/single-example.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | chessboardjs Example #{{{id}}} - {{{name}}} 7 | 8 | 9 | {{#css}} 10 | 13 | {{/css}} 14 | 15 | 16 |

← Back to all examples.

17 | 18 |

{{{description}}}

19 | 20 | 21 | {{{html}}} 22 | 23 | 24 | 25 | {{{chessboardJsScript}}} 26 | {{#includeChessJS}} 27 | 28 | {{/includeChessJS}} 29 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /website/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | 3 | ## Force https 4 | RewriteCond %{HTTPS} off 5 | RewriteRule (.*) https://chessboardjs.com/$1 [R=301,L] 6 | 7 | ## Allow URLs that do not include the ".html" extension 8 | RewriteCond %{REQUEST_FILENAME}.html -f 9 | RewriteRule (.*) $1.html [L] 10 | -------------------------------------------------------------------------------- /website/192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/192.png -------------------------------------------------------------------------------- /website/512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/512.png -------------------------------------------------------------------------------- /website/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/apple-touch-icon.png -------------------------------------------------------------------------------- /website/css/website2.css: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * Normalize 3 | *----------------------------------------------------------------------------*/ 4 | 5 | /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */ 6 | button,hr,input{overflow:visible}audio,canvas,progress,video{display:inline-block}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none} 7 | 8 | /*------------------------------------------------------------------------------ 9 | * General 10 | *----------------------------------------------------------------------------*/ 11 | 12 | html { 13 | box-sizing: border-box; 14 | } 15 | 16 | *, *:before, *:after { 17 | box-sizing: inherit; 18 | } 19 | 20 | body { 21 | background: #333; 22 | color: #333; 23 | font-family: 'Open Sans', arial, sans-serif; 24 | } 25 | 26 | body.homepage { 27 | background: #fff; 28 | } 29 | 30 | body.homepage main { 31 | background: #fff; 32 | } 33 | 34 | a { 35 | color: #462bcb; 36 | } 37 | 38 | a:hover { 39 | text-decoration: underline; 40 | } 41 | 42 | .body-width-115f6 { 43 | margin: 0 auto; 44 | width: 1024px; 45 | } 46 | 47 | .flex-c31d5 { 48 | display: flex; 49 | } 50 | 51 | .body-width { 52 | margin: 0 auto; 53 | width: 960px; 54 | } 55 | 56 | .clearfix { 57 | clear: both; 58 | } 59 | 60 | .homepage-nav-b9ecc { 61 | border-bottom: 1px solid #efefef; 62 | } 63 | 64 | .homepage-section-88e4a { 65 | display: flex; 66 | } 67 | 68 | .col-11bcf button, .blue-button { 69 | background: #2ba6cb; 70 | border-radius: 3px; 71 | border: 1px solid #1e728c; 72 | color: #fff; 73 | cursor: pointer; 74 | display: inline-block; 75 | font-size: 14px; 76 | font-weight: 600; 77 | margin: 15px 5px 0 0; 78 | outline: none; 79 | padding: 10px 15px; 80 | text-align: center; 81 | text-decoration: none; 82 | } 83 | 84 | .blue-button.large { 85 | font-size: 18px; 86 | padding: 15px 30px; 87 | } 88 | 89 | h2 { 90 | font-size: 26px; 91 | font-weight: 300; 92 | } 93 | 94 | h4 { 95 | font-size: 14px; 96 | font-weight: 400; 97 | margin: 0; 98 | text-transform: uppercase; 99 | } 100 | 101 | pre.prettyprint { 102 | margin: 8px 0 30px 0; 103 | } 104 | 105 | .hover-linkable .hover-link { 106 | display: none; 107 | } 108 | 109 | .hover-linkable:hover .hover-link { 110 | background-image: url('../img/link.svg'); 111 | background-repeat: no-repeat; 112 | background-size: 16px; 113 | display: block; 114 | float: left; 115 | height: 16px; 116 | line-height: 1; 117 | margin-left: -16px; 118 | margin-top: 14px; 119 | padding-right: 16px; 120 | width: 16px; 121 | } 122 | 123 | .hover-linkable:hover .hover-link.docs { 124 | margin-top: 8px; 125 | margin-left: -18px; 126 | padding-right: 18px; 127 | } 128 | 129 | /*------------------------------------------------------------------------------ 130 | * Header 131 | *----------------------------------------------------------------------------*/ 132 | 133 | #topBar { 134 | background-image: url('../img/board-background.png'); 135 | background-position: center top; 136 | height: 35px; 137 | } 138 | 139 | #headerWrapper { 140 | padding: 20px 0; 141 | } 142 | 143 | #headerWrapper .left-col { 144 | float: left; 145 | width: 300px; 146 | } 147 | 148 | #homeLink { 149 | color: #444; 150 | font-size: 18px; 151 | font-weight: bold; 152 | text-decoration: none; 153 | } 154 | 155 | #homeLink .piece { 156 | font-weight: normal; 157 | } 158 | 159 | #headerWrapper .right-col { 160 | float: right; 161 | text-align: right; 162 | width: 600px; 163 | } 164 | 165 | #headerWrapper .nav-link { 166 | display: block; 167 | color: #444; 168 | float: right; 169 | font-size: 18px; 170 | text-align: center; 171 | text-decoration: none; 172 | width: 140px; 173 | } 174 | 175 | #headerWrapper .nav-link .piece { 176 | visibility: hidden; 177 | } 178 | 179 | #headerWrapper .nav-link:hover .piece { 180 | visibility: visible; 181 | } 182 | 183 | header { 184 | background: #222; 185 | } 186 | 187 | .homepage-link-98a24 { 188 | color: #fff; 189 | cursor: pointer; 190 | display: inline-block; 191 | font-size: 22px; 192 | font-weight: 600; 193 | padding: 10px 20px; 194 | text-decoration: none; 195 | } 196 | 197 | .homepage-link-98a24:hover { 198 | background: #000; 199 | text-decoration: none; 200 | } 201 | 202 | .tld-bd9e6 { 203 | color: #ccc; 204 | font-size: 16px; 205 | font-weight: 300; 206 | } 207 | 208 | header .right-05ad3 a { 209 | color: #fff; 210 | display: inline-block; 211 | font-size: 14px; 212 | padding: 15px 20px; 213 | text-decoration: none; 214 | } 215 | 216 | header .right-05ad3 a:hover { 217 | background: #000; 218 | text-decoration: underline; 219 | } 220 | 221 | /*------------------------------------------------------------------------------ 222 | * Footer 223 | *----------------------------------------------------------------------------*/ 224 | 225 | footer { 226 | background: #333; 227 | color: #999; 228 | font-size: 14px; 229 | padding: 30px 0; 230 | } 231 | 232 | footer p { 233 | margin: 0 0 8px 0; 234 | } 235 | 236 | footer a { 237 | color: #fff; 238 | text-decoration: none; 239 | } 240 | 241 | footer a:hover { 242 | text-decoration: underline; 243 | } 244 | 245 | .left-3edd4 { 246 | flex: 1; 247 | } 248 | 249 | .right-05ad3 { 250 | flex: 1; 251 | text-align: right; 252 | } 253 | 254 | footer .left-3edd4 { 255 | padding-left: 20px; 256 | } 257 | 258 | /*------------------------------------------------------------------------------ 259 | * Homepage 260 | *----------------------------------------------------------------------------*/ 261 | 262 | .hero-wrapper { 263 | background-image: url('../img/board-background.png'); 264 | background-position: center top; 265 | } 266 | 267 | .hero-inner-556fe { 268 | height: 535px; 269 | margin: 0px auto; 270 | padding-top: 118px; 271 | text-align: center; 272 | } 273 | 274 | .hero-inner-556fe img { 275 | display: block; 276 | height: 60px; 277 | margin: 0 auto; 278 | width: 60px; 279 | } 280 | 281 | .hero-inner-556fe h1 { 282 | color: #fff; 283 | font-size: 44px; 284 | font-weight: 400; 285 | margin: 28px 0 0 0; 286 | padding: 0; 287 | } 288 | 289 | .hero-inner-556fe h3 { 290 | color: #fff; 291 | font-size: 16px; 292 | font-weight: 300; 293 | margin: 0; 294 | padding-top: 8px; 295 | } 296 | 297 | .hero-inner-556fe a { 298 | background: #ffdc10; 299 | border-radius: 6px; 300 | color: #333; 301 | display: block; 302 | margin: 45px auto 0 auto; 303 | padding: 12px 24px; 304 | text-decoration: none; 305 | width: 200px; 306 | } 307 | 308 | .navbar-a57cc { 309 | display: flex; 310 | } 311 | 312 | .navbar-a57cc a { 313 | color: #444; 314 | display: block; 315 | flex: 1; 316 | font-size: 18px; 317 | padding: 20px 0; 318 | text-align: center; 319 | text-decoration: none; 320 | } 321 | 322 | .navbar-a57cc .piece { 323 | visibility: hidden; 324 | } 325 | 326 | .hover-effect a:hover .piece { 327 | visibility: visible; 328 | } 329 | 330 | .col-11bcf { 331 | flex: 1; 332 | padding: 40px; 333 | } 334 | 335 | /*------------------------------------------------------------------------------ 336 | * Examples 337 | *----------------------------------------------------------------------------*/ 338 | 339 | main { 340 | background: #f2f2f2; 341 | } 342 | 343 | .examples-c30bc { 344 | background: #fff; 345 | } 346 | 347 | .example-nav-0e953 { 348 | flex: 25; 349 | padding: 20px; 350 | } 351 | 352 | .examples-body-9af4d { 353 | flex: 75; 354 | padding: 20px; 355 | } 356 | 357 | .example-nav-0e953 h4 { 358 | background: #f2f2f2; 359 | border-top: 1px solid #e6e6e6; 360 | border-right: 1px solid #e6e6e6; 361 | border-left: 3px solid #ccc; 362 | color: #555; 363 | cursor: pointer; 364 | font-size: 14px; 365 | font-weight: normal; 366 | margin: 0px; 367 | padding: 15px 20px; 368 | text-transform: none; 369 | } 370 | 371 | .example-nav-0e953 h4.active { 372 | background: #4d4d4d; 373 | border-top: 1px solid #1a1a1a; 374 | border-right: 1px solid #1a1a1a; 375 | border-left: 4px solid #1a1a1a; 376 | color: #fff; 377 | font-weight: bold; 378 | } 379 | 380 | .example-nav-0e953 ul { 381 | border-left: 3px solid #eee; 382 | border-right: 1px solid #eee; 383 | margin: 0; 384 | padding: 10px 0px; 385 | } 386 | 387 | .example-nav-0e953 li { 388 | color: #666; 389 | cursor: pointer; 390 | font-size: 14px; 391 | line-height: 1.6; 392 | list-style: none; 393 | padding: 5px 0px 5px 15px; 394 | } 395 | 396 | .example-nav-0e953 li:hover { 397 | color: #222; 398 | } 399 | 400 | .example-nav-0e953 li.active { 401 | color: #222; 402 | font-weight: bold; 403 | } 404 | 405 | .examples-body-9af4d h2 { 406 | border-bottom: 2px solid #eee; 407 | font-size: 36px; 408 | margin: 0 0 8px 0; 409 | padding-bottom: 8px; 410 | } 411 | 412 | .examples-body-9af4d h4 { 413 | font-size: 16px; 414 | } 415 | 416 | .examples-body-9af4d p { 417 | line-height: 1.6; 418 | font-size: 16px; 419 | margin-bottom: 20px; 420 | } 421 | 422 | .examples-body-9af4d button { 423 | background: #2ba6cb; 424 | border-radius: 3px; 425 | border: 1px solid #1e728c; 426 | color: #fff; 427 | cursor: pointer; 428 | display: inline-block; 429 | font-size: 14px; 430 | font-weight: 600; 431 | margin: 15px 5px 0 0; 432 | outline: none; 433 | padding: 10px 15px; 434 | text-align: center; 435 | text-decoration: none; 436 | } 437 | 438 | .examples-body-9af4d label { 439 | display: block; 440 | font-weight: 600; 441 | margin: 10px 0 2px 0; 442 | } 443 | 444 | .container-4e1ee { 445 | margin-bottom: 40px; 446 | } 447 | 448 | .small-link-335ea { 449 | font-size: 14px; 450 | } 451 | 452 | .small-board { 453 | display: inline-block; 454 | margin-right: 5px; 455 | width: 200px; 456 | } 457 | 458 | /*------------------------------------------------------------------------------ 459 | * Tables 460 | *----------------------------------------------------------------------------*/ 461 | 462 | .table-bc66e { 463 | background: #fff; 464 | border: 1px solid #ddd; 465 | margin: 0 0 18px 0; 466 | } 467 | 468 | .table-bc66e thead { 469 | background: #f5f5f5; 470 | } 471 | 472 | .table-bc66e thead th { 473 | color: #222; 474 | font-size: 14px; 475 | font-weight: bold; 476 | padding: 8px 10px 9px; 477 | text-align: left; 478 | } 479 | 480 | .table-bc66e tbody tr:nth-child(even) { 481 | background: #f9f9f9; 482 | } 483 | 484 | .table-bc66e tbody td { 485 | border: none; 486 | color: #333; 487 | padding: 9px 10px; 488 | vertical-align: top; 489 | } 490 | 491 | .property-type-7ae66 { 492 | line-height: 22px; 493 | } 494 | 495 | /*------------------------------------------------------------------------------ 496 | * Docs Page 497 | *----------------------------------------------------------------------------*/ 498 | 499 | .title-5ad05 { 500 | border-bottom: 2px solid #eee; 501 | font-size: 36px; 502 | font-weight: 300; 503 | margin: 0; 504 | padding-bottom: 12px; 505 | } 506 | 507 | .toc-list-38a45 { 508 | color: #aaa; 509 | list-style-type: square; 510 | margin: 30px 0 0 0; 511 | padding: 0 0 0 20px; 512 | } 513 | 514 | .toc-list-38a45 li { 515 | margin: 14px 0; 516 | } 517 | 518 | .page-529b3 { 519 | background: #fff; 520 | padding: 20px; 521 | } 522 | 523 | .page-529b3 section { 524 | border-bottom: 1px solid #ddd; 525 | padding-bottom: 30px; 526 | margin-bottom: 30px; 527 | } 528 | 529 | .page-529b3 section:last-child { 530 | border-bottom: 0; 531 | } 532 | 533 | /*------------------------------------------------------------------------------ 534 | * Downloads Page 535 | *----------------------------------------------------------------------------*/ 536 | 537 | .big-version { 538 | color: #000; 539 | font-size: 24px; 540 | } 541 | 542 | .big-version small { 543 | color: #6f6f6f; 544 | font-size: 60%; 545 | } 546 | 547 | .download-link { 548 | margin: 0; 549 | padding: 0; 550 | } 551 | 552 | /*------------------------------------------------------------------------------ 553 | * prettyPrint 554 | *----------------------------------------------------------------------------*/ 555 | 556 | .pln { 557 | color: #c5c8c6; 558 | } 559 | 560 | @media screen { 561 | .str { 562 | color: #b5bd68; 563 | } 564 | .kwd { 565 | color: #b294bb; 566 | } 567 | .com { 568 | color: #969896; 569 | } 570 | .typ { 571 | color: #81a2be; 572 | } 573 | .lit { 574 | color: #de935f; 575 | } 576 | .pun { 577 | color: #c5c8c6; 578 | } 579 | .opn { 580 | color: #c5c8c6; 581 | } 582 | .clo { 583 | color: #c5c8c6; 584 | } 585 | .tag { 586 | color: #cc6666; 587 | } 588 | .atn { 589 | color: #de935f; 590 | } 591 | .atv { 592 | color: #8abeb7; 593 | } 594 | .dec { 595 | color: #de935f; 596 | } 597 | .var { 598 | color: #cc6666; 599 | } 600 | .fun { 601 | color: #81a2be; 602 | } 603 | } 604 | @media print,projection { 605 | .str { 606 | color: #060; 607 | } 608 | .kwd { 609 | color: #006; 610 | font-weight: bold; 611 | } 612 | .com { 613 | color: #600; 614 | font-style: italic; 615 | } 616 | .typ { 617 | color: #404; 618 | font-weight: bold; 619 | } 620 | .lit { 621 | color: #044; 622 | } 623 | .pun, 624 | .opn, 625 | .clo { 626 | color: #440; 627 | } 628 | .tag { 629 | color: #006; 630 | font-weight: bold; 631 | } 632 | .atn { 633 | color: #404; 634 | } 635 | .atv { 636 | color: #060; 637 | } 638 | } 639 | 640 | pre.prettyprint { 641 | background: #1d1f21; 642 | font-family: 'Roboto Mono', Consolas, monospace; 643 | font-size: 14px; 644 | line-height: 1.5; 645 | border: 1px solid #ccc; 646 | padding: 10px; 647 | } 648 | 649 | ol.linenums { 650 | margin-top: 0; 651 | margin-bottom: 0; 652 | } 653 | 654 | code { 655 | font-family: 'Roboto Mono', Consolas, monospace; 656 | font-size: 14px; 657 | } 658 | 659 | code.string { 660 | color: blue; 661 | } 662 | 663 | code.keyword { 664 | color: #0066cc; 665 | } 666 | 667 | code.plain { 668 | color: #d94d3a; 669 | text-decoration-color: #d94d3a; 670 | } 671 | -------------------------------------------------------------------------------- /website/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/favicon.ico -------------------------------------------------------------------------------- /website/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /website/img/board-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/board-background.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bB.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bK.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bN.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bP.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/bR.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wB.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wK.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wN.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wP.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/alpha/wR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/alpha/wR.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bB.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bK.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bN.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bP.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/bR.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wB.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wK.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wN.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wP.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/uscf/wR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/uscf/wR.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bB.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bK.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bK.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bN.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bP.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/bR.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wB.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wK.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wN.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wP.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wQ.png -------------------------------------------------------------------------------- /website/img/chesspieces/wikipedia/wR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/chesspieces/wikipedia/wR.png -------------------------------------------------------------------------------- /website/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/favicon.ico -------------------------------------------------------------------------------- /website/img/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /website/img/satinweave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/img/satinweave.png -------------------------------------------------------------------------------- /website/js/chess-0.10.2.min.js: -------------------------------------------------------------------------------- 1 | /* @license 2 | * Copyright (c) 2016, Jeff Hlywa (jhlywa@gmail.com) 3 | * Released under the BSD license 4 | * https://github.com/jhlywa/chess.js/blob/master/LICENSE 5 | */ 6 | var Chess=function(r){var e="b",n="w",t=-1,o="p",i="n",f="b",a="r",u="q",l="k",s="pnbrqkPNBRQK",p="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",c=["1-0","0-1","1/2-1/2","*"],v={b:[16,32,17,15],w:[-16,-32,-17,-15]},g={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},h=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],E=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],d={p:0,n:1,b:2,r:3,q:4,k:5},b={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q"},_={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64},A=7,S=6,m=1,C=0,y={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},T={w:[{square:y.a1,flag:_.QSIDE_CASTLE},{square:y.h1,flag:_.KSIDE_CASTLE}],b:[{square:y.a8,flag:_.QSIDE_CASTLE},{square:y.h8,flag:_.KSIDE_CASTLE}]},I=new Array(128),P={w:t,b:t},w=n,L={w:0,b:0},R=t,N=0,O=1,k=[],q={};function D(){I=new Array(128),P={w:t,b:t},w=n,L={w:0,b:0},R=t,N=0,O=1,k=[],q={},j(x())}function K(){Q(p)}function Q(r){var o=r.split(/\s+/),i=o[0],f=0;if(!U(r).valid)return!1;D();for(var a=0;a-1&&(L.w|=_.KSIDE_CASTLE),o[2].indexOf("Q")>-1&&(L.w|=_.QSIDE_CASTLE),o[2].indexOf("k")>-1&&(L.b|=_.KSIDE_CASTLE),o[2].indexOf("q")>-1&&(L.b|=_.QSIDE_CASTLE),R="-"===o[3]?t:y[o[3]],N=parseInt(o[4],10),O=parseInt(o[5],10),j(x()),!0}function U(r){var e="No errors.",n="FEN string must contain six space-delimited fields.",t="6th field (move number) must be a positive integer.",o="5th field (half move counter) must be a non-negative integer.",i="4th field (en-passant square) is invalid.",f="3rd field (castling availability) is invalid.",a="2nd field (side to move) is invalid.",u="1st field (piece positions) does not contain 8 '/'-delimited rows.",l="1st field (piece positions) is invalid [consecutive numbers].",s="1st field (piece positions) is invalid [invalid piece].",p="1st field (piece positions) is invalid [row too large].",c="Illegal en-passant square",v=r.split(/\s+/);if(6!==v.length)return{valid:!1,error_number:1,error:n};if(isNaN(v[5])||parseInt(v[5],10)<=0)return{valid:!1,error_number:2,error:t};if(isNaN(v[4])||parseInt(v[4],10)<0)return{valid:!1,error_number:3,error:o};if(!/^(-|[abcdefgh][36])$/.test(v[3]))return{valid:!1,error_number:4,error:i};if(!/^(KQ?k?q?|Qk?q?|kq?|q|-)$/.test(v[2]))return{valid:!1,error_number:5,error:f};if(!/^(w|b)$/.test(v[1]))return{valid:!1,error_number:6,error:a};var g=v[0].split("/");if(8!==g.length)return{valid:!1,error_number:7,error:u};for(var h=0;h0&&(o+=r,r=0);var f=I[i].color,a=I[i].type;o+=f===n?a.toUpperCase():a.toLowerCase()}i+1&136&&(r>0&&(o+=r),i!==y.h1&&(o+="/"),r=0,i+=8)}var u="";L[n]&_.KSIDE_CASTLE&&(u+="K"),L[n]&_.QSIDE_CASTLE&&(u+="Q"),L[e]&_.KSIDE_CASTLE&&(u+="k"),L[e]&_.QSIDE_CASTLE&&(u+="q"),u=u||"-";var l=R===t?"-":fr(R);return[o,w,u,l,N,O].join(" ")}function $(r){for(var e=0;e0||(r!==p?(q.SetUp="1",q.FEN=r):(delete q.SetUp,delete q.FEN))}function B(r){var e=I[y[r]];return e?{type:e.type,color:e.color}:null}function M(r,e){if(!("type"in r&&"color"in r))return!1;if(-1===s.indexOf(r.type.toLowerCase()))return!1;if(!(e in y))return!1;var n=y[e];return(r.type!=l||P[r.color]==t||P[r.color]==n)&&(I[n]={type:r.type,color:r.color},r.type===l&&(P[r.color]=n),j(x()),!0)}function G(r,e,n,t,i){var f={color:w,from:e,to:n,flags:t,piece:r[e].type};return i&&(f.flags|=_.PROMOTION,f.promotion=i),r[n]?f.captured=r[n].type:t&_.EP_CAPTURE&&(f.captured=o),f}function F(r){function e(r,e,n,t,l){if(r[n].type!==o||or(t)!==C&&or(t)!==A)e.push(G(r,n,t,l));else for(var s=[u,a,f,i],p=0,c=s.length;p0)return a>0&&u>0?fr(t):u>0?fr(t).charAt(1):fr(t).charAt(0);return""}(r,e);r.piece!==o&&(n+=r.piece.toUpperCase()+t),r.flags&(_.CAPTURE|_.EP_CAPTURE)&&(r.piece===o&&(n+=fr(r.from)[0]),n+="x"),n+=fr(r.to),r.flags&_.PROMOTION&&(n+="="+r.promotion.toUpperCase())}return er(r),J()&&(V()?n+="#":n+="+"),nr(),n}function H(r){return r.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}function Z(r,t){for(var i=y.a8;i<=y.h1;i++)if(136&i)i+=7;else if(null!=I[i]&&I[i].color===r){var f=I[i],a=i-t,u=a+119;if(h[u]&1<0){if(f.color===n)return!0}else if(f.color===e)return!0;continue}if("n"===f.type||"k"===f.type)return!0;for(var l=E[u],s=i+l,p=!1;s!==t;){if(null!=I[s]){p=!0;break}s+=l}if(!p)return!0}}return!1}function z(r){return Z(ar(r),P[r])}function J(){return z(w)}function V(){return J()&&0===F().length}function X(){return!J()&&0===F().length}function Y(){for(var r={},e=[],n=0,t=0,o=y.a8;o<=y.h1;o++)if(t=(t+1)%2,136&o)o+=7;else{var a=I[o];a&&(r[a.type]=a.type in r?r[a.type]+1:1,a.type===f&&e.push(t),n++)}if(2===n)return!0;if(3===n&&(1===r[f]||1===r[i]))return!0;if(n===r[f]+2){var u=0,l=e.length;for(o=0;o=3&&(n=!0),!r.length)break;er(r.pop())}return n}function er(r){var n=w,i=ar(n);if(function(r){k.push({move:r,kings:{b:P.b,w:P.w},turn:w,castling:{b:L.b,w:L.w},ep_square:R,half_moves:N,move_number:O})}(r),I[r.to]=I[r.from],I[r.from]=null,r.flags&_.EP_CAPTURE&&(w===e?I[r.to-16]=null:I[r.to+16]=null),r.flags&_.PROMOTION&&(I[r.to]={type:r.promotion,color:n}),I[r.to].type===l){if(P[I[r.to].color]=r.to,r.flags&_.KSIDE_CASTLE){var f=r.to-1,a=r.to+1;I[f]=I[a],I[a]=null}else if(r.flags&_.QSIDE_CASTLE){f=r.to+1,a=r.to-2;I[f]=I[a],I[a]=null}L[n]=""}if(L[n])for(var u=0,s=T[n].length;u>4}function ir(r){return 15&r}function fr(r){var e=ir(r),n=or(r);return"abcdefgh".substring(e,e+1)+"87654321".substring(n,n+1)}function ar(r){return r===n?e:n}function ur(r){var e=function r(e){var n=e instanceof Array?[]:{};for(var t in e)n[t]="object"==typeof t?r(e[t]):e[t];return n}(r);e.san=W(e,!1),e.to=fr(e.to),e.from=fr(e.from);var n="";for(var t in _)_[t]&e.flags&&(n+=b[t]);return e.flags=n,e}function lr(r){return r.replace(/^\s+|\s+$/g,"")}return Q(void 0===r?p:r),{WHITE:n,BLACK:e,PAWN:o,KNIGHT:i,BISHOP:f,ROOK:a,QUEEN:u,KING:l,SQUARES:function(){for(var r=[],e=y.a8;e<=y.h1;e++)136&e?e+=7:r.push(fr(e));return r}(),FLAGS:b,load:function(r){return Q(r)},reset:function(){return K()},moves:function(r){for(var e=F(r),n=[],t=0,o=e.length;t=100||X()||Y()||rr()},insufficient_material:function(){return Y()},in_threefold_repetition:function(){return rr()},game_over:function(){return N>=100||V()||X()||Y()||rr()},validate_fen:function(r){return U(r)},fen:function(){return x()},pgn:function(r){var e="object"==typeof r&&"string"==typeof r.newline_char?r.newline_char:"\n",n="object"==typeof r&&"number"==typeof r.max_width?r.max_width:0,t=[],o=!1;for(var i in q)t.push("["+i+' "'+q[i]+'"]'+e),o=!0;o&&k.length&&t.push(e);for(var f=[];k.length>0;)f.push(nr());for(var a=[],u="";f.length>0;){var l=f.pop();k.length||"b"!==l.color?"w"===l.color&&(u.length&&a.push(u),u=O+"."):u=O+". ...",u=u+" "+W(l,!1),er(l)}if(u.length&&a.push(u),void 0!==q.Result&&a.push(q.Result),0===n)return t.join("")+a.join(" ");var s=0;for(i=0;in&&0!==i?(" "===t[t.length-1]&&t.pop(),t.push(e),s=0):0!==i&&(t.push(" "),s++),t.push(a[i]),s+=a[i].length;return t.join("")},load_pgn:function(r,e){var n=void 0!==e&&"sloppy"in e&&e.sloppy;function t(r){return r.replace(/\\/g,"\\")}var o="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",i=new RegExp("^(\\[(.|"+t(o)+")*\\])("+t(o)+")*1.("+t(o)+"|.)*$","g"),f=r.replace(i,"$1");"["!==f[0]&&(f=""),K();var a=function(r,e){for(var n="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",o={},i=r.split(new RegExp(t(n))),f="",a="",u=0;u0&&(o[f]=a);return o}(f,e);for(var u in a)$([u,a[u]]);if("1"===a.SetUp&&!("FEN"in a&&Q(a.FEN)))return!1;var l=r.replace(f,"").replace(new RegExp(t(o),"g")," ");l=l.replace(/(\{[^}]+\})+?/g,"");for(var s=/(\([^\(\)]+\))+?/g;s.test(l);)l=l.replace(s,"");var p=lr(l=(l=(l=l.replace(/\d+\.(\.\.)?/g,"")).replace(/\.\.\./g,"")).replace(/\$\d+/g,"")).split(new RegExp(/\s+/));p=p.join(",").replace(/,,+/g,",").split(",");for(var v="",g=0;g-1)(function(r){for(var e in r)return!0;return!1})(q)&&void 0===q.Result&&$(["Result",v]);else{if(null==(v=tr(v,n)))return!1;er(v)}return!0},header:function(){return $(arguments)},ascii:function(){return function(){for(var r=" +------------------------+\n",e=y.a8;e<=y.h1;e++){if(0===ir(e)&&(r+=" "+"87654321"[or(e)]+" |"),null==I[e])r+=" . ";else{var t=I[e].type;r+=" "+(I[e].color===n?t.toUpperCase():t.toLowerCase())+" "}e+1&136&&(r+="|\n",e+=8)}return r+=" +------------------------+\n",r+=" a b c d e f g h\n"}()},turn:function(){return w},move:function(r,e){var n=void 0!==e&&"sloppy"in e&&e.sloppy,t=null;if("string"==typeof r)t=tr(r,n);else if("object"==typeof r)for(var o=F(),i=0,f=o.length;i0?t+=r(e-1):t++),nr();return t}(r)},square_color:function(r){if(r in y){var e=y[r];return(or(e)+ir(e))%2==0?"light":"dark"}return null},history:function(r){for(var e=[],n=[],t=(void 0!==r&&"verbose"in r&&r.verbose);k.length>0;)e.push(nr());for(;e.length>0;){var o=e.pop();t?n.push(ur(o)):n.push(W(o)),er(o)}return n}}};"undefined"!=typeof exports&&(exports.Chess=Chess),"undefined"!=typeof define&&define(function(){return Chess}); 7 | -------------------------------------------------------------------------------- /website/js/examples.js: -------------------------------------------------------------------------------- 1 | ;(function () { 2 | var $ = window.jQuery 3 | var EXAMPLES = window.CHESSBOARD_EXAMPLES 4 | var prettyPrint = window.prettyPrint 5 | 6 | function htmlEscape (str) { 7 | return (str + '') 8 | .replace(/&/g, '&') 9 | .replace(//g, '>') 11 | .replace(/"/g, '"') 12 | .replace(/'/g, ''') 13 | .replace(/\//g, '/') 14 | .replace(/`/g, '`') 15 | } 16 | 17 | function highlightGroupHeader (groupIdx) { 18 | $('#examplesNav h4').removeClass('active') 19 | $('#groupHeader-' + groupIdx).addClass('active') 20 | } 21 | 22 | function highlightExampleLink (exampleId) { 23 | $('#examplesNav li').removeClass('active') 24 | $('#exampleLink-' + exampleId).addClass('active') 25 | } 26 | 27 | function buildExampleBodyHTML (example, id) { 28 | var html = '

' + 29 | '' + 30 | htmlEscape(example.name) + 31 | '

' + 32 | '

' + example.description + '

' + 33 | '
' + example.html + '
' + 34 | '

JavaScript

' + 35 | '
' + htmlEscape(example.jsStr) + '
' + 36 | '

HTML

' + 37 | '
' + htmlEscape(example.html) + '
' + 38 | '

View this example in new window.

' 39 | 40 | return html 41 | } 42 | 43 | function showExample (exampleId) { 44 | var groupIdx = $('#exampleLink-' + exampleId).parent('ul').attr('id').replace('groupContainer-', '') 45 | 46 | $('#groupContainer-' + groupIdx).css('display', '') 47 | highlightGroupHeader(groupIdx) 48 | highlightExampleLink(exampleId) 49 | 50 | $('#exampleBodyContainer').html(buildExampleBodyHTML(EXAMPLES[exampleId], exampleId)) 51 | EXAMPLES[exampleId].jsFn() 52 | 53 | prettyPrint() 54 | } 55 | 56 | function clickExampleNavLink () { 57 | var exampleId = $(this).attr('id').replace('exampleLink-', '') 58 | if (!EXAMPLES.hasOwnProperty(exampleId)) return 59 | 60 | window.location.hash = exampleId 61 | loadExampleFromHash() 62 | } 63 | 64 | function loadExampleFromHash () { 65 | var exampleId = parseInt(window.location.hash.replace('#', ''), 10) 66 | if (!EXAMPLES.hasOwnProperty(exampleId)) { 67 | exampleId = 1000 68 | window.location.hash = exampleId 69 | } 70 | showExample(exampleId) 71 | } 72 | 73 | function clickGroupHeader () { 74 | var groupIdx = $(this).attr('id').replace('groupHeader-', '') 75 | var $examplesList = $('#groupContainer-' + groupIdx) 76 | if ($examplesList.css('display') === 'none') { 77 | $examplesList.slideDown('fast') 78 | } else { 79 | $examplesList.slideUp('fast') 80 | } 81 | } 82 | 83 | function init () { 84 | $('#examplesNav').on('click', 'li', clickExampleNavLink) 85 | $('#examplesNav').on('click', 'h4', clickGroupHeader) 86 | loadExampleFromHash() 87 | } 88 | 89 | $(document).ready(init) 90 | })() 91 | -------------------------------------------------------------------------------- /website/js/jquery.color-2.1.2.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery Color v@2.1.2 http://github.com/jquery/jquery-color | jquery.org/license */ 2 | (function(a,b){function m(a,b,c){var d=h[b.type]||{};return a==null?c||!b.def?null:b.def:(a=d.floor?~~a:parseFloat(a),isNaN(a)?b.def:d.mod?(a+d.mod)%d.mod:0>a?0:d.max")[0],k,l=a.each;j.style.cssText="background-color:rgba(1,1,1,.5)",i.rgba=j.style.backgroundColor.indexOf("rgba")>-1,l(g,function(a,b){b.cache="_"+a,b.props.alpha={idx:3,type:"percent",def:1}}),f.fn=a.extend(f.prototype,{parse:function(c,d,e,h){if(c===b)return this._rgba=[null,null,null,null],this;if(c.jquery||c.nodeType)c=a(c).css(d),d=b;var i=this,j=a.type(c),o=this._rgba=[];d!==b&&(c=[c,d,e,h],j="array");if(j==="string")return this.parse(n(c)||k._default);if(j==="array")return l(g.rgba.props,function(a,b){o[b.idx]=m(c[b.idx],b)}),this;if(j==="object")return c instanceof f?l(g,function(a,b){c[b.cache]&&(i[b.cache]=c[b.cache].slice())}):l(g,function(b,d){var e=d.cache;l(d.props,function(a,b){if(!i[e]&&d.to){if(a==="alpha"||c[a]==null)return;i[e]=d.to(i._rgba)}i[e][b.idx]=m(c[a],b,!0)}),i[e]&&a.inArray(null,i[e].slice(0,3))<0&&(i[e][3]=1,d.from&&(i._rgba=d.from(i[e])))}),this},is:function(a){var b=f(a),c=!0,d=this;return l(g,function(a,e){var f,g=b[e.cache];return g&&(f=d[e.cache]||e.to&&e.to(d._rgba)||[],l(e.props,function(a,b){if(g[b.idx]!=null)return c=g[b.idx]===f[b.idx],c})),c}),c},_space:function(){var a=[],b=this;return l(g,function(c,d){b[d.cache]&&a.push(c)}),a.pop()},transition:function(a,b){var c=f(a),d=c._space(),e=g[d],i=this.alpha()===0?f("transparent"):this,j=i[e.cache]||e.to(i._rgba),k=j.slice();return c=c[e.cache],l(e.props,function(a,d){var e=d.idx,f=j[e],g=c[e],i=h[d.type]||{};if(g===null)return;f===null?k[e]=g:(i.mod&&(g-f>i.mod/2?f+=i.mod:f-g>i.mod/2&&(f-=i.mod)),k[e]=m((g-f)*b+f,d))}),this[d](k)},blend:function(b){if(this._rgba[3]===1)return this;var c=this._rgba.slice(),d=c.pop(),e=f(b)._rgba;return f(a.map(c,function(a,b){return(1-d)*e[b]+d*a}))},toRgbaString:function(){var b="rgba(",c=a.map(this._rgba,function(a,b){return a==null?b>2?1:0:a});return c[3]===1&&(c.pop(),b="rgb("),b+c.join()+")"},toHslaString:function(){var b="hsla(",c=a.map(this.hsla(),function(a,b){return a==null&&(a=b>2?1:0),b&&b<3&&(a=Math.round(a*100)+"%"),a});return c[3]===1&&(c.pop(),b="hsl("),b+c.join()+")"},toHexString:function(b){var c=this._rgba.slice(),d=c.pop();return b&&c.push(~~(d*255)),"#"+a.map(c,function(a){return a=(a||0).toString(16),a.length===1?"0"+a:a}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}}),f.fn.parse.prototype=f.fn,g.hsla.to=function(a){if(a[0]==null||a[1]==null||a[2]==null)return[null,null,null,a[3]];var b=a[0]/255,c=a[1]/255,d=a[2]/255,e=a[3],f=Math.max(b,c,d),g=Math.min(b,c,d),h=f-g,i=f+g,j=i*.5,k,l;return g===f?k=0:b===f?k=60*(c-d)/h+360:c===f?k=60*(d-b)/h+120:k=60*(b-c)/h+240,h===0?l=0:j<=.5?l=h/i:l=h/(2-i),[Math.round(k)%360,l,j,e==null?1:e]},g.hsla.from=function(a){if(a[0]==null||a[1]==null||a[2]==null)return[null,null,null,a[3]];var b=a[0]/360,c=a[1],d=a[2],e=a[3],f=d<=.5?d*(1+c):d+c-d*c,g=2*d-f;return[Math.round(o(g,f,b+1/3)*255),Math.round(o(g,f,b)*255),Math.round(o(g,f,b-1/3)*255),e]},l(g,function(c,e){var g=e.props,h=e.cache,i=e.to,j=e.from;f.fn[c]=function(c){i&&!this[h]&&(this[h]=i(this._rgba));if(c===b)return this[h].slice();var d,e=a.type(c),k=e==="array"||e==="object"?c:arguments,n=this[h].slice();return l(g,function(a,b){var c=k[e==="object"?a:b.idx];c==null&&(c=n[b.idx]),n[b.idx]=m(c,b)}),j?(d=f(j(n)),d[h]=n,d):f(n)},l(g,function(b,e){if(f.fn[b])return;f.fn[b]=function(f){var g=a.type(f),h=b==="alpha"?this._hsla?"hsla":"rgba":c,i=this[h](),j=i[e.idx],k;return g==="undefined"?j:(g==="function"&&(f=f.call(this,j),g=a.type(f)),f==null&&e.empty?this:(g==="string"&&(k=d.exec(f),k&&(f=j+parseFloat(k[2])*(k[1]==="+"?1:-1))),i[e.idx]=f,this[h](i)))}})}),f.hook=function(b){var c=b.split(" ");l(c,function(b,c){a.cssHooks[c]={set:function(b,d){var e,g,h="";if(d!=="transparent"&&(a.type(d)!=="string"||(e=n(d)))){d=f(e||d);if(!i.rgba&&d._rgba[3]!==1){g=c==="backgroundColor"?b.parentNode:b;while((h===""||h==="transparent")&&g&&g.style)try{h=a.css(g,"backgroundColor"),g=g.parentNode}catch(j){}d=d.blend(h&&h!=="transparent"?h:"_default")}d=d.toRgbaString()}try{b.style[c]=d}catch(j){}}},a.fx.step[c]=function(b){b.colorInit||(b.start=f(b.elem,c),b.end=f(b.end),b.colorInit=!0),a.cssHooks[c].set(b.elem,b.start.transition(b.end,b.pos))}})},f.hook(c),a.cssHooks.borderColor={expand:function(a){var b={};return l(["Top","Right","Bottom","Left"],function(c,d){b["border"+d+"Color"]=a}),b}},k=a.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}})(jQuery); -------------------------------------------------------------------------------- /website/js/prettify.min.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}pg.length)return!1;for(var b=0;8>b;b++)if(""===g[b]||8f;f++){for(var l=g[f].split(""),m=0,p=0;pf;f++){for(var l=0;8>l;l++){var m=x[l]+r;!0===g.hasOwnProperty(m)?(m=g[m].split(""),m="w"===m[0]?m[1].toUpperCase():m[1].toLowerCase(),b+= 4 | m):b+="1"}7!==f&&(b+="/");r--}b=b.replace(/11111111/g,"8");b=b.replace(/1111111/g,"7");b=b.replace(/111111/g,"6");b=b.replace(/11111/g,"5");b=b.replace(/1111/g,"4");b=b.replace(/111/g,"3");return b=b.replace(/11/g,"2")};window.ChessBoard=window.ChessBoard||function(g,b){b=b||{};var r=I("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"),f={alpha:"alpha-d2270",black:"black-3c85d",board:"board-b72b1",chessboard:"chessboard-63f37",clearfix:"clearfix-7da63",highlight1:"highlight1-32417",highlight2:"highlight2-9c5d2", 5 | notation:"notation-322f9",numeric:"numeric-fc462",piece:"piece-417db",row:"row-5277c",sparePieces:"spare-pieces-7492f",sparePiecesBottom:"spare-pieces-bottom-ae20f",sparePiecesTop:"spare-pieces-top-4028b",square:"square-55d63",white:"white-1e1d7"},l,m,p,Q,E,h={},V=2,w="white",n={},q,A,B,v,y=!1,K={},s={},F,C=function(){return"xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx".replace(/x/g,function(a){return(16*Math.random()|0).toString(16)})},t=function(a){return JSON.parse(JSON.stringify(a))},W=function(a){a= 6 | a.split(".");return{major:parseInt(a[0],10),minor:parseInt(a[1],10),patch:parseInt(a[2],10)}},G=function(a,e,c){if(!0===b.hasOwnProperty("showErrors")&&!1!==b.showErrors){var d="ChessBoard Error "+a+": "+e;"console"===b.showErrors&&"object"===typeof console&&"function"===typeof console.log?(console.log(d),2<=arguments.length&&console.log(c)):"alert"===b.showErrors?(c&&(d+="\n\n"+JSON.stringify(c)),window.alert(d)):"function"===typeof b.showErrors&&b.showErrors(a,e,c)}},L=function(a){return"fast"=== 7 | a||"slow"===a?!0:parseInt(a,10)+""!==a+""?!1:0=b;b++){var c=x[a]+b;s[c]=c+"-"+C()}b="KQRBNP".split("");for(a=0;a';!0===b.sparePieces&&(a+='
');a+='
';!0===b.sparePieces&&(a+='
'); 8 | return a+""},fa=function(a){"black"!==a&&(a="white");var e="",c=t(x),d=8;"black"===a&&(c.reverse(),d=1);for(var g="white",h=0;8>h;h++){for(var e=e+('
'),k=0;8>k;k++){var l=c[k]+d,e=e+('
');if(!0===b.showNotation){if("white"===a&&1===d||"black"===a&&8===d)e+='
'+c[k]+"
";0===k&&(e+='
'+d+"
")}e+="
";g="white"===g?"black":"white"}e+='
';g="white"===g?"black":"white";"white"===a?d--:d++}return e},X=function(a){if("function"===typeof b.pieceTheme)return b.pieceTheme(a);if("string"===typeof b.pieceTheme)return b.pieceTheme.replace(/{piece}/g,a);G(8272,"Unable to build image source for cfg.pieceTheme.")},z=function(a,b,c){var d=''},M=function(a){var b="wK wQ wR wB wN wP".split(" ");"black"===a&&(b="bK bQ bR bB bN bP".split(" "));a="";for(var c=0;c=d?c:d}, 13 | ka=function(a){for(var b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var f=x[c]+(d+1);a!==f&&b.push({square:f,distance:ja(a,f)})}b.sort(function(a,b){return a.distance-b.distance});a=[];for(c=0;c=d.left&&a=d.top&&b=a)q=0;else{for(a-=1;0!==a%8&&0=1E8*b.major+1E4*b.minor+b.patch;return a?!0:(window.alert("ChessBoard Error 1005: Unable to find a valid version of jQuery. Please include jQuery 1.7.0 or higher on the page.\n\nExiting..."), 27 | !1)}()){if("string"===typeof b||!0===H(b))b={position:b};"black"!==b.orientation&&(b.orientation="white");w=b.orientation;!1!==b.showNotation&&(b.showNotation=!0);!0!==b.draggable&&(b.draggable=!1);"trash"!==b.dropOffBoard&&(b.dropOffBoard="snapback");!0!==b.sparePieces&&(b.sparePieces=!1);!0===b.sparePieces&&(b.draggable=!0);if(!0!==b.hasOwnProperty("pieceTheme")||"string"!==typeof b.pieceTheme&&"function"!==typeof b.pieceTheme)b.pieceTheme="img/chesspieces/wikipedia/{piece}.png";if(!0!==b.hasOwnProperty("moveSpeed")|| 28 | !0!==L(b.moveSpeed))b.moveSpeed=200;if(!0!==b.hasOwnProperty("snapbackSpeed")||!0!==L(b.snapbackSpeed))b.snapbackSpeed=50;if(!0!==b.hasOwnProperty("snapSpeed")||!0!==L(b.snapSpeed))b.snapSpeed=25;if(!0!==b.hasOwnProperty("trashSpeed")||!0!==L(b.trashSpeed))b.trashSpeed=100;!0===b.hasOwnProperty("position")&&("start"===b.position?n=t(r):!0===P(b.position)?n=I(b.position):!0===H(b.position)?n=t(b.position):G(7263,"Invalid value passed to config.position.",b.position));U=!0}U&&(da(),va(),ua());return h}; 29 | window.ChessBoard.fenToObj=I;window.ChessBoard.objToFen=J})(); -------------------------------------------------------------------------------- /website/releases/0.2.0/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2013 Chris Oakman 2 | http://chessboardjs.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /website/releases/0.2.0/chessboardjs-0.2.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/chessboardjs-0.2.0.zip -------------------------------------------------------------------------------- /website/releases/0.2.0/css/chessboard-0.2.0.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * ChessBoardJS v0.2.0 3 | * 4 | * Copyright 2013 Chris Oakman 5 | * Released under the MIT license 6 | * https://github.com/oakmac/chessboardjs/blob/master/LICENSE 7 | * 8 | * Date: 05 Aug 2013 9 | */ 10 | 11 | /* clearfix */ 12 | .clearfix-7da63 { 13 | clear: both; 14 | } 15 | 16 | /* board */ 17 | .board-b72b1 { 18 | border: 2px solid #404040; 19 | -moz-box-sizing: content-box; 20 | box-sizing: content-box; 21 | } 22 | 23 | /* square */ 24 | .square-55d63 { 25 | float: left; 26 | position: relative; 27 | 28 | /* disable any native browser highlighting */ 29 | -webkit-touch-callout: none; 30 | -webkit-user-select: none; 31 | -khtml-user-select: none; 32 | -moz-user-select: none; 33 | -ms-user-select: none; 34 | user-select: none; 35 | } 36 | 37 | /* white square */ 38 | .white-1e1d7 { 39 | background-color: #f0d9b5; 40 | color: #b58863; 41 | } 42 | 43 | /* black square */ 44 | .black-3c85d { 45 | background-color: #b58863; 46 | color: #f0d9b5; 47 | } 48 | 49 | /* highlighted square */ 50 | .highlight1-32417, .highlight2-9c5d2 { 51 | -webkit-box-shadow: inset 0 0 3px 3px yellow; 52 | -moz-box-shadow: inset 0 0 3px 3px yellow; 53 | box-shadow: inset 0 0 3px 3px yellow; 54 | } 55 | 56 | /* notation */ 57 | .notation-322f9 { 58 | cursor: default; 59 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 60 | font-size: 14px; 61 | position: absolute; 62 | } 63 | .alpha-d2270 { 64 | bottom: 1px; 65 | right: 3px; 66 | } 67 | .numeric-fc462 { 68 | top: 2px; 69 | left: 2px; 70 | } -------------------------------------------------------------------------------- /website/releases/0.2.0/css/chessboard-0.2.0.min.css: -------------------------------------------------------------------------------- 1 | /*! ChessBoardJS v0.2.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */ 2 | .clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;-moz-box-sizing:content-box;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{-webkit-box-shadow:inset 0 0 3px 3px yellow;-moz-box-shadow:inset 0 0 3px 3px yellow;box-shadow:inset 0 0 3px 3px yellow}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px} -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bB.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bK.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bN.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bP.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bQ.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/bR.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wB.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wK.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wN.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wP.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wQ.png -------------------------------------------------------------------------------- /website/releases/0.2.0/img/chesspieces/wikipedia/wR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.2.0/img/chesspieces/wikipedia/wR.png -------------------------------------------------------------------------------- /website/releases/0.2.0/js/chessboard-0.2.0.min.js: -------------------------------------------------------------------------------- 1 | /*! ChessBoardJS v0.2.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */ 2 | (function(){var y="abcdefgh".split(""),p=function(g){return"string"!==typeof g?!1:-1!==g.search(/^[a-h][1-8]$/)},Q=function(g){if("string"!==typeof g)return!1;g=g.replace(/ .+$/,"");g=g.split("/");if(8!==g.length)return!1;for(var b=0;8>b;b++)if(""===g[b]||8f;f++){for(var n=g[f].split(""),l=0,q=0;qf;f++){for(var n=0;8>n;n++){var l=y[n]+p;!0===g.hasOwnProperty(l)?(l=g[l].split(""), 4 | l="w"===l[0]?l[1].toUpperCase():l[1].toLowerCase(),b+=l):b+="1"}7!==f&&(b+="/");p--}b=b.replace(/11111111/g,"8");b=b.replace(/1111111/g,"7");b=b.replace(/111111/g,"6");b=b.replace(/11111/g,"5");b=b.replace(/1111/g,"4");b=b.replace(/111/g,"3");return b=b.replace(/11/g,"2")};window.ChessBoard=window.ChessBoard||function(g,b){b=b||{};var u=J("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"),f={alpha:"alpha-d2270",black:"black-3c85d",board:"board-b72b1",chessboard:"chessboard-63f37",clearfix:"clearfix-7da63", 5 | highlight1:"highlight1-32417",highlight2:"highlight2-9c5d2",notation:"notation-322f9",numeric:"numeric-fc462",piece:"piece-417db",row:"row-5277c",sparePieces:"spare-pieces-7492f",sparePiecesBottom:"spare-pieces-bottom-ae20f",sparePiecesTop:"spare-pieces-top-4028b",square:"square-55d63",white:"white-1e1d7"},n,l,q,R,E,m={},W=2,w="white",k={},s,A,B,v,x=!1,L={},t={},F,C=function(){return"xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx".replace(/x/g,function(a){return(16*Math.random()|0).toString(16)})},r=function(a){return JSON.parse(JSON.stringify(a))}, 6 | X=function(a){a=a.split(".");return{major:parseInt(a[0],10),minor:parseInt(a[1],10),patch:parseInt(a[2],10)}},G=function(a,e,c){if(!0===b.hasOwnProperty("showErrors")&&!1!==b.showErrors){var d="ChessBoard Error "+a+": "+e;"console"===b.showErrors&&"object"===typeof console&&"function"===typeof console.log?(console.log(d),2<=arguments.length&&console.log(c)):"alert"===b.showErrors?(c&&(d+="\n\n"+JSON.stringify(c)),window.alert(d)):"function"===typeof b.showErrors&&b.showErrors(a,e,c)}},M=function(a){return"fast"=== 7 | a||"slow"===a?!0:parseInt(a,10)+""!==a+""?!1:0<=a},ea=function(){for(var a=0;a=b;b++){var c=y[a]+b;t[c]=c+"-"+C()}b="KQRBNP".split("");for(a=0;a';!0===b.sparePieces&&(a+='
');a+='
';!0===b.sparePieces&&(a+='
'); 8 | return a+""},ga=function(a){"black"!==a&&(a="white");var e="",c=r(y),d=8;"black"===a&&(c.reverse(),d=1);for(var H="white",g=0;8>g;g++){for(var e=e+('
'),h=0;8>h;h++){var k=c[h]+d,e=e+('
');if(!0===b.showNotation){if("white"===a&&1===d||"black"===a&&8===d)e+='
'+c[h]+"
";0===h&&(e+='
'+d+"
")}e+="
";H="white"===H?"black":"white"}e+='
';H="white"===H?"black":"white";"white"===a?d--:d++}return e},Y=function(a){if("function"===typeof b.pieceTheme)return b.pieceTheme(a);if("string"===typeof b.pieceTheme)return b.pieceTheme.replace(/{piece}/g,a);G(8272,"Unable to build image source for cfg.pieceTheme.")},z=function(a,b,c){var d=''},N=function(a){var b="wK wQ wR wB wN wP".split(" ");"black"===a&&(b="bK bQ bR bB bN bP".split(" "));a="";for(var c=0;c= 13 | d?c:d},la=function(a){for(var b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var f=y[c]+(d+1);a!==f&&b.push({square:f,distance:ka(a,f)})}b.sort(function(a,b){return a.distance-b.distance});a=[];for(c=0;c=d.left&&a=d.top&&b=a)s=0;else{for(a-=1;0!==a%8&&0=1E8*b.major+1E4*b.minor+b.patch;return a?!0:(window.alert("ChessBoard Error 1005: Unable to find a valid version of jQuery. Please include jQuery 1.7.0 or higher on the page.\n\nExiting..."),!1)}()){if("string"===typeof b||!0===I(b))b={position:b};"black"!==b.orientation&&(b.orientation="white");w=b.orientation;!1!==b.showNotation&&(b.showNotation=!0);!0!==b.draggable&&(b.draggable=!1);"trash"!== 29 | b.dropOffBoard&&(b.dropOffBoard="snapback");!0!==b.sparePieces&&(b.sparePieces=!1);!0===b.sparePieces&&(b.draggable=!0);if(!0!==b.hasOwnProperty("pieceTheme")||"string"!==typeof b.pieceTheme&&"function"!==typeof b.pieceTheme)b.pieceTheme="img/chesspieces/wikipedia/{piece}.png";if(!0!==b.hasOwnProperty("moveSpeed")||!0!==M(b.moveSpeed))b.moveSpeed=200;if(!0!==b.hasOwnProperty("snapbackSpeed")||!0!==M(b.snapbackSpeed))b.snapbackSpeed=50;if(!0!==b.hasOwnProperty("snapSpeed")||!0!==M(b.snapSpeed))b.snapSpeed= 30 | 25;if(!0!==b.hasOwnProperty("trashSpeed")||!0!==M(b.trashSpeed))b.trashSpeed=100;!0===b.hasOwnProperty("position")&&("start"===b.position?k=r(u):!0===Q(b.position)?k=J(b.position):!0===I(b.position)?k=r(b.position):G(7263,"Invalid value passed to config.position.",b.position));V=!0}V&&(ea(),ya(),xa());return m};window.ChessBoard.fenToObj=J;window.ChessBoard.objToFen=K})(); -------------------------------------------------------------------------------- /website/releases/0.3.0/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2013 Chris Oakman 2 | http://chessboardjs.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /website/releases/0.3.0/chessboardjs-0.3.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/chessboardjs-0.3.0.zip -------------------------------------------------------------------------------- /website/releases/0.3.0/css/chessboard-0.3.0.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * chessboard.js v0.3.0 3 | * 4 | * Copyright 2013 Chris Oakman 5 | * Released under the MIT license 6 | * https://github.com/oakmac/chessboardjs/blob/master/LICENSE 7 | * 8 | * Date: 10 Aug 2013 9 | */ 10 | 11 | /* clearfix */ 12 | .clearfix-7da63 { 13 | clear: both; 14 | } 15 | 16 | /* board */ 17 | .board-b72b1 { 18 | border: 2px solid #404040; 19 | -moz-box-sizing: content-box; 20 | box-sizing: content-box; 21 | } 22 | 23 | /* square */ 24 | .square-55d63 { 25 | float: left; 26 | position: relative; 27 | 28 | /* disable any native browser highlighting */ 29 | -webkit-touch-callout: none; 30 | -webkit-user-select: none; 31 | -khtml-user-select: none; 32 | -moz-user-select: none; 33 | -ms-user-select: none; 34 | user-select: none; 35 | } 36 | 37 | /* white square */ 38 | .white-1e1d7 { 39 | background-color: #f0d9b5; 40 | color: #b58863; 41 | } 42 | 43 | /* black square */ 44 | .black-3c85d { 45 | background-color: #b58863; 46 | color: #f0d9b5; 47 | } 48 | 49 | /* highlighted square */ 50 | .highlight1-32417, .highlight2-9c5d2 { 51 | -webkit-box-shadow: inset 0 0 3px 3px yellow; 52 | -moz-box-shadow: inset 0 0 3px 3px yellow; 53 | box-shadow: inset 0 0 3px 3px yellow; 54 | } 55 | 56 | /* notation */ 57 | .notation-322f9 { 58 | cursor: default; 59 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 60 | font-size: 14px; 61 | position: absolute; 62 | } 63 | .alpha-d2270 { 64 | bottom: 1px; 65 | right: 3px; 66 | } 67 | .numeric-fc462 { 68 | top: 2px; 69 | left: 2px; 70 | } -------------------------------------------------------------------------------- /website/releases/0.3.0/css/chessboard-0.3.0.min.css: -------------------------------------------------------------------------------- 1 | /*! chessboard.js v0.3.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */ 2 | .clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;-moz-box-sizing:content-box;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{-webkit-box-shadow:inset 0 0 3px 3px yellow;-moz-box-shadow:inset 0 0 3px 3px yellow;box-shadow:inset 0 0 3px 3px yellow}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px} -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bB.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bK.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bN.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bP.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bQ.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/bR.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wB.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wK.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wN.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wP.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wQ.png -------------------------------------------------------------------------------- /website/releases/0.3.0/img/chesspieces/wikipedia/wR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/0.3.0/img/chesspieces/wikipedia/wR.png -------------------------------------------------------------------------------- /website/releases/0.3.0/js/chessboard-0.3.0.min.js: -------------------------------------------------------------------------------- 1 | /*! chessboard.js v0.3.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */ 2 | (function(){function l(f){return"string"!==typeof f?!1:-1!==f.search(/^[a-h][1-8]$/)}function Q(f){if("string"!==typeof f)return!1;f=f.replace(/ .+$/,"");f=f.split("/");if(8!==f.length)return!1;for(var b=0;8>b;b++)if(""===f[b]||8m;m++){for(var l=f[m].split(""),r=0,w=0;wm;m++){for(var l=0;8>l;l++){var r=B[l]+n;!0===f.hasOwnProperty(r)?(r=f[r].split(""),r="w"===r[0]?r[1].toUpperCase(): 4 | r[1].toLowerCase(),b+=r):b+="1"}7!==m&&(b+="/");n--}b=b.replace(/11111111/g,"8");b=b.replace(/1111111/g,"7");b=b.replace(/111111/g,"6");b=b.replace(/11111/g,"5");b=b.replace(/1111/g,"4");b=b.replace(/111/g,"3");return b=b.replace(/11/g,"2")}var B="abcdefgh".split("");window.ChessBoard=window.ChessBoard||function(f,b){function n(){return"xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx".replace(/x/g,function(a){return(16*Math.random()|0).toString(16)})}function m(a){return JSON.parse(JSON.stringify(a))}function X(a){a= 5 | a.split(".");return{major:parseInt(a[0],10),minor:parseInt(a[1],10),patch:parseInt(a[2],10)}}function r(a,e,c){if(!0===b.hasOwnProperty("showErrors")&&!1!==b.showErrors){var d="ChessBoard Error "+a+": "+e;"console"===b.showErrors&&"object"===typeof console&&"function"===typeof console.log?(console.log(d),2<=arguments.length&&console.log(c)):"alert"===b.showErrors?(c&&(d+="\n\n"+JSON.stringify(c)),window.alert(d)):"function"===typeof b.showErrors&&b.showErrors(a,e,c)}}function w(a){return"fast"=== 6 | a||"slow"===a?!0:parseInt(a,10)+""!==a+""?!1:0<=a}function I(){for(var a=0;a=b;b++){var c=B[a]+b;s[c]=c+"-"+n()}b="KQRBNP".split("");for(a=0;a';!0===b.sparePieces&&(a+='
');a+='
';!0===b.sparePieces&&(a+='
'); 7 | return a+""}function A(a){"black"!==a&&(a="white");var e="",c=m(B),d=8;"black"===a&&(c.reverse(),d=1);for(var C="white",f=0;8>f;f++){for(var e=e+('
'),k=0;8>k;k++){var g=c[k]+d,e=e+('
');if(!0===b.showNotation){if("white"===a&&1===d||"black"===a&&8===d)e+='
'+c[k]+"
";0===k&&(e+='
'+d+"
")}e+="
";C="white"===C?"black":"white"}e+='
';C="white"===C?"black":"white";"white"===a?d--:d++}return e}function Y(a){if("function"===typeof b.pieceTheme)return b.pieceTheme(a);if("string"===typeof b.pieceTheme)return b.pieceTheme.replace(/{piece}/g,a);r(8272,"Unable to build image source for cfg.pieceTheme.");return""}function D(a,b,c){var d=''}function N(a){var b="wK wQ wR wB wN wP".split(" ");"black"===a&&(b="bK bQ bR bB bN bP".split(" "));a="";for(var c=0;c=d?c:d}function la(a){for(var b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var g=B[c]+(d+1);a!==g&&b.push({square:g,distance:ka(a,g)})}b.sort(function(a,b){return a.distance-b.distance});a=[];for(c=0;c=d.left&&a=d.top&&b=a)p=0;else{for(a-=1;0!==a%8&&0=1E8*b.major+1E4*b.minor+b.patch;return a?!0:(window.alert("ChessBoard Error 1005: Unable to find a valid version of jQuery. Please include jQuery 1.7.0 or higher on the page.\n\nExiting..."), 29 | !1)}()){if("string"===typeof b||!0===F(b))b={position:b};"black"!==b.orientation&&(b.orientation="white");u=b.orientation;!1!==b.showNotation&&(b.showNotation=!0);!0!==b.draggable&&(b.draggable=!1);"trash"!==b.dropOffBoard&&(b.dropOffBoard="snapback");!0!==b.sparePieces&&(b.sparePieces=!1);!0===b.sparePieces&&(b.draggable=!0);if(!0!==b.hasOwnProperty("pieceTheme")||"string"!==typeof b.pieceTheme&&"function"!==typeof b.pieceTheme)b.pieceTheme="img/chesspieces/wikipedia/{piece}.png";if(!0!==b.hasOwnProperty("appearSpeed")|| 30 | !0!==w(b.appearSpeed))b.appearSpeed=200;if(!0!==b.hasOwnProperty("moveSpeed")||!0!==w(b.moveSpeed))b.moveSpeed=200;if(!0!==b.hasOwnProperty("snapbackSpeed")||!0!==w(b.snapbackSpeed))b.snapbackSpeed=50;if(!0!==b.hasOwnProperty("snapSpeed")||!0!==w(b.snapSpeed))b.snapSpeed=25;if(!0!==b.hasOwnProperty("trashSpeed")||!0!==w(b.trashSpeed))b.trashSpeed=100;!0===b.hasOwnProperty("position")&&("start"===b.position?g=m(fa):!0===Q(b.position)?g=K(b.position):!0===F(b.position)?g=m(b.position):r(7263,"Invalid value passed to config.position.", 31 | b.position));W=!0}W&&(I(),ya(),xa());return q};window.ChessBoard.fenToObj=K;window.ChessBoard.objToFen=L})(); -------------------------------------------------------------------------------- /website/releases/chessboardjs-1.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oakmac/chessboardjs/bfb9315cd44d22c4a3ccc883ab4c0b42e902557e/website/releases/chessboardjs-1.0.0.zip --------------------------------------------------------------------------------