From bc3009c95dd01c8684c5fc2758ac756ad3ff5003 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 9 May 2024 10:57:19 -0400 Subject: [PATCH] show pagination count in headers --- tdx-enhanced.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tdx-enhanced.js b/tdx-enhanced.js index 19a492a..d632cbd 100644 --- a/tdx-enhanced.js +++ b/tdx-enhanced.js @@ -1,7 +1,7 @@ // ==UserScript== // @name tdx-enhanced // @namespace ecn -// @version 2024-05-08-01 +// @version 2024-05-09-01 // @description enhanced tdx coloring & formatting. follows system color scheme. // @author Purdue STEM IT - it@purdue.edu // @match https://service.purdue.edu/TDNext/* @@ -73,7 +73,7 @@ /* BEGIN FUNCTIONS */ - function updateHeading(mutation,numItems) { + function updateHeading(mutation,numItems,totalItems) { let headings = mutation.querySelectorAll(".panel-title") for (const heading of headings) { @@ -113,7 +113,15 @@ heading.appendChild(countSpan) } - countSpan.innerText = `${numItems} ${numItems == 1 ? 'item' : 'items'}` + var countTxt + + if (totalItems) { + countTxt = `${numItems} of ${totalItems} ${totalItems == 1 ? 'item' : 'items'}` + } else { + countTxt = `${numItems} ${numItems == 1 ? 'item' : 'items'}` + } + + countSpan.innerText = countTxt } } @@ -195,7 +203,17 @@ }) //update panel heading above table - updateHeading(t.parentElement,items.length) + var numItems = items.length + var totalItems = null + + let pagination = t.querySelector(".pull-right .bootstrap-pagination-label") + if (pagination) { + let pTxt = pagination.innerText + pTxt = pTxt.split(" ")[0] + totalItems = pTxt + } + + updateHeading(t.parentElement,numItems,totalItems) console.log("Items:",items) }