<chess-board>
A web component for displaying chess positions.
Demo
Usage
-
Import Web Components' polyfill:
-
Import Custom Element:
-
Start using it!
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Options
Attribute | Description |
---|---|
unicode |
Display chess pices with unicode characters. |
frame |
Display file and rank arround the chessboard |
reverse |
Display the chessboard with black pieces at the bottom. |
Methods
put()
Put the white queen on the a4 square
var board = ;board;
set a4 square empty
var board = ;board;
move()
move a piece from a4 to a1
var board = ;board;
The pieces are defined as in Forsyth–Edwards Notation
P // ♙ white pawnN // ♘ white knightB // ♗ white bishopR // ♖ white rookQ // ♕ white queenK // ♔ white king p // ♟ black pawnn // ♞ black knightb // ♝ black bishopr // ♜ black rookq // ♛ black queenk // ♚ black king
clearBoard()
var board = ;board;
setting board position
var board = ;boardfen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
getting board position
var board = ;boardfen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";board; var currentFen = boardfen;
License
MIT © Sigurd Fosseng