Skip to content

Commit

Permalink
show pagination count in headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mart2070 committed May 9, 2024
1 parent 379da7d commit bc3009c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tdx-enhanced.js
Original file line number Diff line number Diff line change
@@ -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/*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit bc3009c

Please sign in to comment.