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);
}
}