main
Elnu 2 years ago
parent faa47dd546
commit d27c7dbb50

@ -187,16 +187,29 @@ let timerTimeout = null;
let word = null;
let repeats = 0;
let failed = false;
let problemWords = [];
let problemTimes = [];
const reset = () => {
failed = false;
input.value = "";
hint.innerHTML = "";
timer.value = 1;
if (repeats == 0) {
if (problemTimes.length > 0 && new Date() - problemTimes[0] > 60000) {
word = problemWords[0];
problemWords.shift();
problemTimes.shift();
} else {
word = words[Math.round(Math.random() * words.length)];
}
}
wordDisplay.innerHTML = word;
const typeTime = typeTimePerKana * word.length;
incorrectTimeout = setTimeout(() => {
if (!problemWords.includes(word)) {
problemWords.push(word);
problemTimes.push(new Date());
}
repeats += repeats == 0 ? 3 : 1;
failed = true;
wordDisplay.innerHTML = `${word}`;