Add SRS
This commit is contained in:
parent
faa47dd546
commit
d27c7dbb50
1 changed files with 14 additions and 1 deletions
15
nicolator.js
15
nicolator.js
|
@ -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) {
|
||||
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;
|
||||
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} ❌`;
|
||||
|
|
Reference in a new issue