Skip to content

Commit e440b45

Browse files
minor migrations of isolated components
1 parent 7e33f9a commit e440b45

File tree

8 files changed

+52
-37
lines changed

8 files changed

+52
-37
lines changed

frontend/src/ts/elements/settings/account-settings-notice.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ const ls = new LocalStorageWithSchema({
88
fallback: false,
99
});
1010

11+
const noticeSelector = ".pageSettings .accountSettingsNotice";
12+
1113
if (ls.get()) {
12-
$(".pageSettings .accountSettingsNotice").remove();
14+
document.querySelector(noticeSelector)?.remove();
1315
}
1416

15-
$(".pageSettings .accountSettingsNotice .dismissAndGo").on("click", () => {
16-
ls.set(true);
17-
void navigate("/account-settings");
18-
$(".pageSettings .accountSettingsNotice").remove();
19-
});
17+
document
18+
.querySelector(`${noticeSelector} .dismissAndGo`)
19+
?.addEventListener("click", () => {
20+
ls.set(true);
21+
void navigate("/account-settings");
22+
document.querySelector(noticeSelector)?.remove();
23+
});

frontend/src/ts/elements/version-button.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import { isDevEnvironment } from "../utils/misc";
22
import * as Version from "../states/version";
33

44
function setText(text: string): void {
5-
$("footer .currentVersion .text").text(text);
5+
const el = document.querySelector("footer .currentVersion .text");
6+
if (el) el.textContent = text;
67
}
78

89
function setIndicatorVisible(state: boolean): void {
9-
if (state) {
10-
$("#newVersionIndicator").removeClass("hidden");
11-
} else {
12-
$("#newVersionIndicator").addClass("hidden");
13-
}
10+
const indicator = document.getElementById("newVersionIndicator");
11+
indicator?.classList.toggle("hidden", !state);
1412
}
1513

1614
export async function update(): Promise<void> {
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as Commandline from "../commandline/commandline";
22

3-
$("#keymap").on("click", ".r5 .layoutIndicator", async () => {
4-
Commandline.show({
5-
subgroupOverride: "keymapLayouts",
6-
});
3+
document.getElementById("keymap")?.addEventListener("click", (e) => {
4+
if ((e.target as Element).closest(".r5 .layoutIndicator")) {
5+
Commandline.show({
6+
subgroupOverride: "keymapLayouts",
7+
});
8+
}
79
});

frontend/src/ts/event-handlers/login.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as ForgotPasswordModal from "../modals/forgot-password";
22

33
const loginPage = document.querySelector("#pageLogin") as HTMLElement;
44

5-
$(loginPage).on("click", "#forgotPasswordButton", () => {
6-
ForgotPasswordModal.show();
5+
loginPage?.addEventListener("click", (e) => {
6+
if ((e.target as Element).closest("#forgotPasswordButton")) {
7+
ForgotPasswordModal.show();
8+
}
79
});

frontend/src/ts/states/connection.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ const throttledHandleState = debounce(5000, () => {
3333
Notifications.add("You're back online", 1, {
3434
customTitle: "Connection",
3535
});
36-
$(
37-
`#bannerCenter .psa.notice[id="${noInternetBannerId}"] .closeButton`,
38-
).trigger("click");
36+
document
37+
.querySelector(
38+
`#bannerCenter .psa.notice[id="${noInternetBannerId}"] .closeButton`,
39+
)
40+
?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
3941
}
4042
bannerAlreadyClosed = false;
4143
} else if (!TestState.isActive) {

frontend/src/ts/test/funbox/memory-funbox-timer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function start(time: number): void {
4242
memoryTimer === 0 ? hide() : update(memoryTimer);
4343
if (memoryTimer <= 0) {
4444
reset();
45-
$("#wordsWrapper").addClass("hidden");
45+
document.getElementById("wordsWrapper")?.classList.add("hidden");
4646
}
4747
}, 1000);
4848
}

frontend/src/ts/test/out-of-focus.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@ import Config from "../config";
33

44
const outOfFocusTimeouts: (number | NodeJS.Timeout)[] = [];
55

6+
const blurTargets = "#words, #compositionDisplay";
7+
68
export function hide(): void {
7-
$("#words, #compositionDisplay")
8-
.css("transition", "none")
9-
.removeClass("blurred");
10-
$(".outOfFocusWarning").addClass("hidden");
9+
document.querySelectorAll(blurTargets).forEach((el) => {
10+
(el as HTMLElement).style.transition = "none";
11+
el.classList.remove("blurred");
12+
});
13+
document.querySelector(".outOfFocusWarning")?.classList.add("hidden");
1114
Misc.clearTimeouts(outOfFocusTimeouts);
1215
}
1316

1417
export function show(): void {
1518
if (!Config.showOutOfFocusWarning) return;
1619
outOfFocusTimeouts.push(
1720
setTimeout(() => {
18-
$("#words, #compositionDisplay")
19-
.css("transition", "0.25s")
20-
.addClass("blurred");
21-
$(".outOfFocusWarning").removeClass("hidden");
21+
document.querySelectorAll(blurTargets).forEach((el) => {
22+
(el as HTMLElement).style.transition = "0.25s";
23+
el.classList.add("blurred");
24+
});
25+
document.querySelector(".outOfFocusWarning")?.classList.remove("hidden");
2226
}, 1000),
2327
);
2428
}

frontend/src/ts/test/pb-crown.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { applyReducedMotion } from "../utils/misc";
33

44
export function hide(): void {
55
visible = false;
6-
$("#result .stats .wpm .crown").css("opacity", 0).addClass("hidden");
6+
const crown = document.querySelector("#result .stats .wpm .crown") as HTMLElement | null;
7+
if (crown) {
8+
crown.style.opacity = "0";
9+
crown.classList.add("hidden");
10+
}
711
}
812

913
export type CrownType =
@@ -38,10 +42,9 @@ export function show(): void {
3842

3943
export function update(type: CrownType): void {
4044
currentType = type;
41-
const el = $("#result .stats .wpm .crown");
42-
el.removeClass("ineligible");
43-
el.removeClass("pending");
44-
el.removeClass("error");
45-
el.removeClass("warning");
46-
el.addClass(type);
45+
const crown = document.querySelector("#result .stats .wpm .crown");
46+
if (crown) {
47+
crown.classList.remove("ineligible", "pending", "error", "warning");
48+
crown.classList.add(type);
49+
}
4750
}

0 commit comments

Comments
 (0)