|
|
|
@ -176,18 +176,18 @@ const timerFPS = 60;
|
|
|
|
|
let incorrectTimeout = null;
|
|
|
|
|
let timerTimeout = null;
|
|
|
|
|
let word = null;
|
|
|
|
|
let wrong = false;
|
|
|
|
|
let repeats = 0;
|
|
|
|
|
const reset = () => {
|
|
|
|
|
input.value = "";
|
|
|
|
|
hint.innerHTML = "";
|
|
|
|
|
timer.value = 1;
|
|
|
|
|
if (!wrong) {
|
|
|
|
|
if (repeats == 0) {
|
|
|
|
|
word = words[Math.round(Math.random() * words.length)];
|
|
|
|
|
}
|
|
|
|
|
wordDisplay.innerHTML = word;
|
|
|
|
|
const typeTime = typeTimePerKana * word.length;
|
|
|
|
|
incorrectTimeout = setTimeout(() => {
|
|
|
|
|
wrong = true;
|
|
|
|
|
repeats += repeats == 0 ? 3 : 1;
|
|
|
|
|
wordDisplay.innerHTML = `${word} ❌`;
|
|
|
|
|
for (let i = 0; i < word.length; i++) {
|
|
|
|
|
const letter = word[i];
|
|
|
|
@ -221,6 +221,8 @@ const reset = () => {
|
|
|
|
|
timerTimeout = setInterval(() => {
|
|
|
|
|
timer.value -= (1 / timerFPS) / typeTime;
|
|
|
|
|
}, 1000 / timerFPS);
|
|
|
|
|
wrong = false;
|
|
|
|
|
if (repeats > 0) {
|
|
|
|
|
repeats -= 1;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
reset();
|
|
|
|
|