diff options
| author | Ivan Gabaldon <igabaldon@inetol.net> | 2025-12-02 10:18:00 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-02 10:18:00 +0000 |
| commit | fb089ae297b27f51777318e3a28bca8b172a4165 (patch) | |
| tree | 293e17a6ba3a7ae17c31bc6746794b97c012c6af /searx/static/themes/simple/js/infinite_scroll.min.js.map | |
| parent | ab8224c9394236d2cbcf6ec7d9bf0d7c602ca6ac (diff) | |
[mod] client/simple: client plugins (#5406)
* [mod] client/simple: client plugins
Defines a new interface for client side *"plugins"* that coexist with server
side plugin system. Each plugin (e.g., `InfiniteScroll`) extends the base
`ts Plugin`. Client side plugins are independent and lazy‑loaded via `router.ts`
when their `load()` conditions are met. On each navigation request, all
applicable plugins are instanced.
Since these are client side plugins, we can only invoke them once DOM is fully
loaded. E.g. `Calculator` will not render a new `answer` block until fully
loaded and executed.
For some plugins, we might want to handle its availability in `settings.yml`
and toggle in UI, like we do for server side plugins. In that case, we extend
`py Plugin` instancing only the information and then checking client side if
[`settings.plugins`](https://github.com/inetol/searxng/blob/1ad832b1dc33f3f388da361ff2459b05dc86a164/client/simple/src/js/toolkit.ts#L134)
array has the plugin id.
* [mod] client/simple: rebuild static
Diffstat (limited to 'searx/static/themes/simple/js/infinite_scroll.min.js.map')
| -rw-r--r-- | searx/static/themes/simple/js/infinite_scroll.min.js.map | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/searx/static/themes/simple/js/infinite_scroll.min.js.map b/searx/static/themes/simple/js/infinite_scroll.min.js.map deleted file mode 100644 index 686d1f0e4..000000000 --- a/searx/static/themes/simple/js/infinite_scroll.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"infinite_scroll.min.js","names":["resultsElement: HTMLElement | null","onlyImages: boolean","intersectionObserveOptions: IntersectionObserverInit","observer: IntersectionObserver","initialObservedElement: HTMLElement | null"],"sources":["../../../../../client/simple/src/js/main/infinite_scroll.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { assertElement, http, settings } from \"../core/toolkit.ts\";\n\nconst newLoadSpinner = (): HTMLDivElement => {\n return Object.assign(document.createElement(\"div\"), {\n className: \"loader\"\n });\n};\n\nconst loadNextPage = async (onlyImages: boolean, callback: () => void): Promise<void> => {\n const searchForm = document.querySelector<HTMLFormElement>(\"#search\");\n assertElement(searchForm);\n\n const form = document.querySelector<HTMLFormElement>(\"#pagination form.next_page\");\n assertElement(form);\n\n const action = searchForm.getAttribute(\"action\");\n if (!action) {\n throw new Error(\"Form action not defined\");\n }\n\n const paginationElement = document.querySelector<HTMLElement>(\"#pagination\");\n assertElement(paginationElement);\n\n paginationElement.replaceChildren(newLoadSpinner());\n\n try {\n const res = await http(\"POST\", action, { body: new FormData(form) });\n const nextPage = await res.text();\n if (!nextPage) return;\n\n const nextPageDoc = new DOMParser().parseFromString(nextPage, \"text/html\");\n const articleList = nextPageDoc.querySelectorAll<HTMLElement>(\"#urls article\");\n const nextPaginationElement = nextPageDoc.querySelector<HTMLElement>(\"#pagination\");\n\n document.querySelector(\"#pagination\")?.remove();\n\n const urlsElement = document.querySelector<HTMLElement>(\"#urls\");\n if (!urlsElement) {\n throw new Error(\"URLs element not found\");\n }\n\n if (articleList.length > 0 && !onlyImages) {\n // do not add <hr> element when there are only images\n urlsElement.appendChild(document.createElement(\"hr\"));\n }\n\n urlsElement.append(...Array.from(articleList));\n\n if (nextPaginationElement) {\n const results = document.querySelector<HTMLElement>(\"#results\");\n results?.appendChild(nextPaginationElement);\n callback();\n }\n } catch (error) {\n console.error(\"Error loading next page:\", error);\n\n const errorElement = Object.assign(document.createElement(\"div\"), {\n textContent: settings.translations?.error_loading_next_page ?? \"Error loading next page\",\n className: \"dialog-error\"\n });\n errorElement.setAttribute(\"role\", \"alert\");\n document.querySelector(\"#pagination\")?.replaceChildren(errorElement);\n }\n};\n\nconst resultsElement: HTMLElement | null = document.getElementById(\"results\");\nif (!resultsElement) {\n throw new Error(\"Results element not found\");\n}\n\nconst onlyImages: boolean = resultsElement.classList.contains(\"only_template_images\");\nconst observedSelector = \"article.result:last-child\";\n\nconst intersectionObserveOptions: IntersectionObserverInit = {\n rootMargin: \"320px\"\n};\n\nconst observer: IntersectionObserver = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {\n const [paginationEntry] = entries;\n\n if (paginationEntry?.isIntersecting) {\n observer.unobserve(paginationEntry.target);\n\n void loadNextPage(onlyImages, () => {\n const nextObservedElement = document.querySelector<HTMLElement>(observedSelector);\n if (nextObservedElement) {\n observer.observe(nextObservedElement);\n }\n }).then(() => {\n // wait until promise is resolved\n });\n }\n}, intersectionObserveOptions);\n\nconst initialObservedElement: HTMLElement | null = document.querySelector<HTMLElement>(observedSelector);\nif (initialObservedElement) {\n observer.observe(initialObservedElement);\n}\n"],"mappings":"wDAIA,IAAM,MACG,OAAO,OAAO,SAAS,cAAc,MAAM,CAAE,CAClD,UAAW,SACZ,CAAC,CAGE,EAAe,MAAO,EAAqB,IAAwC,CACvF,IAAM,EAAa,SAAS,cAA+B,UAAU,CACrE,EAAc,EAAW,CAEzB,IAAM,EAAO,SAAS,cAA+B,6BAA6B,CAClF,EAAc,EAAK,CAEnB,IAAM,EAAS,EAAW,aAAa,SAAS,CAChD,GAAI,CAAC,EACH,MAAU,MAAM,0BAA0B,CAG5C,IAAM,EAAoB,SAAS,cAA2B,cAAc,CAC5E,EAAc,EAAkB,CAEhC,EAAkB,gBAAgB,GAAgB,CAAC,CAEnD,GAAI,CAEF,IAAM,EAAW,MADL,MAAM,EAAK,OAAQ,EAAQ,CAAE,KAAM,IAAI,SAAS,EAAK,CAAE,CAAC,EACzC,MAAM,CACjC,GAAI,CAAC,EAAU,OAEf,IAAM,EAAc,IAAI,WAAW,CAAC,gBAAgB,EAAU,YAAY,CACpE,EAAc,EAAY,iBAA8B,gBAAgB,CACxE,EAAwB,EAAY,cAA2B,cAAc,CAEnF,SAAS,cAAc,cAAc,EAAE,QAAQ,CAE/C,IAAM,EAAc,SAAS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