diff options
author | Alan Pearce | 2025-03-22 18:04:43 +0100 |
---|---|---|
committer | Alan Pearce | 2025-03-22 18:04:43 +0100 |
commit | 4554d524916e48b18b4c669fe64bc8d54a148c59 (patch) | |
tree | 64fee632f9771f7a08f0f4e63910cb1849a58b7a | |
parent | 6f21abc4c10f69d351573599e033394db9b279b0 (diff) | |
download | searchix-4554d524916e48b18b4c669fe64bc8d54a148c59.tar.lz searchix-4554d524916e48b18b4c669fe64bc8d54a148c59.tar.zst searchix-4554d524916e48b18b4c669fe64bc8d54a148c59.zip |
docs: add JSDoc comments to javascript functions
-rw-r--r-- | frontend/static/search.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/frontend/static/search.js b/frontend/static/search.js index e16c83c..445a788 100644 --- a/frontend/static/search.js +++ b/frontend/static/search.js @@ -28,6 +28,10 @@ if (window.trustedTypes && trustedTypes.createPolicy) { }); } +/** + * + * @param {MouseEvent} ev + */ function openSiblingDialog(ev) { const dialog = ev.target.nextElementSibling; dialog.showModal(); @@ -36,6 +40,10 @@ function openSiblingDialog(ev) { }); } +/** + * + * @param {HTMLElement} results + */ function addOpenDialogListeners(results) { results.querySelectorAll("a.open-dialog").forEach(function (element) { element.addEventListener("click", handleDialogOpen); @@ -45,12 +53,20 @@ function addOpenDialogListeners(results) { }); } +/** + * + * @param {MouseEvent} ev + */ function paginationLinkClicked(ev) { const url = new URL(ev.target.href); getResults(url); ev.preventDefault(); } +/** + * + * @param {HTMLElement} pagination + */ function addPaginationEventListeners(pagination) { Array.from(pagination.children).forEach((child) => child.addEventListener("click", paginationLinkClicked), @@ -70,6 +86,10 @@ function renderResults(html) { } } +/** + * + * @param {URL} url + */ async function getResults(url) { try { state.url = url.toJSON(); @@ -141,6 +161,10 @@ document.querySelector("a.current").addEventListener("click", function (ev) { queryInput.value = ""; }); +/** + * + * @param {string} html + */ function renderDetails(html) { const fragment = detailsRange.createContextualFragment( escapePolicy !== null ? escapePolicy.createHTML(html) : html, @@ -157,6 +181,10 @@ dialog.querySelector("button").addEventListener("click", function () { dialog.close(); }); +/** + * + * @param {URL} url + */ async function getDetail(url) { try { state.url = url.toJSON(); @@ -178,6 +206,9 @@ async function getDetail(url) { } } +/** + * @param {MouseEvent} ev + */ function handleDialogOpen(ev) { getDetail(new URL(ev.target.href)); ev.preventDefault(); |