From e59b1669d8606789358f69e7f1ea14ecb0b7a9c5 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 1 May 2024 17:24:05 -0400 Subject: [PATCH] add item counts to reports --- tdx-enhanced.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/tdx-enhanced.js b/tdx-enhanced.js index 5eaea14..05d4aaf 100644 --- a/tdx-enhanced.js +++ b/tdx-enhanced.js @@ -65,10 +65,11 @@ /* BEGIN FUNCTIONS */ - function getHeadings() { - let headings = document.querySelectorAll(".panel-title") + function updateHeading(mutation,numItems) { + let headings = mutation.querySelectorAll(".panel-title") for (const heading of headings) { + //color the header if queue name is found let headingTxt = heading.innerText let headingFirst = headingTxt.split(" ")[0] headingFirst = headingFirst.toLowerCase() @@ -86,6 +87,25 @@ } } + + //append number of items to title + //let parentDiv = document.createElement("div") + + //let header = document.createElement("h4") + //header.innerText = headingTxt + + var countSpan = heading.querySelector(".subtitle") + + if (!countSpan) { + countSpan = document.createElement("span") + //countSpan.innerText = `${numItems} items` + countSpan.classList.add("subtitle") + + heading.innerText = headingTxt + heading.appendChild(countSpan) + } + + countSpan.innerText = `${numItems} ${numItems == 1 ? 'item' : 'items'}` } } @@ -159,11 +179,15 @@ }) item.row = row + items.push(item) console.log("ITEM:",item) //being coloring parseItem(item) }) + + //update panel heading above table + updateHeading(t.parentElement,items.length) } } @@ -305,7 +329,6 @@ } } - getHeadings() parseTicket() changeTitle() @@ -315,6 +338,7 @@ :root { --light-txt-1: #000; + --light-txt-4: #0000008c; --light-col-1: #897043; --light-col-2: #635130; --light-bg-2: #ddd; @@ -331,6 +355,7 @@ --dark-txt-1: #fff; --dark-txt-2: #ececec; --dark-txt-3: #929292; + --dark-txt-4: #ffffff8c; --dark-border-0: #2b2b2b; } @@ -353,6 +378,17 @@ box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px var(--dark-col-1); } + .panel-title { + display: flex; + align-items: baseline; + gap: 4px; + } + + .subtitle { + font-size: 14px; + cursor: unset !important; + } + @media (prefers-color-scheme: light) { :root { @@ -367,6 +403,10 @@ color: var(--dark-txt-1) !important; } + .subtitle { + color: var(--light-txt-4) !important; + } + /* Colors */ a, a.noHover, .blue { color: var(--light-col-1) !important; @@ -428,6 +468,10 @@ color: var(--dark-txt-1) !important; } + .subtitle { + color: var(--dark-txt-4) !important; + } + /* Body */ html, body { background-color: var(--dark-bg-0) !important;