Skip to content

Commit

Permalink
fix modified column colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mart2070 committed May 13, 2024
1 parent 5bf6741 commit 7ff7075
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 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-13-02
// @version 2024-05-13-03
// @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 @@ -333,19 +333,22 @@
}

//highlight modified/age red
if ('LastModifiedDate' in item) {
let modDate = item.LastModifiedDate
const ageThreshold = 336
let modifiedDates = ['LastModifiedDate','ModifiedDate']
for (const dType of modifiedDates) {
if (dType in item) {
let modDate = item[dType]
const ageThreshold = 336

let date = moment(modDate.txt)
let duration = moment.duration(moment().diff(date))
let hours = duration.asHours()
let date = moment(modDate.txt)
let duration = moment.duration(moment().diff(date))
let hours = duration.asHours()

let alpha = hours / ageThreshold
let alpha = hours / ageThreshold

let cell = modDate.cell
cell.style.background = `rgba(255,0,0,${alpha}`
cell.classList.add(alpha > 0.5 ? "light" : "dark")
let cell = modDate.cell
cell.style.background = `rgba(255,0,0,${alpha}`
cell.classList.add(alpha > 0.5 ? "light" : "dark")
}
}

//find user replies & last modified by internal
Expand Down Expand Up @@ -748,7 +751,7 @@
}
.light {
color: var(--txt-1) !important;
color: #fff;
}
.dark {
Expand Down

0 comments on commit 7ff7075

Please sign in to comment.