Tweak key coloring

This commit is contained in:
Arne Keller 2022-02-23 15:25:47 +01:00
parent 8eb8cc6640
commit e4d9c46420

View File

@ -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";
}
}