From 9e38502edec81c47a54641186d888f191ed999f0 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Mon, 26 Feb 2024 15:40:55 -0600 Subject: Add pagination handling --- static/js/paginator.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 static/js/paginator.js (limited to 'static/js/paginator.js') diff --git a/static/js/paginator.js b/static/js/paginator.js new file mode 100644 index 0000000..9a7ed65 --- /dev/null +++ b/static/js/paginator.js @@ -0,0 +1,15 @@ +export class Paginator { + constructor(host, context, path) { + this.endpoint = `${host}${context}?path=${path}`; + } + + populatePageAnchors() { + const pagination_widget = document.querySelector(".pagination"); + var anchors = pagination_widget.querySelectorAll('a'); + + for(let anchor of anchors) { + var page = /\d/.exec(anchor.id)[0]; + anchor.setAttribute("href", `${this.endpoint}&page=${page}`); + } + } +} \ No newline at end of file -- cgit v1.2.3