fix: fix adaptive themeing to support current year subjects

This commit is contained in:
2026-04-03 10:47:56 +10:30
parent 834d585ac7
commit 04843a90fe
+8 -3
View File
@@ -2,12 +2,17 @@ import { getUserInfo } from "@/seqta/ui/AddBetterSEQTAElements";
/**
* Parses the current page from window.location.hash.
* Returns { programme, metaclass } for /courses/SEMESTER/X:Y or /assessments/SEMESTER/X:Y, or null.
* e.g. #?page=/courses/2023S/4804:11066 or #?page=/assessments/2023S/4621:10772
* Supports both old and current URL formats, e.g.
* /courses/SEMESTER/X:Y and /courses/X:Y
* /assessments/SEMESTER/X:Y and /assessments/X:Y
* e.g. #?page=/courses/2023S/4804:11066,
* #?page=/courses/4804:11066,
* #?page=/assessments/2023S/4621:10772,
* #?page=/assessments/4621:10772
*/
function parsePageContext(): { programme: number; metaclass: number } | null {
const hash = window.location.hash || "";
const match = hash.match(/[?&]page=\/(courses|assessments)\/[^/]+\/(\d+):(\d+)/);
const match = hash.match(/[?&]page=\/(courses|assessments)\/(?:[^/]+\/)?(\d+):(\d+)/);
if (!match) return null;
const programme = parseInt(match[2], 10);
const metaclass = parseInt(match[3], 10);