fix eslint errors
authorLaurent Mazet <mazet@softndesign.org>
Fri, 14 Aug 2020 19:35:25 +0000 (21:35 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Fri, 14 Aug 2020 19:35:25 +0000 (21:35 +0200)
public/trivabble.js

index dc093e980fbb1cc3010f3d7ef456830e4040d4ec..a684d014d9fc9dd8e4b7b28560cbdb501f42c8be 100644 (file)
         if (code !== null) {
             localStorage.spellChecker = code;
         }
-        if (localStorage.spellChecker !== "false") {
-            document.getElementById("enable-spell-checker").checked = true;
-            document.getElementById("check-spelling").style.display = "block";
-        } else {
+        if (localStorage.spellChecker === "false") {
             document.getElementById("enable-spell-checker").checked = false;
             document.getElementById("check-spelling").style.display = "none";
+        } else {
+            document.getElementById("enable-spell-checker").checked = true;
+            document.getElementById("check-spelling").style.display = "block";
         }
     }
 
         file.open("GET", "dict/" + code + ".dict", true);
         file.onreadystatechange = function () {
             if (file.readyState === 4) {
-                if (file.status == "200") {
+                if (Number(file.status) === 200) {
                     try {
                         dictionary = file.responseText.split("\n");
                         checkSpellCheckerState(code);
             if (moveCMD.to === "board") {
                 currentTilePlayed[moveCMD.indexTo] = "-";
             }
-        } else { /* moveCMD.from === "board" */
+        } else {/* moveCMD.from === "board" */
             if (moveCMD.to === "board") {
                 currentTilePlayed[moveCMD.indexTo] = currentTilePlayed[moveCMD.indexFrom];
             }
             }
             modifyTileClass(newWords[k], "tile-spelling-ok", true);
             const pattern = "^" + newWords[k].letters.replace(/ /gu, ".") + "$";
-            if (!dictionary.find(function (word) {return word.match(pattern);})) {
+            const find = dictionary.find(function (word) {
+                return word.match(pattern);
+            });
+            if (!find) {
                 if (badWords.indexOf(currentWord) === -1) {
                     badWords.push(currentWord);
                 }
 
     function initSpellChecker() {
         if (!Object.prototype.hasOwnProperty.call(localStorage, "spellChecker")) {
-           localStorage.spellChecker = Conf.SPELL_CHECKER;
+            localStorage.spellChecker = Conf.SPELL_CHECKER;
         }
 
         document.getElementById("enable-spell-checker").onclick = enableSpellChecker;
 
-        if (localStorage.spellChecker !== "false") {
+        if (localStorage.spellChecker === "false") {
+            checkSpellCheckerState("false");
+        } else {
             const spellChecker = localStorage.spellChecker;
             localStorage.spellChecker = "false";
-            downloadDictionary(spellChecker)
-        } else {
-            checkSpellCheckerState("false");
+            downloadDictionary(spellChecker);
         }
     }