mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-04 20:47:54 +08:00
moved caps warning to a module #495
This commit is contained in:
parent
5dc5b71e92
commit
b89d4fa56e
4 changed files with 28 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
|
26
src/js/test/caps-warning.js
Normal file
26
src/js/test/caps-warning.js
Normal 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 {}
|
||||
});
|
Loading…
Add table
Reference in a new issue