Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
be29e24
Convert
Leonabcd123 Jan 7, 2026
5fdc839
Add default value
Leonabcd123 Jan 7, 2026
c2f5d21
Merge branch 'master' into bye-jquery-test
Leonabcd123 Jan 7, 2026
15adadc
Add getChildren
Leonabcd123 Jan 7, 2026
047c158
Add back getChildren
Leonabcd123 Jan 7, 2026
45aaa74
Chain
Leonabcd123 Jan 7, 2026
a33be62
Return ElementsWithUtils
Leonabcd123 Jan 7, 2026
2e4509b
Fix qsa warning
Leonabcd123 Jan 7, 2026
58c6e12
fehmer
Leonabcd123 Jan 7, 2026
5c5d6af
Remove comments
Leonabcd123 Jan 7, 2026
db0e29c
Remove getElementIndex
Leonabcd123 Jan 7, 2026
d0e63b8
Merge branch 'master' into bye-jquery-test
Leonabcd123 Jan 7, 2026
d41a701
Merge branch 'master' into bye-jquery-test
Leonabcd123 Jan 11, 2026
f4d5d4c
Merge branch 'master' into pr/Leonabcd123/7325
Miodec Jan 14, 2026
b090fe1
Merge branch 'master' into bye-jquery-test
Leonabcd123 Jan 14, 2026
f2e57c5
Remove jquery from test-screenshot
Leonabcd123 Jan 15, 2026
c40460b
Complete
Leonabcd123 Jan 15, 2026
7d18970
Remove jQuery from test-logic
Leonabcd123 Jan 15, 2026
69785b0
Remove jQuery from result
Leonabcd123 Jan 18, 2026
4a2c3b5
Remove jQuery from test-config
Leonabcd123 Jan 18, 2026
3edba28
Replace native dom with dom utils
Leonabcd123 Jan 19, 2026
ea58306
Merge branch 'master' into bye-jquery-test
Leonabcd123 Jan 19, 2026
8ee3417
Remove jquery from funbox-functions
Leonabcd123 Jan 19, 2026
881718f
Don't accept jQuery
Leonabcd123 Jan 19, 2026
a333c11
Merge branch 'master' into pr/Leonabcd123/7325
Miodec Jan 21, 2026
b5976e1
Accept KeyboardEvent
Leonabcd123 Jan 21, 2026
3db8a37
finish
Miodec Jan 21, 2026
7b097d7
Update frontend/src/ts/observables/connection-event.ts
Miodec Jan 21, 2026
1ec63a0
remove
Miodec Jan 21, 2026
9dc457d
rename
Miodec Jan 21, 2026
421447e
fix
Miodec Jan 21, 2026
275f67a
improve utils
Miodec Jan 21, 2026
9437d15
No ??
Leonabcd123 Jan 21, 2026
13b6731
Return this
Leonabcd123 Jan 21, 2026
d9a2721
Remove getChildren
Leonabcd123 Jan 21, 2026
1f56b93
use getchildren
Miodec Jan 21, 2026
0a6a084
Don't spread
Leonabcd123 Jan 21, 2026
ff61f4a
Don't spread
Leonabcd123 Jan 21, 2026
1544459
filter after split
Miodec Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions frontend/__tests__/test/layout-emulator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ describe("LayoutEmulator", () => {
updateAltGrState(event);
});

const createEvent = (
code: string,
type: string,
): JQuery.KeyboardEventBase =>
const createEvent = (code: string, type: string): KeyboardEvent =>
({
code,
type,
}) as JQuery.KeyboardEventBase;
}) as KeyboardEvent;

