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