From: Laurent Mazet Date: Wed, 10 Jun 2020 21:58:36 +0000 (+0200) Subject: add a button to enable spell checker X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=1595b60145631d0366db5a5d850961e38f3d9a87;p=trivabble.git add a button to enable spell checker --- diff --git a/l10n/po/fr/trivabble.po b/l10n/po/fr/trivabble.po index b4a9841..0d0398b 100644 --- a/l10n/po/fr/trivabble.po +++ b/l10n/po/fr/trivabble.po @@ -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 ?" diff --git a/l10n/pot/trivabble.pot b/l10n/pot/trivabble.pot index b8706b9..912c1a4 100644 --- a/l10n/pot/trivabble.pot +++ b/l10n/pot/trivabble.pot @@ -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 "" diff --git a/public/index.html b/public/index.html index a15eb23..f61707c 100644 --- a/public/index.html +++ b/public/index.html @@ -69,7 +69,8 @@

Who's turn? Click on the Turn button!

- + + diff --git a/public/trivabble.js b/public/trivabble.js index 37f9a5f..dd2cbba 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -151,6 +151,14 @@ } 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; @@ -164,7 +172,7 @@ 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.")); } @@ -173,6 +181,19 @@ 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); } @@ -578,7 +599,6 @@ case "boardLang": localStorage.trivabbleBoardLang = value; document.getElementById("board-lang").value = value; - document.getElementById("check-spelling").disabled = true; downloadDictionary(value); break; } @@ -1739,6 +1759,7 @@ 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; }