From ff3f02dddcb979da7c5df14ba0279f5968c9e7d8 Mon Sep 17 00:00:00 2001 From: IgrisBRC Date: Mon, 15 Jul 2024 11:22:02 +0530 Subject: fixed fault functionality, by changing for charAt to charCodeAt --- public/board.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'public/board.js') diff --git a/public/board.js b/public/board.js index bc76394..c5f1fc7 100644 --- a/public/board.js +++ b/public/board.js @@ -15,27 +15,28 @@ function handle_highlight(i) { let id = squares[i].id - let moves = move(board, id.charAt(0), id.charAt(1), to_move) + let moves = move(board, id.charCodeAt(0) - 48, id.charCodeAt(1) - 48, to_move) for (let i = 0; i < previously_highlighted_squares.length; i++) { let prev = document.getElementById(previously_highlighted_squares[i]) prev.classList.remove('highlight') + prev.onclick = null } for (let i = 0; i < moves.length; i++) { let hlsquare = document.getElementById(`${moves[i][0]}${moves[i][1]}`) hlsquare.classList.add('highlight') - hlsquare.onclick = handle_move(hlsquare.id) previously_highlighted_squares.push(`${moves[i][0]}${moves[i][1]}`) } - } -} -function handle_move(id) { - return function() { - console.log(id) } } +//function handle_move(id) { +// return function() { +// console.log(id) +// } +//} +// -- cgit v1.2.3