|
|
@ -108,7 +108,9 @@ const wordDisplay = document.getElementById("word");
|
|
|
|
const input = document.getElementById("input");
|
|
|
|
const input = document.getElementById("input");
|
|
|
|
const timer = document.getElementById("timer");
|
|
|
|
const timer = document.getElementById("timer");
|
|
|
|
const hintDisplay = document.getElementById("hint");
|
|
|
|
const hintDisplay = document.getElementById("hint");
|
|
|
|
|
|
|
|
const incorrect = document.getElementById("incorrectSfx");
|
|
|
|
|
|
|
|
const correct = document.getElementById("correctSfx");
|
|
|
|
|
|
|
|
const success = document.getElementById("successSfx");
|
|
|
|
const leftShiftCode = 32; // space
|
|
|
|
const leftShiftCode = 32; // space
|
|
|
|
const rightShiftCode = 16; // shift key
|
|
|
|
const rightShiftCode = 16; // shift key
|
|
|
|
let leftShift = false;
|
|
|
|
let leftShift = false;
|
|
|
@ -137,6 +139,13 @@ addEventListener("keyup", event => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const check = () => {
|
|
|
|
const check = () => {
|
|
|
|
if (input.value == word) {
|
|
|
|
if (input.value == word) {
|
|
|
|
|
|
|
|
if (repeats == 0) {
|
|
|
|
|
|
|
|
success.currentTime = 0;
|
|
|
|
|
|
|
|
success.play();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
correct.currentTime = 0;
|
|
|
|
|
|
|
|
correct.play();
|
|
|
|
|
|
|
|
}
|
|
|
|
clearTimeout(incorrectTimeout);
|
|
|
|
clearTimeout(incorrectTimeout);
|
|
|
|
clearTimeout(timerTimeout);
|
|
|
|
clearTimeout(timerTimeout);
|
|
|
|
wordDisplay.style.color = "green";
|
|
|
|
wordDisplay.style.color = "green";
|
|
|
@ -177,6 +186,7 @@ let incorrectTimeout = null;
|
|
|
|
let timerTimeout = null;
|
|
|
|
let timerTimeout = null;
|
|
|
|
let word = null;
|
|
|
|
let word = null;
|
|
|
|
let repeats = 0;
|
|
|
|
let repeats = 0;
|
|
|
|
|
|
|
|
let failed = false;
|
|
|
|
const reset = () => {
|
|
|
|
const reset = () => {
|
|
|
|
input.value = "";
|
|
|
|
input.value = "";
|
|
|
|
hint.innerHTML = "";
|
|
|
|
hint.innerHTML = "";
|
|
|
@ -188,7 +198,10 @@ const reset = () => {
|
|
|
|
const typeTime = typeTimePerKana * word.length;
|
|
|
|
const typeTime = typeTimePerKana * word.length;
|
|
|
|
incorrectTimeout = setTimeout(() => {
|
|
|
|
incorrectTimeout = setTimeout(() => {
|
|
|
|
repeats += repeats == 0 ? 3 : 1;
|
|
|
|
repeats += repeats == 0 ? 3 : 1;
|
|
|
|
|
|
|
|
failed = true;
|
|
|
|
wordDisplay.innerHTML = `${word} ❌`;
|
|
|
|
wordDisplay.innerHTML = `${word} ❌`;
|
|
|
|
|
|
|
|
incorrect.currentTime = 0;
|
|
|
|
|
|
|
|
incorrect.play();
|
|
|
|
for (let i = 0; i < word.length; i++) {
|
|
|
|
for (let i = 0; i < word.length; i++) {
|
|
|
|
const letter = word[i];
|
|
|
|
const letter = word[i];
|
|
|
|
let key = null;
|
|
|
|
let key = null;
|
|
|
@ -222,7 +235,7 @@ const reset = () => {
|
|
|
|
timer.value -= (1 / timerFPS) / typeTime;
|
|
|
|
timer.value -= (1 / timerFPS) / typeTime;
|
|
|
|
}, 1000 / timerFPS);
|
|
|
|
}, 1000 / timerFPS);
|
|
|
|
if (repeats > 0) {
|
|
|
|
if (repeats > 0) {
|
|
|
|
repeats -= 1;
|
|
|
|
repeats--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
reset();
|
|
|
|
reset();
|
|
|
|