diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-28 00:09:50 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-28 00:09:50 +0530 |
| commit | c56cc12c154b3f21411d71e10f4e8a5a9682355b (patch) | |
| tree | 9e07f9cf746ca12ca386c3ea1bebe4953453045a /assets | |
| parent | 2c2a70b69869f149c0407a62f1bf4c39899027a7 (diff) | |
the moves now make it to the frontend
i know the issue which exists, where the server can't handle the request
if i reload the page
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/board.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/assets/board.js b/assets/board.js index 8bd6a61..e53e285 100644 --- a/assets/board.js +++ b/assets/board.js @@ -77,24 +77,23 @@ let renderingMoves = []; function updateRenderingMoves() { for (let i = 0; i < 64; i++) { const square = document.getElementById(`square-${i}`); - if (i in renderingMoves) square.children[0].classList.add("possible_move"); + if (renderingMoves.includes(i)) square.children[0].classList.add("possible_move"); else square.children[0].classList.remove("possible_move"); } } -function addMoves(moves) { - console.log(moves); - validMoves = {}; - for (const [from, to] of moves) { +function handleTransmission(data) { + data = data.join(""); + for (let i = 0; i < data.length / 4; i++) { + const moveData = data.slice(4 * i, 4 * i + 4); + let from = parseInt(moveData.slice(0, 2)); + let to = parseInt(moveData.slice(2)); + + console.log(from, to); + if (validMoves[from] == undefined) validMoves[from] = [] validMoves[from].push(to); } - - console.log(validMoves); -} - -function handleTransmission(data) { - console.log(data); } window.onload = () => { |
