From 0b913053a76e83a43846e19097963f98c8519a1d Mon Sep 17 00:00:00 2001 From: Ivan Gabaldon Date: Sun, 6 Jul 2025 12:27:28 +0200 Subject: [mod] theme/simple: migrate codebase to TypeScript TypeScript is a superset of JavaScript, converting the entire theme to TypeScript allows us to receive much more feedback on possible issues made in package updates or our own typos, furthermore, it allows to transpile properly to lower specs. This PR couldn't be done in smaller commits, a lot of work needed to make everything *work properly*: - A browser baseline has been set that requires minimum **Chromium 93, Firefox 92 and Safari 15** (proper visuals/operation on older browser versions is not guaranteed) - LightningCSS now handles minification and prefix creation for CSS. - All hardcoded polyfills and support for previous browser baseline versions have been removed. - Convert codebase to TypeScript. - Convert IIFE to ESM, handling globals with IIFE is cumbersome, ESM is the standard for virtually any use of JS nowadays. - Vite now builds the theme without the need for `vite-plugin-static-copy`. - `searxng.ready` now accepts an array of conditions for the callback to be executed. - Replace `leaflet` with `ol` as there were some issues with proper Vite bundling. - Merged `head` with `main` script, as head was too small now. - Add `assertElement` to properly check the existence of critical DOM elements. - `searxng.on` renamed to `searxng.listen` with some handling improvements. --- client/simple/src/js/main/preferences.js | 52 -------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 client/simple/src/js/main/preferences.js (limited to 'client/simple/src/js/main/preferences.js') diff --git a/client/simple/src/js/main/preferences.js b/client/simple/src/js/main/preferences.js deleted file mode 100644 index ac080e290..000000000 --- a/client/simple/src/js/main/preferences.js +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -((_w, d, searxng) => { - if (searxng.endpoint !== "preferences") { - return; - } - - searxng.ready(() => { - let engine_descriptions = null; - - function load_engine_descriptions() { - if (engine_descriptions == null) { - searxng.http("GET", "engine_descriptions.json").then((content) => { - engine_descriptions = JSON.parse(content); - for (const [engine_name, description] of Object.entries(engine_descriptions)) { - const elements = d.querySelectorAll(`[data-engine-name="${engine_name}"] .engine-description`); - for (const element of elements) { - const source = ` (${searxng.settings.translations.Source}: ${description[1]})`; - element.innerHTML = description[0] + source; - } - } - }); - } - } - - for (const el of d.querySelectorAll("[data-engine-name]")) { - searxng.on(el, "mouseenter", load_engine_descriptions); - } - - const enableAllEngines = d.querySelectorAll(".enable-all-engines"); - const disableAllEngines = d.querySelectorAll(".disable-all-engines"); - const engineToggles = d.querySelectorAll("tbody input[type=checkbox][class~=checkbox-onoff]"); - const toggleEngines = (enable) => { - for (const el of engineToggles) { - // check if element visible, so that only engines of the current category are modified - if (el.offsetParent !== null) el.checked = !enable; - } - }; - for (const el of enableAllEngines) { - searxng.on(el, "click", () => toggleEngines(true)); - } - for (const el of disableAllEngines) { - searxng.on(el, "click", () => toggleEngines(false)); - } - - const copyHashButton = d.querySelector("#copy-hash"); - searxng.on(copyHashButton, "click", (e) => { - e.preventDefault(); - navigator.clipboard.writeText(copyHashButton.dataset.hash); - copyHashButton.innerText = copyHashButton.dataset.copiedText; - }); - }); -})(window, document, window.searxng); -- cgit v1.2.3