Files
spend-sparrow/static/js/transaction.js
Tim Wundenberg 2ac14c84cc
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 2m2s
fix: browser console error
2026-01-01 16:06:25 +01:00

50 lines
1.2 KiB
JavaScript

document.addEventListener("DOMContentLoaded", () => {
if (typeof page === "undefined" ||
typeof page1 === "undefined" ||
typeof pagePrev1 === "undefined" ||
typeof pageNext1 === "undefined" ||
typeof page2 === "undefined" ||
typeof pagePrev2 === "undefined" ||
typeof pageNext2 === "undefined" ||
typeof transactionFilterForm === "undefined") {
return;
}
const scrollToTop = function() {
window.scrollTo(0, 0);
};
const incPage = function() {
const currPage = Number(page.value);
var nextPage = currPage
if (currPage > 1) {
nextPage -= 1;
page.value = nextPage;
transactionFilterForm.dispatchEvent(new Event('change'));
}
page1.textContent = nextPage;
page2.textContent = nextPage;
scrollToTop();
};
const decPage = function() {
const currPage = Number(page.value);
var nextPage = currPage + 1;
page.value = nextPage;
transactionFilterForm.dispatchEvent(new Event('change'));
page1.textContent = nextPage;
page2.textContent = nextPage;
scrollToTop();
};
pagePrev1.addEventListener("click", incPage);
pagePrev2.addEventListener("click", incPage);
pageNext1.addEventListener("click", decPage);
pageNext2.addEventListener("click", decPage);
console.log("initialized pagination");
})