Skip to content

Commit

Permalink
webui: pass ?pattern to pagination links
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Dec 16, 2024
1 parent f66e101 commit c43ae6f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions webui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
});
}
}

0 comments on commit c43ae6f

Please sign in to comment.