Skip to content

Commit

Permalink
Added student features
Browse files Browse the repository at this point in the history
  • Loading branch information
ejunga committed Sep 19, 2024
1 parent 6a08f78 commit 0760f9f
Showing 1 changed file with 94 additions and 9 deletions.
103 changes: 94 additions & 9 deletions tdx-enhanced.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ==UserScript==
// @name tdx-enhanced
// @name tdx-enhanced-student
// @namespace ecn
// @version 2024-09-03-01
// @description enhanced tdx coloring & formatting. follows system color scheme.
Expand All @@ -19,7 +19,7 @@
/* QUEUE COLORS */

//from main webqueue script
var colorsByQueue = {
const colorsByQueue = {
'aae': {'bg' : '#7030A0', 'txt' : 'white' },
'abe' : {'bg' : '#256f78', 'txt' : 'white'},
'bidc' : {'bg' : '#C5FFC5', 'txt' : 'black'},
Expand Down Expand Up @@ -68,12 +68,69 @@
};

//regex for matching inline highlights
var colorsByStatus = {
const colorsByStatus = {
'!!': {style: {background: 'var(--col-highlight-1)'}, type: 'highlight', re: new RegExp("\!! (.*) \!!","g")},
'~~': {style: {background: 'var(--col-highlight-2)'}, type: 'highlight', re: new RegExp("\~~ (.*) \~~","g")},
}

var colorScheme
const colorsByReport = {
'Unassigned' : {'bg': '#117c1f', 'txt': 'white'},
'Assigned' : {'bg': '#1f117c', 'txt': 'white'},
'Open' : {'bg': '#86297b', 'txt': 'white'},
'open' : {'bg': '#86297b', 'txt': 'white'},
'Completed' : {'bg': '#86297b', 'txt': 'white'},
'': {'bg': '#117e7e', 'txt': 'white'}
};

const colorsByStudent = {
'Kaitlyn Harley' : {'bg' : '#35dd66', 'fg': "black"},
'Ethan Mesecar' : {'bg' : '#412264', 'fg': "white"},
'Justice Johnson': {'bg' : '#285c65', 'fg': "white"},
'Elijah Junga' : {'bg': '#27f9bb', 'fg': "black"},
'Deon Murray' : {'bg' : '#e63ab4', 'fg': "black"},
'Ethan Hammond' : {'bg' : '#fa990b', 'fg': "black"},
'Andrea Gajic' : {'bg' : '#b886d2', 'fg': "black"},
'Omar Mostafa' : {'bg' : '#a759f9', 'fg': "black"},
'Alexander Martin': {'bg': '#5c7dc0', 'fg': "white"},
'Thomas Franks': {'bg': '#4abef2', 'fg': "white"},
'Trae Richardson': {'bg': '#e0c200', 'fg': "black"},
};

function highlightReportHeadings() {
let headings = document.querySelectorAll(".panel-title");
let reportKeys = Object.keys(colorsByReport);

for (const heading of headings) {
for (const reportKey of reportKeys) {
let headingTxt = heading.innerText;
if (headingTxt.includes(reportKey)) {
let reportColors = colorsByReport[reportKey];
heading.style.color = reportColors.txt;
heading.parentElement.style.backgroundColor = reportColors.bg;
break;
}
}
}
}

function left_append_ticket_number() {
try {
let form1 = document.querySelector("#Form1");
let ticketID = form1.attributes["action"].value.slice(-6);
let title = document.querySelector("title");
title.innerText = ticketID + ' ' + title.innerText;
} catch (error) {
console.warn(error);
console.warn("Was unable to append the ticketID for this page to the title\nThis page may not point to a ticket, or the Form1 element may be missing");
}
}

function applyStudentFormatting() {
highlightReportHeadings();
left_append_ticket_number();
}

let colorScheme

/* BEGIN FUNCTIONS */

Expand Down Expand Up @@ -412,11 +469,13 @@
item.row.style.backgroundColor = "var(--col-reply)";
}

/*
//modified by internal
if (lastModified.txt != fromUser.txt && lastModified.txt != assignedTo.txt) {
let cell = item.LastModifiedByFullName.cell
cell.style.backgroundColor = "var(--col-modified)"
}
*/
}

//find inline highlights for tasks
Expand All @@ -425,12 +484,12 @@
for (const [key,color] of Object.entries(colorsByStatus)) {
let re = color.re.exec(title.txt)
if (re) {
let newTitle = re[1]
//let newTitle = re[1]

let link = title.cell.querySelector("a")
if (link) {
title.cell.style.backgroundColor = color.style.background
link.innerText = newTitle
link.style.backgroundColor = color.style.background
//link.innerText = newTitle
}

//reset regex
Expand All @@ -451,6 +510,31 @@
}
}
}

//Highlight Student team names <-- Added for student desktop
let nameTypes = ['CustomerName', 'ResponsibleFullName', 'ModifiedByFullName', 'Responsibility'];
for (const nameType of nameTypes) {
if (nameType in item) {
let e = item[nameType].cell;
for (const studentName of Object.keys(colorsByStudent)) {
if (item[nameType].cell.innerText == studentName) {
let colors = colorsByStudent[studentName];
let nameBox = document.createElement("div");
nameBox.style.color = colors.fg;
nameBox.style.backgroundColor = colors.bg;
nameBox.style.borderRadius = '8%';
nameBox.style.padding = '3px';
nameBox.style.width = 'fit-content';
let link = e.firstElementChild;
if (link) { // if the cell contains a link, we need to do this to change the text color
link.style.color = colors.fg;
}
nameBox.appendChild(e.firstChild);
e.appendChild(nameBox);
}
}
}
}
}

function handleLink(source,link) {
Expand Down Expand Up @@ -983,6 +1067,7 @@
settings("apply")
parseTicket()
checkPath()
applyStudentFormatting()

addEventListener("storage", (event) => {
//console.log("Storage event:",event)
Expand Down Expand Up @@ -1036,8 +1121,8 @@
--dark-txt-5: var(--light-txt-1);
--dark-border-0: color-mix(in srgb,var(--dark-bg-primary),#fff 18%);
--dark-col-reply: #1e3438;
--dark-col-highlight-1: #625714;
--dark-col-highlight-2: #311462;
--dark-col-highlight-1: #6F6200;
--dark-col-highlight-2: #581F53;
--dark-col-currentuser: #09482f;
--dark-col-modified: #30241c;
--dark-txt-invert: 1;
Expand Down

0 comments on commit 0760f9f

Please sign in to comment.