From c56cc12c154b3f21411d71e10f4e8a5a9682355b Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Thu, 28 May 2026 00:09:50 +0530 Subject: 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 --- assets/board.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'assets/board.js') 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 = () => { -- cgit v1.2.3