From: Laurent Mazet Date: Sat, 20 Jun 2020 21:35:45 +0000 (+0200) Subject: correct badWords list and simplify word list trimming X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=e3a8b3c032f586f107ccf44bcc7d3208005f43e4;p=trivabble.git correct badWords list and simplify word list trimming --- diff --git a/public/trivabble.js b/public/trivabble.js index a4bf6ba..2e4888d 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1587,17 +1587,13 @@ setTimeout(function () {highlightWord(newWords[k], "tile-spelling-ok", false);}, 5000); const pattern = "^" + newWords[k].letters.replace(/ /g, ".") + "$"; if (!dictionary.find(element => element.match(pattern))) { - badWords.push(newWords[k]); + badWords.push(newWords[k].letters.replace(/ /g, "?")); highlightWord(newWords[k], "tile-spelling-nok", true); setTimeout(function () {highlightWord(newWords[k], "tile-spelling-nok", false);}, 5000); } } - words = words.join(", ") - .replace(/^ */u, "") - .replace(/ *$/u, ""); - badWords = badWords.join(", ") - .replace(/^ */u, "") - .replace(/ *$/u, ""); + words = words.join(", ").trim(); + badWords = badWords.join(", ").trim(); /* Advice on erroneous spelling */ if (badWords.length > 0) {