it("should set isAltGrPressed to true on AltRight keydown", () => {
const event = createEvent("AltRight", "keydown");
Expand Down
25 changes: 9 additions & 16 deletions frontend/src/ts/test/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import * as TimerProgress from "./timer-progress";
import * as PageTransition from "../states/page-transition";
import { requestDebouncedAnimationFrame } from "../utils/debounced-animation-frame";
import { getFocus, setFocus } from "../signals/core";
import { qsa, ElementsWithUtils } from "../utils/dom";

const unfocusPx = 3;

let cacheReady = false;
let cache: {
focus?: HTMLElement[];
cursor?: HTMLElement[];
focus?: ElementsWithUtils;
cursor?: ElementsWithUtils;
} = {};

function initializeCache(): void {
Expand All @@ -33,8 +34,8 @@ function initializeCache(): void {
"#ad-footer-small-wrapper",
].join(",");

cache.cursor = [...document.querySelectorAll<HTMLElement>(cursorSelector)];
cache.focus = [...document.querySelectorAll<HTMLElement>(elementsSelector)];
cache.cursor = qsa(cursorSelector);
cache.focus = qsa(elementsSelector);

cacheReady = true;
}
Expand All @@ -50,14 +51,10 @@ export function set(value: boolean, withCursor = false): void {

// batch DOM operations for better performance
if (cache.focus) {
for (const el of cache.focus) {
el.classList.add("focus");
}
cache.focus.addClass("focus");
}
if (!withCursor && cache.cursor) {
for (const el of cache.cursor) {
el.style.cursor = "none";
}
cache.cursor.setStyle({ cursor: "none" });
}

Caret.stopAnimation();
Expand All @@ -69,14 +66,10 @@ export function set(value: boolean, withCursor = false): void {
setFocus(false);

if (cache.focus) {
for (const el of cache.focus) {
el.classList.remove("focus");
}
cache.focus.removeClass("focus");
}
if (cache.cursor) {
for (const el of cache.cursor) {
el.style.cursor = "";
}
cache.cursor.setStyle({ cursor: "" });
}

Caret.startAnimation();
Expand Down
23 changes: 12 additions & 11 deletions frontend/src/ts/test/funbox/funbox-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import * as TestState from "../test-state";
import { WordGenError } from "../../utils/word-gen-error";
import { FunboxName, KeymapLayout, Layout } from "@monkeytype/schemas/configs";
import { Language, LanguageObject } from "@monkeytype/schemas/languages";
import { qs } from "../../utils/dom";

export type FunboxFunctions = {
getWord?: (wordset?: Wordset, wordIndex?: number) => string;
Expand Down Expand Up @@ -61,9 +62,9 @@ async function readAheadHandleKeydown(event: KeyboardEvent): Promise<void> {
TestWords.words.get(TestState.activeWordIndex - 1) ||
Config.freedomMode)
) {
$("#words").addClass("read_ahead_disabled");
qs("#words")?.addClass("read_ahead_disabled");
} else if (event.key === " ") {
$("#words").removeClass("read_ahead_disabled");
qs("#words")?.removeClass("read_ahead_disabled");
}
}

Expand Down Expand Up @@ -510,7 +511,7 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
},
memory: {
applyConfig(): void {
$("#wordsWrapper").addClass("hidden");
qs("#wordsWrapper")?.hide();
setConfig("showAllLines", true, {
nosave: true,
});
Expand All @@ -529,11 +530,11 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
},
start(): void {
MemoryTimer.reset();
$("#words").addClass("hidden");
qs("#words")?.hide();
},
restart(): void {
MemoryTimer.start(Math.round(Math.pow(TestWords.words.length, 1.2)));
$("#words").removeClass("hidden");
qs("#words")?.show();
if (Config.keymapMode === "next") {
setConfig("keymapMode", "react");
}
Expand Down Expand Up @@ -672,14 +673,14 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
return;
}
}
$("body").append('<div id="scanline" />');
$("body").addClass("crtmode");
$("#globalFunBoxTheme").attr("href", `funbox/crt.css`);
qs("body")?.appendHtml('<div id="scanline" />');
qs("body")?.addClass("crtmode");
qs("#globalFunBoxTheme")?.setAttribute("href", `funbox/crt.css`);
},
clearGlobal(): void {
$("#scanline").remove();
$("body").removeClass("crtmode");
$("#globalFunBoxTheme").attr("href", ``);
qs("#scanline")?.remove();
qs("body")?.removeClass("crtmode");
qs("#globalFunBoxTheme")?.setAttribute("href", ``);
},
},
ALL_CAPS: {
Expand Down
23 changes: 12 additions & 11 deletions frontend/src/ts/test/funbox/funbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from "./list";
import { checkForcedConfig } from "./funbox-validation";
import { tryCatch } from "@monkeytype/util/trycatch";
import { qs } from "../../utils/dom";

export function toggleScript(...params: string[]): void {
if (Config.funbox.length === 0) return;
Expand Down Expand Up @@ -66,18 +67,18 @@ export function toggleFunbox(funbox: FunboxName): void {
}

export async function clear(): Promise<boolean> {
$("body").attr(
qs("body")?.setAttribute(
"class",
$("body")
?.attr("class")
qs("body")
?.getAttribute("class")
?.split(/\s+/)
?.filter((it) => !it.startsWith("fb-"))
?.join(" ") ?? "",
);

$(".funBoxTheme").remove();
qs(".funBoxTheme")?.remove();

$("#wordsWrapper").removeClass("hidden");
qs("#wordsWrapper")?.show();
MemoryTimer.reset();
ManualRestart.set();
return true;
Expand Down Expand Up @@ -115,7 +116,7 @@ export async function activate(
await setFunboxBodyClasses();
await applyFunboxCSS();

$("#wordsWrapper").removeClass("hidden");
qs("#wordsWrapper")?.show();

const { data: language, error } = await tryCatch(
JSONData.getCurrentLanguage(Config.language),
Expand Down Expand Up @@ -216,23 +217,23 @@ export async function rememberSettings(): Promise<void> {
}

async function setFunboxBodyClasses(): Promise<boolean> {
const $body = $("body");
const body = qs("body");

const activeFbClasses = getActiveFunboxNames().map(
(name) => "fb-" + name.replaceAll("_", "-"),
);

const currentClasses =
$body
?.attr("class")
body
?.getAttribute("class")
?.split(/\s+/)
.filter((it) => !it.startsWith("fb-")) ?? [];

if (isFunboxActiveWithProperty("ignoreReducedMotion")) {
currentClasses.push("ignore-reduced-motion");
}

$body.attr(
body?.setAttribute(
"class",
[...new Set([...currentClasses, ...activeFbClasses]).keys()].join(" "),
);
Expand All @@ -241,7 +242,7 @@ async function setFunboxBodyClasses(): Promise<boolean> {
}

async function applyFunboxCSS(): Promise<boolean> {
$(".funBoxTheme").remove();
qs(".funBoxTheme")?.remove();
for (const funbox of getActiveFunboxesWithProperty("hasCssFile")) {
const css = document.createElement("link");
css.classList.add("funBoxTheme");
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/ts/test/funbox/layoutfluid-funbox-timer.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import { animate } from "animejs";
import { capitalizeFirstLetter } from "../../utils/strings";
import { applyReducedMotion } from "../../utils/misc";
import { qs } from "../../utils/dom";

const timerEl = document.querySelector(
"#typingTest #layoutfluidTimer",
) as HTMLElement;
const timerEl = qs("#typingTest #layoutfluidTimer");

export function show(): void {
animate(timerEl, {
timerEl?.animate({
opacity: 1,
duration: applyReducedMotion(125),
});
}

export function hide(): void {
animate(timerEl, {
timerEl?.animate({
opacity: 0,
duration: applyReducedMotion(125),
});
}

export function instantHide(): void {
timerEl.style.opacity = "0";
timerEl?.setStyle({ opacity: "0" });
}

export function updateTime(sec: number, layout: string): void {
timerEl.textContent = `${capitalizeFirstLetter(layout)} in: ${sec}s`;
timerEl?.setText(`${capitalizeFirstLetter(layout)} in: ${sec}s`);
}

export function updateWords(words: number, layout: string): void {
Expand All @@ -34,5 +32,5 @@ export function updateWords(words: number, layout: string): void {
if (words === 1) {
str = `${layoutName} starting next word`;
}
timerEl.textContent = str;
timerEl?.setText(str);
}
14 changes: 6 additions & 8 deletions frontend/src/ts/test/funbox/memory-funbox-timer.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { animate } from "animejs";
import { applyReducedMotion } from "../../utils/misc";
import { qs } from "../../utils/dom";

let memoryTimer: number | null = null;
let memoryInterval: NodeJS.Timeout | null = null;

const timerEl = document.querySelector(
"#typingTest #memoryTimer",
) as HTMLElement;
const timerEl = qs("#typingTest #memoryTimer");

export function show(): void {
animate(timerEl, {
timerEl?.animate({
opacity: 1,
duration: applyReducedMotion(125),
});
}

export function hide(): void {
animate(timerEl, {
timerEl?.animate({
opacity: 0,
duration: applyReducedMotion(125),
});
Expand All @@ -42,11 +40,11 @@ export function start(time: number): void {
memoryTimer === 0 ? hide() : update(memoryTimer);
if (memoryTimer <= 0) {
reset();
$("#wordsWrapper").addClass("hidden");
qs("#wordsWrapper")?.hide();
}
}, 1000);
}

export function update(sec: number): void {
timerEl.textContent = `Timer left to memorise all words: ${sec}s`;
timerEl?.setText(`Timer left to memorise all words: ${sec}s`);
}
10 changes: 5 additions & 5 deletions frontend/src/ts/test/layout-emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ let isAltGrPressed = false;
const isPunctuationPattern = /\p{P}/u;

export async function getCharFromEvent(
event: JQuery.KeyDownEvent | JQuery.KeyUpEvent | KeyboardEvent,
event: KeyboardEvent,
): Promise<string | null> {
function emulatedLayoutGetVariant(
event: JQuery.KeyDownEvent | JQuery.KeyUpEvent | KeyboardEvent,
event: KeyboardEvent,
keyVariants: string[],
): string | undefined {
let isCapitalized = event.shiftKey;
Expand Down Expand Up @@ -238,7 +238,7 @@ export async function getCharFromEvent(
}
}

export function updateAltGrState(event: JQuery.KeyboardEventBase): void {
export function updateAltGrState(event: KeyboardEvent): void {
const shouldHandleLeftAlt =
event.code === "AltLeft" && navigator.userAgent.includes("Mac");
if (event.code !== "AltRight" && !shouldHandleLeftAlt) return;
Expand All @@ -250,5 +250,5 @@ export function getIsAltGrPressed(): boolean {
return isAltGrPressed;
}

$(document).on("keydown", updateAltGrState);
$(document).on("keyup", updateAltGrState);
document.addEventListener("keydown", updateAltGrState);
document.addEventListener("keyup", updateAltGrState);
Loading