Merge pull request #365 from Jaxx7594/line

fix: House/year box hard failing when house_colour does not exist
This commit is contained in:
Seth Burkart
2026-01-21 21:52:43 +11:00
committed by GitHub
+22 -15
View File
@@ -173,28 +173,35 @@ async function updateStudentInfo(students: any) {
); );
}); });
let houseelement1 = document.getElementsByClassName("userInfohouse")[0]; const houseelement = document.getElementsByClassName("userInfohouse")[0] as HTMLElement;
const houseelement = houseelement1 as HTMLElement;
// Fallback to N/A
let text = 'N/A';
const student = students[index] ?? {};
// If student has a house, prefer to show year + house. If no year, only show house.
if (student.house) {
text = `${student.year ?? ""}${student.house}`;
// If house_colour exists, compute colour
if (student.house_colour) {
houseelement.style.background = student.house_colour;
if (students[index]?.house) {
if (students[index]?.house_colour) {
houseelement.style.background = students[index].house_colour;
try { try {
let colorresult = GetThresholdOfColor(students[index]?.house_colour); const colorresult = GetThresholdOfColor(student.house_colour);
houseelement.style.color = houseelement.style.color =
colorresult && colorresult > 300 ? "black" : "white"; colorresult && colorresult > 300 ? "black" : "white";
houseelement.innerText = students[index].year + students[index].house;
} catch (error) { } catch (err) {
houseelement.innerText = students[index].house; // Colour calculation failed, no text colour set
} }
} }
} else { } else if (student.year) {
try { // No house, only year will be shown
houseelement.innerText = students[index].year; text = student.year;
} catch (err) {
houseelement.innerText = "N/A";
}
} }
houseelement.innerText = text;
} }
function createNewsButton(fragment: DocumentFragment, menu: HTMLElement) { function createNewsButton(fragment: DocumentFragment, menu: HTMLElement) {