Update Compass QoL Enhancer to 1.7.0
- Link to Action Centre events on calendars - Show the end/finish time for all applicable calendar events - Fix support for the mini-details view (visible on the month calendar view with more than five events visible)
This commit is contained in:
parent
c5bcef022a
commit
e2632b4722
|
@ -2,7 +2,7 @@
|
|||
// @name Compass QoL Enhancer
|
||||
// @namespace blankie-scripts
|
||||
// @match http*://*.compass.education/*
|
||||
// @version 1.6.0
|
||||
// @version 1.7.0
|
||||
// @author blankie
|
||||
// @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background
|
||||
// @inject-into page
|
||||
|
@ -60,16 +60,22 @@ function handleNewCalendarEvent(element) {
|
|||
a.replaceChildren(...element.childNodes);
|
||||
let preventCompassHandler = false;
|
||||
|
||||
let calendarElement = element.closest(".x-component.ext-cal-ct, .x-component.ext-cal-body-ct");
|
||||
let calendar = unsafeWindow.Ext.getCmp(calendarElement.id);
|
||||
let calendar = unsafeWindow.Ext.getCmp(element.closest(".x-component").id);
|
||||
if (calendar.view) {
|
||||
calendar = calendar.view;
|
||||
}
|
||||
let calendarData = calendar.getEventRecordFromEl(element).data;
|
||||
|
||||
if (a.classList.contains("activity-type-1")) {
|
||||
// Add a link and show the finish time for activities/"standard classes"
|
||||
let data = calendar.getEventRecordFromEl(element).data;
|
||||
let startString = unsafeWindow.Ext.util.Format.date(data.start, unsafeWindow.Compass.TIME_NO_PERIOD_FORMAT);
|
||||
let finishString = unsafeWindow.Ext.util.Format.date(data.finish, unsafeWindow.Compass.TIME_NO_PERIOD_FORMAT);
|
||||
a.href = `/Organise/Activities/Activity.aspx?targetUserId=${data.targetStudentId}#session/${data.instanceId}`;
|
||||
// yes, innerHTML. longTitleWithoutTime can apparently contain HTML. lets hope that startString and finishString don't
|
||||
a.querySelector("span").innerHTML = `${startString} - ${finishString}: ${data.longTitleWithoutTime}`;
|
||||
// Add a link for activities/"standard classes"
|
||||
a.href = `/Organise/Activities/Activity.aspx?targetUserId=${calendarData.targetStudentId}#session/${calendarData.instanceId}`;
|
||||
preventCompassHandler = true;
|
||||
} else if (a.classList.contains("activity-type-2")) {
|
||||
// Add a link for action centre events
|
||||
a.href = `/Organise/Activities/Events/Event.aspx?eventId=${calendarData.activityId}`;
|
||||
if (calendarData.targetStudentId) {
|
||||
a.href += `&userId=${calendarData.targetStudentId}`;
|
||||
}
|
||||
preventCompassHandler = true;
|
||||
} else if (a.classList.contains("activity-type-10")) {
|
||||
// Add a link for learning tasks
|
||||
|
@ -78,6 +84,15 @@ function handleNewCalendarEvent(element) {
|
|||
preventCompassHandler = true;
|
||||
}
|
||||
|
||||
// Show the finish time for applicable calendar events
|
||||
let startString = unsafeWindow.Ext.util.Format.date(calendarData.start, unsafeWindow.Compass.TIME_NO_PERIOD_FORMAT);
|
||||
let finishString = unsafeWindow.Ext.util.Format.date(calendarData.finish, unsafeWindow.Compass.TIME_NO_PERIOD_FORMAT);
|
||||
let textElement = a.querySelector("span") || a;
|
||||
// yes, innerHTML. longTitleWithoutTime can apparently contain HTML. lets hope that startString and finishString don't
|
||||
if (textElement.innerHTML === `${startString}: ${calendarData.longTitleWithoutTime}`) {
|
||||
textElement.innerHTML = `${startString} - ${finishString}: ${calendarData.longTitleWithoutTime}`;
|
||||
}
|
||||
|
||||
// prevent ctrl-clicking from changing the current tab
|
||||
// it seems like the link thing actually effectively killed the default handler anyway
|
||||
if (preventCompassHandler) {
|
||||
|
@ -160,7 +175,7 @@ function handleNewNode(node, observer) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (node.parentElement && (node.classList.contains("ext-cal-hd-ct") || node.classList.contains("ext-cal-bg-tbl") || node.classList.contains("ext-cal-inner-ct"))) {
|
||||
if (node.parentElement && (node.classList.contains("ext-cal-hd-ct") || node.classList.contains("ext-cal-bg-tbl") || node.classList.contains("ext-cal-inner-ct") || node.classList.contains("ext-cal-mdv"))) {
|
||||
for (let element of node.querySelectorAll("div.ext-cal-evt")) {
|
||||
handleNewCalendarEvent(element);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ Hacky script to disable the client-side file limit per tab
|
|||
|
||||
A userscript that adds small but useful features for Compass. Features include:
|
||||
- The ability to close windows by clicking on the background
|
||||
- Calendar events are now links (they work with [Link Hints] now! you can also
|
||||
ctrl+click on "standard classes" and learning tasks)
|
||||
- Calendar events now being links (they work with [Link Hints] now! you can
|
||||
also ctrl+click on "standard classes", events, and learning tasks)
|
||||
- Calendar events now show their end time without having to being hovered
|
||||
- Tabs are now links (you can refresh pages and the tab will automatically
|
||||
open. you can also ctrl+click on them)
|
||||
|
|
Loading…
Reference in New Issue