cm-chessboard

Example: Context input, mark squares

Toggle marker on context input. First board, context input only. Second board, move input and context input enabled.


const board1 = new Chessboard(document.getElementById("board1"), {
    position: "start",
    sprite: {url: "../assets/images/chessboard-sprite.svg"}
})
board1.enableContextInput((event) => {
    const markersOnSquare = board1.getMarkers(event.square, MARKER_TYPE.emphasize)
    if (markersOnSquare.length > 0) {
        board1.removeMarkers(event.square, MARKER_TYPE.emphasize)
    } else {
        board1.addMarker(event.square)
    }
})