add a button to enable spell checker
authorLaurent Mazet <mazet@softndesign.org>
Wed, 10 Jun 2020 21:58:36 +0000 (23:58 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Wed, 10 Jun 2020 21:58:36 +0000 (23:58 +0200)
l10n/po/fr/trivabble.po
l10n/pot/trivabble.pot
public/index.html
public/trivabble.js

index b4a98414d86c2a0d91d7b35e1783e360366fb50a..0d0398b85df9f6f89966cf6ba51111babd6342b8 100644 (file)
@@ -180,3 +180,9 @@ msgstr "Aucun nouveau mot trouvé"
 
 msgid  "Incorrect dictionary file."
 msgstr "Dictionaire incorrect."
+
+msgid  "Enable spell checker"
+msgstr "Activer le vérificateur orthographique"
+
+msgid  "Spell checking requires Trivabble to download a dictionary. This dictionary is based on Aspell. Do you confirm?"
+msgstr "La vérification orthographique nécessite que Trivabble télécharge un dictionnaire. Ce dictionnaire est construit grâce à Aspell. Confirmez-vous ?"
index b8706b9f7f3fbb2aef26728732682ea08cb95888..912c1a4e38b33ec867592413b32321d818660559 100644 (file)
@@ -186,3 +186,9 @@ msgstr ""
 
 msgid  "Incorrect dictionary file."
 msgstr ""
+
+msgid  "Enable spell checker"
+msgstr ""
+
+msgid  "Spell checking requires Trivabble to download a dictionary. This dictionary is based on Aspell. Do you confirm?"
+msgstr ""
index a15eb237e86da59014edd0ec579a6a4e3a4fcf56..f61707cbd46ec6123ae6d5de51fe30fbe62be2ef 100644 (file)
@@ -69,7 +69,8 @@
             <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" disabled="disabled">Check spelling for new words</button>
+            <button id="enable-spell-checker" class="minibutton" data-l10n="text-content">Enable spell checker</button>
+            <button id="check-spelling" class="minibutton" data-l10n="text-content" style="display: none">Check spelling for new words</button>
         </div>
     </body>
 </html>
index 37f9a5f1042e6d4ce49ab9c9370fb762402e5204..dd2cbba9118a4d05c640b2421678eef551c950ab 100644 (file)
     }
 
     function downloadDictionary(code) {
+        if (localStorage.spellChecker) {
+            document.getElementById("enable-spell-checker").style.display = "none";
+            document.getElementById("check-spelling").style.display = "none";
+        } else {
+            document.getElementById("enable-spell-checker").style.display = "block";
+            document.getElementById("check-spelling").style.display = "none";
+        }
+
         /* static variable */
         if (downloadDictionary.code === code) {
             return;
             if ((file.readyState === 4) && (file.status == "200")) {
                 try {
                     dictionary = file.responseText.split("\n");
-                    document.getElementById("check-spelling").disabled = false;
+                    document.getElementById("check-spelling").style.display = "block";
                 } catch (e) {
                     myAlert(_("Incorrect dictionary file."));
                 }
         file.send(null);
     }
 
+    function enableSpellChecker() {
+        myConfirm(
+            _("Spell checking requires Trivabble to download a dictionary. This dictionary is based on Aspell. Do you confirm?"),
+            function () {
+                localStorage.spellChecker = true;
+                downloadDictionary(localStorage.trivabbleBoardLang);
+            },
+            function () {
+                localStorage.spellChecker = false;
+                downloadDictionary(localStorage.trivabbleBoardLang);
+            });
+    }
+
     function removeElem(elem) {
         elem.parentNode.removeChild(elem);
     }
             case "boardLang":
                 localStorage.trivabbleBoardLang = value;
                 document.getElementById("board-lang").value = value;
-                document.getElementById("check-spelling").disabled = true;
                 downloadDictionary(value);
                 break;
         }
         document.getElementById("join-game").onclick   = joinGame;
         document.getElementById("clear-rack").onclick  = clearRack;
         document.getElementById("show-rack").onclick   = showRack;
+        document.getElementById("enable-spell-checker").onclick = enableSpellChecker;
         document.getElementById("check-spelling").onclick = checkSpelling;
         helpClear.onclick  = clearGame;
     }