//#region js/pagination.js function getCurrentPage() { const activePage = Number($("[data-pagination] .d-pagination__page.is-active").attr("data-page") || 1); return Number.isFinite(activePage) && activePage > 0 ? activePage : 1; } function goToPage(page) { const nextPage = Number(page); if (!Number.isFinite(nextPage) || nextPage < 1) return; const url = new URL(window.location.href); if (nextPage <= 1) url.searchParams.delete("page"); else url.searchParams.set("page", String(nextPage)); const query = url.searchParams.toString(); window.location.href = query ? `${url.pathname}?${query}` : url.pathname; } $(function() { $(document).on("click", "[data-pagination] .d-pagination__page[data-page]", function() { if ($(this).hasClass("is-active") || $(this).prop("disabled")) return; goToPage($(this).attr("data-page")); }); $(document).on("click", "[data-pagination] [data-page-prev]", function() { if ($(this).prop("disabled")) return; goToPage(getCurrentPage() - 1); }); $(document).on("click", "[data-pagination] [data-page-next]", function() { if ($(this).prop("disabled")) return; goToPage(getCurrentPage() + 1); }); }); //#endregion