From c43ae6fdf83aef709cb6f3fc2f630d6d4d05c077 Mon Sep 17 00:00:00 2001 From: Adam Shannon Date: Mon, 16 Dec 2024 13:20:55 -0600 Subject: [PATCH] webui: pass ?pattern to pagination links --- webui/index.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/webui/index.js b/webui/index.js index 2ace5a5a..f289ca67 100644 --- a/webui/index.js +++ b/webui/index.js @@ -12,6 +12,9 @@ window.onload = function() { // Populate the filter with any current pattern from the URL populateCurrentPatternForm(); + + // Update pagination links with the pattern + updatePaginationLinks(); }; function filterFileListing(pattern) { @@ -21,12 +24,26 @@ function filterFileListing(pattern) { window.location.href = url.toString(); // redirect } -function populateCurrentPatternForm() { +function getCurrentPattern() { const url = new URL(window.location.href); - const currentPattern = url.searchParams.get("pattern"); + return url.searchParams.get("pattern"); +} + +function populateCurrentPatternForm() { + const currentPattern = getCurrentPattern(); if (currentPattern) { var filenameElm = document.querySelector("#filename"); filenameElm.value = currentPattern; } } + +function updatePaginationLinks() { + const currentPattern = getCurrentPattern(); + if (currentPattern) { + var links = document.querySelectorAll("nav.pagination a"); + links.forEach(link => { + link.href += "&pattern=" + currentPattern; + }); + } +}