all repos — searchix @ 4554d524916e48b18b4c669fe64bc8d54a148c59

Search engine for NixOS, nix-darwin, home-manager and NUR users

docs: add JSDoc comments to javascript functions
Alan Pearce alan@alanpearce.eu
Sat, 22 Mar 2025 18:04:43 +0100
commit

4554d524916e48b18b4c669fe64bc8d54a148c59

parent

6f21abc4c10f69d351573599e033394db9b279b0

1 files changed, 31 insertions(+), 0 deletions(-)

jump to
M frontend/static/search.jsfrontend/static/search.js
@@ -28,6 +28,10 @@ createHTML: (string) => string,   });
 }
 
+/**
+ *
+ * @param {MouseEvent} ev
+ */
 function openSiblingDialog(ev) {
   const dialog = ev.target.nextElementSibling;
   dialog.showModal();
@@ -36,6 +40,10 @@ dialog.close();   });
 }
 
+/**
+ *
+ * @param {HTMLElement} results
+ */
 function addOpenDialogListeners(results) {
   results.querySelectorAll("a.open-dialog").forEach(function (element) {
     element.addEventListener("click", handleDialogOpen);
@@ -45,12 +53,20 @@ element.addEventListener("click", openSiblingDialog);   });
 }
 
+/**
+ *
+ * @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 @@ addPaginationEventListeners(pagination);   }
 }
 
+/**
+ *
+ * @param {URL} url
+ */
 async function getResults(url) {
   try {
     state.url = url.toJSON();
@@ -141,6 +161,10 @@ });   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 @@ renderDetails(new Text(error.message));   }
 }
 
+/**
+ * @param {MouseEvent} ev
+ */
 function handleDialogOpen(ev) {
   getDetail(new URL(ev.target.href));
   ev.preventDefault();