From 82b38df25dac008557e70c8374e43a1f9ea7040a Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Wed, 7 Oct 2020 21:41:11 +0200 Subject: [PATCH] correct board design --- public/trivabble.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/public/trivabble.js b/public/trivabble.js index dfff5c5..5362046 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -2223,6 +2223,7 @@ }; let cell; + let row for (let i = 0; i < 7; i++) { const span = document.createElement("span"); @@ -2235,7 +2236,7 @@ board.rows[0].appendChild(document.createElement("th")); board.rows[0].lastChild.textContent = i + 1; - const row = board.insertRow(-1); + row = board.insertRow(-1); row.appendChild(document.createElement("th")); row.lastChild.textContent = letters[i]; @@ -2248,18 +2249,18 @@ cell.lastChild.className = "tile-placeholder"; if (i === j && i === 7) { - specialCell("doubleWord", board.lastChild.lastChild); - cell = board.lastChild.lastChild.getElementsByClassName("special-cell-label")[0]; + specialCell("doubleWord", row.lastChild); + cell = row.lastChild.getElementsByClassName("special-cell-label")[0]; cell.textContent = "★"; row.lastChild.id = "center-cell"; } else if (i % 7 === 0 && j % 7 === 0) { - specialCell("tripleWord", board.lastChild.lastChild); + specialCell("tripleWord", row.lastChild); } else if ((i === j || i + j === 14) && (i < 5 || i > 9)) { - specialCell("doubleWord", board.lastChild.lastChild); + specialCell("doubleWord", row.lastChild); } else if ((i % 4 === 1) && (j % 4 === 1)) { - specialCell("tripleLetter", board.lastChild.lastChild); + specialCell("tripleLetter", row.lastChild); } else if ((i < 8 && doubleLetter[i + "," + j]) || (i > 7 && doubleLetter[(14 - i) + "," + j]) || (i === 7 && (j === 3 || j === 11))) { - specialCell("doubleLetter", board.lastChild.lastChild); + specialCell("doubleLetter", row.lastChild); } } @@ -2269,7 +2270,7 @@ board.rows[0].appendChild(board.rows[0].cells[0].cloneNode(false)); - const row = board.insertRow(-1); + row = board.insertRow(-1); row.appendChild(board.rows[0].cells[0].cloneNode(false)); for (let i = 0; i < 15; i++) { -- 2.30.2