From: Laurent Mazet Date: Fri, 14 Aug 2020 19:35:25 +0000 (+0200) Subject: fix eslint errors X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=a9de7c881f4e9ad707130a00afd3175fbb00db00;p=trivabble.git fix eslint errors --- diff --git a/public/trivabble.js b/public/trivabble.js index dc093e9..a684d01 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -155,12 +155,12 @@ 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"; } } @@ -174,7 +174,7 @@ 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); @@ -271,7 +271,7 @@ 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]; } @@ -1655,7 +1655,10 @@ } 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); } @@ -1761,17 +1764,17 @@ 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); } }