Tweak key coloring
This commit is contained in:
parent
8eb8cc6640
commit
e4d9c46420
17
index.js
17
index.js
@ -214,6 +214,11 @@ function processKey(e) {
|
|||||||
}
|
}
|
||||||
if (input === word) {
|
if (input === word) {
|
||||||
done[pos] = guessed.length + 1;
|
done[pos] = guessed.length + 1;
|
||||||
|
for (let char in keys) {
|
||||||
|
if (word.indexOf(char.toUpperCase()) === -1) {
|
||||||
|
characters[pos][char.toUpperCase()] = "nope";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
guessed.push(input);
|
guessed.push(input);
|
||||||
@ -225,12 +230,20 @@ function processKey(e) {
|
|||||||
saveLocalStorage();
|
saveLocalStorage();
|
||||||
input = "";
|
input = "";
|
||||||
for (let char in keys) {
|
for (let char in keys) {
|
||||||
|
if (char.length > 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const c = char.toUpperCase();
|
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]);
|
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") {
|
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";
|
keys[char].style.opacity = "0.5";
|
||||||
} else {
|
} else if (anyNotNope) {
|
||||||
keys[char].style.color = "#000";
|
keys[char].style.color = "#000";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user