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