diff options
Diffstat (limited to 'frontend/static/search.js')
-rw-r--r-- | frontend/static/search.js | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/frontend/static/search.js b/frontend/static/search.js index e16c83c..0bf4a5e 100644 --- a/frontend/static/search.js +++ b/frontend/static/search.js @@ -28,14 +28,24 @@ if (window.trustedTypes && trustedTypes.createPolicy) { }); } +/** + * + * @param {MouseEvent} ev + */ function openSiblingDialog(ev) { - const dialog = ev.target.nextElementSibling; - dialog.showModal(); - dialog.querySelector("button").addEventListener("click", function () { - dialog.close(); - }); + if (!(ev.shiftKey || ev.altKey || ev.ctrlKey || ev.metaKey)) { + const dialog = ev.target.nextElementSibling; + dialog.showModal(); + dialog.querySelector("button").addEventListener("click", function () { + dialog.close(); + }); + } } +/** + * + * @param {HTMLElement} results + */ function addOpenDialogListeners(results) { results.querySelectorAll("a.open-dialog").forEach(function (element) { element.addEventListener("click", handleDialogOpen); @@ -45,12 +55,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 +88,10 @@ function renderResults(html) { } } +/** + * + * @param {URL} url + */ async function getResults(url) { try { state.url = url.toJSON(); @@ -141,6 +163,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 +183,10 @@ dialog.querySelector("button").addEventListener("click", function () { dialog.close(); }); +/** + * + * @param {URL} url + */ async function getDetail(url) { try { state.url = url.toJSON(); @@ -178,9 +208,14 @@ async function getDetail(url) { } } +/** + * @param {MouseEvent} ev + */ function handleDialogOpen(ev) { - getDetail(new URL(ev.target.href)); - ev.preventDefault(); + if (!(ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey)) { + getDetail(new URL(ev.target.href)); + ev.preventDefault(); + } } if (state.opened.length > 0) { |