From 5d3bcb7ca28b94ab52dfeeb8c79fa0520bff2737 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Wed, 10 Dec 2025 20:46:36 +0200 Subject: [PATCH 01/15] fix(composition-display): Add compositionDisplay SettingsGroup (@Leonabcd123) (#7211) ### Description Add compositionDisplay SettingsGroup to allow users to select the value they want for the compositionDisplay setting. --- frontend/src/ts/config.ts | 7 +++++++ frontend/src/ts/pages/settings.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/frontend/src/ts/config.ts b/frontend/src/ts/config.ts index 1f447a12b532..e8d23a60c74b 100644 --- a/frontend/src/ts/config.ts +++ b/frontend/src/ts/config.ts @@ -629,6 +629,13 @@ export function setIndicateTypos( return genericSet("indicateTypos", value, nosave); } +export function setCompositionDisplay( + value: ConfigSchemas.CompositionDisplay, + nosave?: boolean, +): boolean { + return genericSet("compositionDisplay", value, nosave); +} + export function setAutoSwitchTheme( boolean: boolean, nosave?: boolean, diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 0c60509f463e..558d059a3843 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -204,6 +204,11 @@ async function initGroups(): Promise { UpdateConfig.setIndicateTypos, "button", ); + groups["compositionDisplay"] = new SettingsGroup( + "compositionDisplay", + UpdateConfig.setCompositionDisplay, + "button", + ); groups["hideExtraLetters"] = new SettingsGroup( "hideExtraLetters", UpdateConfig.setHideExtraLetters, From 6d8ef91155a4b62bda70238ee85636c3beccc54e Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Wed, 10 Dec 2025 21:00:38 +0200 Subject: [PATCH 02/15] fix(custom-text): Don't trim custom text (@Leonabcd123) (#7170) ### Description Removed the `.trim()` call that deleted leading and trailing literal tabs or newlines from custom text. This is to make sure that no matter what the custom text is, it will always stay the same after updating it. The current problem is that leading and trailing tabs and newlines will be removed when you click on "change" and "ok" for the second time (because they're now in their literal form, not \t and \n). --- frontend/src/ts/modals/custom-text.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/ts/modals/custom-text.ts b/frontend/src/ts/modals/custom-text.ts index 062bc6ffdcc0..b3396bcadcfa 100644 --- a/frontend/src/ts/modals/custom-text.ts +++ b/frontend/src/ts/modals/custom-text.ts @@ -269,7 +269,7 @@ function cleanUpText(): string[] { if (text === "") return []; - text = text.normalize().trim(); + text = text.normalize(); // text = text.replace(/[\r]/gm, " "); //replace any characters that look like a space with an actual space From de4e8729969e7d139b7faeeb6e136fa68d82f4a3 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Wed, 10 Dec 2025 21:09:30 +0200 Subject: [PATCH 03/15] fix(lazy-mode): Save lazy mode in local storage after getting not supported message (@Leonabcd123) (#7171) ### Description Save lazy mode status in local storage after getting the "This language does not support lazy mode" message. This is so the user doesn't get the same message every time they refresh, and it matches up with the settings that show that lazy mode is disabled even though it's enabled in local storage. --- frontend/src/ts/test/test-logic.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 7e18d352716e..824b86d48e23 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -400,6 +400,7 @@ export function restart(options = {} as RestartOptions): void { let lastInitError: Error | null = null; let rememberLazyMode: boolean; +let showedLazyModeNotification: boolean = false; let testReinitCount = 0; async function init(): Promise { @@ -494,7 +495,7 @@ async function init(): Promise { important: true, }, ); - UpdateConfig.setLazyMode(false, true); + UpdateConfig.setLazyMode(false, false); } else if (rememberLazyMode && anySupportsLazyMode) { UpdateConfig.setLazyMode(true, true); } @@ -502,10 +503,12 @@ async function init(): Promise { // normal mode if (Config.lazyMode && !allowLazyMode) { rememberLazyMode = true; + showedLazyModeNotification = true; Notifications.add("This language does not support lazy mode.", 0, { important: true, }); - UpdateConfig.setLazyMode(false, true); + + UpdateConfig.setLazyMode(false, false); } else if (rememberLazyMode && !language.noLazyMode) { UpdateConfig.setLazyMode(true, true); } @@ -1627,7 +1630,10 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => { ArabicLazyMode.set(eventValue as boolean); } if (eventValue === false) { - rememberLazyMode = false; + if (!showedLazyModeNotification) { + rememberLazyMode = false; + } + showedLazyModeNotification = false; } } }); From 204fffebe86e0481d0a785dd1eb567ecfd8de5a3 Mon Sep 17 00:00:00 2001 From: JuniorKlump Date: Thu, 11 Dec 2025 00:40:11 +0530 Subject: [PATCH 04/15] impr(quotes): add English quotes (@JuniorKlumpy) (#7180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description Added two new quotes as follows: >Everything should be made as simple as possible, but not simpler. – Albert Einstein >Do you see him? Do you see the story? Do you see anything? It seems I am trying to tell you a dream-making a vain attempt, because no relation of a dream can convey the dream-sensation, that commingling of absurdity, surprise, and bewilderment in a tremor of struggling revolt, that notion of being captured by the incredible which is the very essence of dreams. – Heart of Darkness --- frontend/static/quotes/english.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index dc1c8a50c0e8..784992e05f92 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -39087,6 +39087,18 @@ "source": "Undertale", "id": 7727, "length": 103 + }, + { + "text": "Everything should be made as simple as possible, but not simpler.", + "source": "Albert Einstein", + "id": 7728, + "length": 65 + }, + { + "text": "Do you see him? Do you see the story? Do you see anything? It seems I am trying to tell you a dream-making a vain attempt, because no relation of a dream can convey the dream-sensation, that commingling of absurdity, surprise, and bewilderment in a tremor of struggling revolt, that notion of being captured by the incredible which is the very essence of dreams.", + "source": "Heart of Darkness", + "id": 7729, + "length": 362 } ] } From 1dd0ca70ec590329e3964df45e0c3df0d55576d4 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 10 Dec 2025 20:34:37 +0100 Subject: [PATCH 05/15] refactor: begin transition away from jquery (@miodec, @fehmer) (#7185) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christian Fehmer Co-authored-by: Gian Peña <36643266+gianpena@users.noreply.github.com> Co-authored-by: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> --- .github/pull_request_template.md | 2 + docs/CONTRIBUTING_ADVANCED.md | 2 + frontend/__tests__/setup-tests.ts | 44 +- frontend/src/index.html | 2 +- frontend/src/styles/notifications.scss | 1 + frontend/src/ts/auth.ts | 40 +- frontend/src/ts/commandline/commandline.ts | 5 +- frontend/src/ts/controllers/ad-controller.ts | 67 +- .../ts/controllers/analytics-controller.ts | 3 +- .../ts/controllers/challenge-controller.ts | 13 +- .../src/ts/controllers/chart-controller.ts | 5 +- .../src/ts/controllers/eg-ad-controller.ts | 8 +- .../src/ts/controllers/page-controller.ts | 3 +- .../src/ts/controllers/sound-controller.ts | 2 +- .../src/ts/controllers/theme-controller.ts | 72 +-- frontend/src/ts/elements/account-button.ts | 55 +- frontend/src/ts/elements/alerts.ts | 159 +++-- frontend/src/ts/elements/character-counter.ts | 45 +- .../ts/elements/custom-background-filter.ts | 134 ++-- frontend/src/ts/elements/input-indicator.ts | 34 +- frontend/src/ts/elements/input-validation.ts | 62 +- frontend/src/ts/elements/keymap.ts | 66 +- frontend/src/ts/elements/loader.ts | 7 +- frontend/src/ts/elements/modes-notice.ts | 61 +- frontend/src/ts/elements/monkey-power.ts | 30 +- frontend/src/ts/elements/no-css.ts | 9 +- frontend/src/ts/elements/notifications.ts | 112 ++-- .../ts/elements/settings/fps-limit-section.ts | 23 +- .../ts/elements/settings/settings-group.ts | 41 +- frontend/src/ts/index.ts | 4 + frontend/src/ts/modals/edit-preset.ts | 13 +- frontend/src/ts/modals/edit-profile.ts | 56 +- frontend/src/ts/modals/google-sign-up.ts | 9 +- frontend/src/ts/modals/quote-report.ts | 3 +- frontend/src/ts/modals/quote-submit.ts | 3 +- frontend/src/ts/modals/save-custom-text.ts | 3 +- frontend/src/ts/modals/user-report.ts | 3 +- frontend/src/ts/pages/login.ts | 29 +- frontend/src/ts/pages/profile-search.ts | 5 +- frontend/src/ts/pages/settings.ts | 19 +- frontend/src/ts/ready.ts | 15 +- frontend/src/ts/ui.ts | 18 +- frontend/src/ts/utils/dom.ts | 604 ++++++++++++++++++ frontend/src/ts/utils/simple-modal.ts | 17 +- 44 files changed, 1309 insertions(+), 599 deletions(-) create mode 100644 frontend/src/ts/utils/dom.ts diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 23aeb691305d..05cea772f65b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,6 +4,8 @@ ### Checks +- [ ] Adding/modifying Typescript code? + - [ ] I have used `qs`,`qsa` or `qsr` instead of JQuery selectors. - [ ] Adding quotes? - [ ] Make sure to include translations for the quotes in the description (or another comment) so we can verify their content. - [ ] Adding a language? diff --git a/docs/CONTRIBUTING_ADVANCED.md b/docs/CONTRIBUTING_ADVANCED.md index b762aab97988..13c5d774c6d1 100644 --- a/docs/CONTRIBUTING_ADVANCED.md +++ b/docs/CONTRIBUTING_ADVANCED.md @@ -155,6 +155,8 @@ If you are on a UNIX system and you get a spawn error, run npm with `sudo`. Code formatting is enforced by [Prettier](https://prettier.io/docs/en/install.html), which automatically runs every time you make a commit. +We are currently in the process of converting from JQuery to vanilla JS. When submitting new code, please use the `qs`, `qsa` and `qsr` helper functions. These return a class with a lot of JQuery-like methods. You can read how they work and import them from `frontend/src/ts/utils/dom.ts`. + For guidelines on commit messages, adding themes, languages, or quotes, please refer to [CONTRIBUTING.md](./CONTRIBUTING.md). Following these guidelines will increase the chances of getting your change accepted. ## Questions diff --git a/frontend/__tests__/setup-tests.ts b/frontend/__tests__/setup-tests.ts index ce5a30cf562a..43b2255ae136 100644 --- a/frontend/__tests__/setup-tests.ts +++ b/frontend/__tests__/setup-tests.ts @@ -18,6 +18,44 @@ vi.mock("../src/ts/firebase", () => ({ isAuthenticated: () => false, })); -const input = document.createElement("input"); -input.id = "wordsInput"; -document.body.appendChild(input); +vi.mock("../src/ts/utils/dom", () => { + const createMockElement = (): any => { + const mock = { + qsr: vi.fn(), + qs: vi.fn().mockReturnValue(null), + find: vi.fn(), + addClass: vi.fn(), + removeClass: vi.fn(), + hide: vi.fn(), + show: vi.fn(), + setText: vi.fn(), + prependHtml: vi.fn(), + empty: vi.fn(), + appendHtml: vi.fn(), + native: document.createElement("div"), + }; + + // Make chainable methods return the mock itself + mock.qsr.mockImplementation(() => createMockElement()); + mock.addClass.mockReturnValue(mock); + mock.removeClass.mockReturnValue(mock); + mock.hide.mockReturnValue(mock); + mock.show.mockReturnValue(mock); + mock.setText.mockReturnValue(mock); + mock.prependHtml.mockReturnValue(mock); + mock.empty.mockReturnValue(mock); + + return mock; + }; + + return { + qsr: vi.fn().mockImplementation(() => createMockElement()), + qs: vi.fn().mockImplementation(() => createMockElement()), + qsa: vi.fn().mockReturnValue([]), + }; +}); + +// Mock document.querySelector to return a div +global.document.querySelector = vi + .fn() + .mockReturnValue(document.createElement("div")); diff --git a/frontend/src/index.html b/frontend/src/index.html index a8491bf061dc..c514c2b85840 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -10,7 +10,7 @@
-