mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 05:17:51 +08:00
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:
parent
067ce02ed7
commit
a6f1e62c7c
1 changed files with 17 additions and 23 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue