Skip to content

Commit

Permalink
show IT status icon correctly, better msg extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
mart2070 committed Aug 1, 2024
1 parent 12a0ce7 commit c2d84a2
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 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-07-27-01
// @version 2024-08-01-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 @@ -773,18 +773,18 @@
parent.prepend(statusLink)
let statusData = await getITStatus()
let statusIcon = statusLink.querySelector("#statusIcon")
if (statusData.length>0) {
statusIcon.classList = ("fa-solid fa-triangle-exclamation")
let statusTime = statusLink.querySelector("#statusTime")
let statusText = statusLink.querySelector("#statusText")

let statusTimeParsed = moment(statusData[0].time)
let statusTime = statusLink.querySelector("#statusTime")
let statusText = statusLink.querySelector("#statusText")

statusTime.innerText = statusTimeParsed.fromNow()
statusText.innerText = statusData[0].msg //First msg for now, will there be more than one?
if (statusData && statusData.msg != "All Systems Operational") {
statusIcon.classList = ("fa-solid fa-triangle-exclamation")
} else {
statusIcon.classList = ("fa-solid fa-check")
}

let statusTimeParsed = moment(statusData.time)
statusTime.innerText = statusTimeParsed.fromNow()
statusText.innerText = statusData.msg
}
}

Expand All @@ -793,22 +793,20 @@
let res = await fetch(url)
let data = await res.json()

let messages = []
let msg = {}

let msgs = data.Results
if (msgs.length>0) {
let numMsgs = msgs.length/2
for (let i = 0; i<numMsgs; i++) {
let msg = {
time: msgs[i],
msg: msgs[i+1]
}
messages.push(msg)
msg = {
time: msgs[0],
msg: msgs[1]
}
console.warn("IT Messages:",messages)
console.warn("IT Message:",msg)
} else {
msg = null
}

return messages
return msg
}

/* SETTINGS */
Expand Down

0 comments on commit c2d84a2

Please sign in to comment.