Fix layout emulator issues (#1957) by seerlite

* Reset #wordsInput when using layout emulator too

* Refactor input and fix emulation live acc
This commit is contained in:
SeerLite 2021-10-06 12:05:20 -03:00 committed by GitHub
parent 067ce02ed7
commit a6f1e62c7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,21 @@ function setWordsInput(value) {
}
}
function updateUI() {
let acc = Misc.roundTo2(TestStats.calculateAccuracy());
LiveAcc.update(acc);
if (Config.keymapMode === "next" && Config.mode !== "zen") {
Keymap.highlightKey(
TestLogic.words
.getCurrent()
.charAt(TestLogic.input.current.length)
.toString()
.toUpperCase()
);
}
}
function backspaceToPrevious() {
if (!TestLogic.active) return;
@ -718,16 +733,7 @@ $(document).keydown((event) => {
if (char !== null) {
event.preventDefault();
handleChar(char, TestLogic.input.current.length);
}
if (Config.keymapMode === "next" && Config.mode !== "zen") {
Keymap.highlightKey(
TestLogic.words
.getCurrent()
.charAt(TestLogic.input.current.length)
.toString()
.toUpperCase()
);
updateUI();
}
}
});
@ -787,19 +793,7 @@ $("#wordsInput").on("input", (event) => {
}
setWordsInput(" " + TestLogic.input.current);
let acc = Misc.roundTo2(TestStats.calculateAccuracy());
LiveAcc.update(acc);
if (Config.keymapMode === "next" && Config.mode !== "zen") {
Keymap.highlightKey(
TestLogic.words
.getCurrent()
.charAt(TestLogic.input.current.length)
.toString()
.toUpperCase()
);
}
updateUI();
// force caret at end of input
// doing it on next cycle because Chromium on Android won't let me edit