Skip to content

Commit

Permalink
Fix expanded pagination to support AI categories
Browse files Browse the repository at this point in the history
  • Loading branch information
FMaz008 committed May 24, 2024
1 parent eb4d292 commit 0c4a725
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scripts/bootloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ function initInsertTopPagination() {
);
const ITEM_PER_PAGE = 36;
const CURRENT_PAGE = parseInt(currentPageDOM.innerText.replace(/,/g, ""));
const URL = "/vine/vine-items?queue=encore&pn=&cn=&page=1"; //Sample URL to be modified

const URL = window.location.pathname + window.location.search; //Sample URL to be modified
let pagination = generatePagination(URL, TOTAL_ITEMS, ITEM_PER_PAGE, CURRENT_PAGE);

document.querySelector("#vvp-items-grid-container p").appendChild(pagination);
Expand Down
11 changes: 8 additions & 3 deletions scripts/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ function generatePagination(url, totalItems, itemsPerPage, currentPage) {
}

function generatePageLink(url, pageNo) {
const regex = /^(.+)(&page=[0-9]+)(.*?)$/gm;
const result = url.replace(regex, "$1&page=" + pageNo + "$3");
return result;
if (url.includes("&page=")) {
const regex = /^(.+)(&page=[0-9]+)(.*?)$/gm;
const result = url.replace(regex, "$1&page=" + pageNo + "$3");
return result;
} else {
//No replacement took place because &page was not part of the url
return url + "&page=" + pageNo;
}
}

function generatePageItem(url, pageNo, currentPage) {
Expand Down

0 comments on commit 0c4a725

Please sign in to comment.