moved caps warning to a module #495

This commit is contained in:
Miodec 2021-03-16 09:56:35 +00:00
parent 5dc5b71e92
commit b89d4fa56e
4 changed files with 28 additions and 22 deletions

View file

@ -114,6 +114,7 @@ const refactoredSrc = [
"./src/js/test/test-ui.js",
"./src/js/test/keymap.js",
"./src/js/test/live-wpm.js",
"./src/js/test/caps-warning.js",
];
//legacy files

View file

@ -43,3 +43,4 @@ import * as PractiseMissed from "./practise-missed";
import * as TestUI from "./test-ui";
import * as Keymap from "./keymap";
import * as LiveWpm from "./live-wpm";
import * as CapsWarning from "./caps-warning";

View file

@ -3173,18 +3173,6 @@ function tagsEdit() {
}
}
function showCapsWarning() {
if ($("#capsWarning").hasClass("hidden")) {
$("#capsWarning").removeClass("hidden");
}
}
function hideCapsWarning() {
if (!$("#capsWarning").hasClass("hidden")) {
$("#capsWarning").addClass("hidden");
}
}
function showCustomMode2Popup(mode) {
if ($("#customMode2PopupWrapper").hasClass("hidden")) {
if (mode == "time") {
@ -3997,16 +3985,6 @@ $(document).keydown(function (event) {
// keypressStats.duration.current = performance.now();
TestStats.setKeypressDuration(performance.now());
try {
if (
!Config.capsLockBackspace &&
event.originalEvent.getModifierState("CapsLock")
) {
showCapsWarning();
} else {
hideCapsWarning();
}
} catch {}
if (TestUI.testRestarting) {
return;

View file

@ -0,0 +1,26 @@
import Config from "./config";
function show() {
if ($("#capsWarning").hasClass("hidden")) {
$("#capsWarning").removeClass("hidden");
}
}
function hide() {
if (!$("#capsWarning").hasClass("hidden")) {
$("#capsWarning").addClass("hidden");
}
}
$(document).keydown(function (event) {
try {
if (
!Config.capsLockBackspace &&
event.originalEvent.getModifierState("CapsLock")
) {
show();
} else {
hide();
}
} catch {}
});