diff --git a/index.js b/index.js index fe2e22c..8be5907 100644 --- a/index.js +++ b/index.js @@ -214,6 +214,11 @@ function processKey(e) { } if (input === word) { done[pos] = guessed.length + 1; + for (let char in keys) { + if (word.indexOf(char.toUpperCase()) === -1) { + characters[pos][char.toUpperCase()] = "nope"; + } + } } } guessed.push(input); @@ -225,12 +230,20 @@ function processKey(e) { saveLocalStorage(); input = ""; for (let char in keys) { + if (char.length > 1) { + continue; + } const c = char.toUpperCase(); - if (characters[0][c] || characters[1][c] || characters[2][c] || characters[3][c]) { + let anyNotNope = (characters[0][c] && characters[0][c] !== "nope") + || (characters[1][c] && characters[1][c] !== "nope") + || (characters[2][c] && characters[2][c] !== "nope") + || (characters[3][c] && characters[3][c] !== "nope"); + if (anyNotNope || (characters[0][c] === "nope" && characters[1][c] === "nope" && characters[2][c] === "nope" && characters[3][c] === "nope")) { keys[char].style.background = makeGradient(characters[0][c], characters[1][c], characters[2][c], characters[3][c]); if (characters[0][c] === "nope" && characters[1][c] === "nope" && characters[2][c] === "nope" && characters[3][c] === "nope") { + keys[char].style.color = "#fff"; keys[char].style.opacity = "0.5"; - } else { + } else if (anyNotNope) { keys[char].style.color = "#000"; } }