main
Elnu 2 years ago
parent faa47dd546
commit d27c7dbb50

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