UNPKG

cm-chessboard

Version:

A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.

30 lines (28 loc) 1.18 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cm-chessboard</title> <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0"/> <link rel="stylesheet" href="../styles/examples.css"/> <link rel="stylesheet" href="../../assets/chessboard.css"/> <link rel="stylesheet" href="../../assets/extensions/markers/markers.css"/> </head> <body> <h1><a href="../../">cm-chessboard</a></h1> <h2>Example: Persistence Extension</h2> <p>This extension stores the board position in localStorage and automatically loads the board on creation.</p> <p>Alpha version, do not use in production.</p> <div class="board" id="board"></div> <script type="module"> import {Chessboard, FEN} from "../../src/Chessboard.js" import {Persistence} from "../../src/extensions/persistence/Persistence.js" const board = new Chessboard(document.getElementById("board"), { assetsUrl: "../../assets/", // todo initialPosition should be a property of cm-chessboard extensions: [{class: Persistence, props: {initialPosition: FEN.start}}] }) board.enableMoveInput(() => true) </script> </body> </html>