mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-14 23:58:53 +00:00
feat: Clear move selection when clicking on the source piece
This commit is contained in:
parent
9a0a705607
commit
985bff13b7
1 changed files with 11 additions and 7 deletions
|
@ -31,13 +31,17 @@ const loadBoard = (board) => {
|
||||||
|
|
||||||
board.querySelectorAll(".piece.hasMoves").forEach(element => {
|
board.querySelectorAll(".piece.hasMoves").forEach(element => {
|
||||||
element.addEventListener("click", event => {
|
element.addEventListener("click", event => {
|
||||||
clearSelection();
|
if (board.classList.contains("moveSelection")) {
|
||||||
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
clearSelection();
|
||||||
encoded: move,
|
} else {
|
||||||
source: move.split(",")[0].split("-")[2],
|
clearSelection();
|
||||||
target: move.split(",")[1]
|
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
||||||
}));
|
encoded: move,
|
||||||
enterSelection(moves);
|
source: move.split(",")[0].split("-")[2],
|
||||||
|
target: move.split(",")[1]
|
||||||
|
}));
|
||||||
|
enterSelection(moves);
|
||||||
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue