Change button state depending of dictionnary avability
authorLaurent Mazet <mazet@softndesign.org>
Wed, 27 May 2020 07:02:50 +0000 (09:02 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Mon, 8 Jun 2020 05:34:42 +0000 (07:34 +0200)
public/index.html
public/trivabble.js

index 8dc3943c82c3d230a1a9500fb742d5b70094ac58..a15eb237e86da59014edd0ec579a6a4e3a4fcf56 100644 (file)
@@ -69,7 +69,7 @@
             <p id="help-turn" data-l10n="text-content">Who's turn? Click on the Turn button!</p>
             <button id="clear-rack" class="minibutton" data-l10n="text-content">Put back all the tiles of&#10;your rack in the bag</button>
             <button id="show-rack" class="minibutton" data-l10n="text-content">Show my rack to other players</button>
-            <button id="check-spelling" class="minibutton" data-l10n="text-content">Check spelling for new words</button>
+            <button id="check-spelling" class="minibutton" data-l10n="text-content" disabled="disabled">Check spelling for new words</button>
         </div>
     </body>
 </html>
index ce45109dc494080a8dd56facc3158d7dffc78540..205bfea83707264c85e42d5c03ce94e7bb205d64 100644 (file)
                             ? format(_("You changed the language of the board to {0}"), newLang)
                             : format(_("{0} changed the language of the board to {1}"), msg.sender, newLang)
                     );
+                    document.getElementById("check-spelling").disabled = true;
                     const code = document.getElementById("board-lang").value;
                     const file = new XMLHttpRequest();
                     file.overrideMimeType("application/json");
                         if ((file.readyState === 4) && (file.status == "200")) {
                             try {
                                 dictionnary = JSON.parse(file.responseText);
+
+                                document.getElementById("check-spelling").disabled = false;
                             } catch (e) {
                                 console.error(e);
                             }
 
     function searchWordInLine(row, col, incRow, incCol) {
         
+        const initLetter = getLetterFromBoard(row, col);
+
         /* Look for first letter in line */
         while (getLetterFromBoard(row - incRow, col - incCol) !== "") {
             row -= incRow;
             row += incRow;
             col += incCol;
         }
-        return (word.length > 1) ? word : "";
+        return (word === initLetter) ? "" : word;
     }
     
     function searchNewWords() {