correct board design
authorLaurent Mazet <mazet@softndesign.org>
Wed, 7 Oct 2020 19:41:11 +0000 (21:41 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Wed, 7 Oct 2020 20:01:08 +0000 (22:01 +0200)
public/trivabble.js

index dfff5c5f9b8aa201fe3eaeb038568ad72f6bda01..5362046d1ef9b2bf05d9cccfe1ce04ad9352f4ce 100644 (file)
         };
 
         let cell;
+        let row
 
         for (let i = 0; i < 7; i++) {
             const span = document.createElement("span");
             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];
 
                 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);
                 }
             }
 
 
         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++) {