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; + }); + } +}