2023-07-22 11:04:28 +00:00
|
|
|
// ==UserScript==
|
|
|
|
// @name Compass QoL Enhancer
|
|
|
|
// @namespace blankie-scripts
|
|
|
|
// @match http*://*.compass.education/*
|
2024-02-07 03:20:12 +00:00
|
|
|
// @version 1.26.0
|
2023-07-22 11:04:28 +00:00
|
|
|
// @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
|
|
|
|
// @run-at document-end
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2023-07-26 01:12:52 +00:00
|
|
|
let qolTabOpened = false;
|
2023-08-31 07:39:57 +00:00
|
|
|
let qolLearningTaskOpened = false;
|
2023-11-01 23:02:00 +00:00
|
|
|
let modifyUrlHash = true;
|
2023-10-23 02:44:34 +00:00
|
|
|
let shownWindows = 0;
|
2023-11-29 07:24:27 +00:00
|
|
|
// popups should bot be blocked by the prioritised nav bar
|
|
|
|
let productNavBar = window.location.pathname !== "/ActionCentre/" ? document.querySelector("#productNavBar") : null;
|
2023-08-03 11:25:19 +00:00
|
|
|
|
2023-07-26 01:12:52 +00:00
|
|
|
// needed because .toString() adds a trailing = for empty values
|
2023-08-31 07:39:57 +00:00
|
|
|
URLSearchParams.prototype.laxToString = function() {
|
2023-07-26 01:12:52 +00:00
|
|
|
let out = "";
|
2023-08-31 07:39:57 +00:00
|
|
|
for (let [key, value] of this) {
|
2023-07-26 01:12:52 +00:00
|
|
|
if (out) {
|
|
|
|
out += "&";
|
|
|
|
}
|
|
|
|
// required for session/... or activity/...
|
|
|
|
out += encodeURIComponent(key).replaceAll("%2F", "/");
|
|
|
|
if (value) {
|
|
|
|
out += `=${encodeURIComponent(value)}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
2023-08-31 07:39:57 +00:00
|
|
|
function getHashSearch() {
|
|
|
|
return new URLSearchParams(window.location.hash.substring(1));
|
|
|
|
}
|
|
|
|
function getExtClass(className) {
|
|
|
|
if (!unsafeWindow.Ext) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return unsafeWindow.Ext.ClassManager.get(className);
|
|
|
|
}
|
2023-07-26 01:12:52 +00:00
|
|
|
function getPanelItemHash(panelId, isDefault) {
|
|
|
|
if (window.location.pathname === "/Organise/Activities/Activity.aspx") {
|
2023-08-31 07:39:57 +00:00
|
|
|
let query = getHashSearch();
|
2023-07-26 01:12:52 +00:00
|
|
|
if (panelId === "learningtasks") {
|
|
|
|
query.delete("qol_open_tab");
|
|
|
|
query.set("openLearningTaskTab", "");
|
|
|
|
} else if (isDefault) {
|
|
|
|
query.delete("qol_open_tab");
|
|
|
|
query.delete("openLearningTaskTab");
|
|
|
|
} else {
|
|
|
|
query.set("qol_open_tab", panelId);
|
|
|
|
query.delete("openLearningTaskTab");
|
|
|
|
}
|
2023-08-31 07:39:57 +00:00
|
|
|
query.delete("qol_learning_task");
|
|
|
|
return `#${query.laxToString()}`;
|
2023-07-26 01:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return `#${encodeURIComponent(panelId)}`;
|
|
|
|
}
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
|
|
|
|
|
2023-11-04 03:42:10 +00:00
|
|
|
// Prevent scrolling if a window is open, and put the nav bar over or behind masks when necessary
|
2023-10-23 02:44:34 +00:00
|
|
|
function handleWindowShow() {
|
|
|
|
shownWindows++;
|
|
|
|
document.documentElement.style.overflow = "hidden";
|
2023-11-04 03:42:10 +00:00
|
|
|
productNavBar.style.zIndex = "";
|
2023-10-23 02:44:34 +00:00
|
|
|
}
|
|
|
|
function handleWindowClose() {
|
|
|
|
shownWindows--;
|
|
|
|
if (shownWindows <= 0) {
|
|
|
|
document.documentElement.style.overflow = "";
|
2023-11-04 03:42:10 +00:00
|
|
|
productNavBar.style.zIndex = 20000;
|
2023-10-23 02:44:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
let Window = getExtClass("Ext.window.Window");
|
|
|
|
if (Window) {
|
|
|
|
let original = Window.prototype.initComponent;
|
|
|
|
Window.prototype.initComponent = function() {
|
|
|
|
original.apply(this, arguments);
|
|
|
|
this.on("show", handleWindowShow);
|
|
|
|
this.on("close", handleWindowClose);
|
|
|
|
};
|
|
|
|
}
|
2023-11-07 11:16:17 +00:00
|
|
|
// example of message boxes: remove device on /Configure/LoginAndSecurity.aspx
|
|
|
|
// for some reason, listening on Ext.window.MessageBox does nothing
|
|
|
|
let Msg = unsafeWindow.Ext ? unsafeWindow.Ext.Msg : null;
|
|
|
|
if (Msg) {
|
|
|
|
let original = Msg.show;
|
|
|
|
Msg.show = function(options) {
|
|
|
|
let originalFn = options.fn;
|
|
|
|
|
|
|
|
options.fn = function() {
|
|
|
|
handleWindowClose();
|
|
|
|
if (originalFn) {
|
|
|
|
originalFn.apply(this, arguments);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
handleWindowShow();
|
|
|
|
original.apply(this, arguments);
|
|
|
|
};
|
|
|
|
}
|
2023-10-23 02:44:34 +00:00
|
|
|
|
2023-11-04 03:42:10 +00:00
|
|
|
if (productNavBar) {
|
|
|
|
productNavBar.style.zIndex = 20000;
|
|
|
|
}
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
let UserProfileNewWidget = getExtClass("Compass.widgets.UserProfileNewWidget");
|
|
|
|
if (UserProfileNewWidget) {
|
2023-12-04 04:39:48 +00:00
|
|
|
// Prevent the dashboard tab in the user page being "dsh"
|
2023-08-31 07:39:57 +00:00
|
|
|
let original = UserProfileNewWidget.prototype.createItems;
|
|
|
|
UserProfileNewWidget.prototype.createItems = function() {
|
|
|
|
let res = original.apply(this, arguments);
|
|
|
|
delete res[0].listeners;
|
|
|
|
return res;
|
|
|
|
};
|
2023-12-04 04:39:48 +00:00
|
|
|
|
|
|
|
// Prevent clicking on a learning task from changing back to the Dashboard tab
|
|
|
|
UserProfileNewWidget.prototype.processHashChange = function() {};
|
2023-08-31 07:39:57 +00:00
|
|
|
}
|
|
|
|
|
2023-10-10 23:40:13 +00:00
|
|
|
function handleNewsItemClick(event) {
|
2023-11-10 00:38:48 +00:00
|
|
|
if (!this.moreButton.hidden && !event.target.closest("a, .newsfeed-image")) {
|
2023-09-06 07:26:52 +00:00
|
|
|
Compass.saveScrollPosition();
|
|
|
|
this.expandTruncated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let NewsfeedItemWidget = getExtClass("Compass.widgets.NewsfeedItemWidget");
|
|
|
|
if (NewsfeedItemWidget) {
|
|
|
|
let original = NewsfeedItemWidget.prototype.renderLayout;
|
|
|
|
NewsfeedItemWidget.prototype.renderLayout = function() {
|
|
|
|
original.apply(this, arguments);
|
|
|
|
// prevent clicking on text from expanding the item since this disrupts selecting text, and we're gonna extend this to the entire item anyway
|
|
|
|
this.newsItemTextContainer.events.afterrender = true;
|
|
|
|
// Expand news feed items by clicking on them
|
|
|
|
this.on("afterrender", function() {
|
2023-10-10 23:40:13 +00:00
|
|
|
this.el.on("click", handleNewsItemClick.bind(this), this.el);
|
2023-09-06 07:26:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-09 03:28:23 +00:00
|
|
|
// Make links in Looking Ahead actual links
|
|
|
|
let NewsfeedAlertItemWidget = getExtClass("Compass.widgets.NewsfeedAlertItemWidget");
|
|
|
|
if (NewsfeedAlertItemWidget) {
|
|
|
|
let original = NewsfeedAlertItemWidget.prototype.initComponent;
|
|
|
|
NewsfeedAlertItemWidget.prototype.initComponent = function() {
|
|
|
|
this.alertItem.Content = this.alertItem.Content.replaceAll(
|
|
|
|
/<a onclick="Compass\.postForm\('\/ActionCentre\/', { eventId:(\d+), attendeeId:(\d+)}\)"/gi,
|
|
|
|
"<a href=\"/Organise/Activities/Events/Event.aspx?eventId=$1&userId=$2\"",
|
|
|
|
);
|
|
|
|
original.apply(this, arguments);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
let LearningTasksDetailsWidgetNew = getExtClass("Compass.widgets.LearningTasksDetailsWidgetNew");
|
|
|
|
if (LearningTasksDetailsWidgetNew) {
|
2024-02-05 12:25:36 +00:00
|
|
|
// Automatically open learning tasks specified in the URL
|
|
|
|
let originalFOLTOL = LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad;
|
2023-08-31 07:39:57 +00:00
|
|
|
LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad = function() {
|
|
|
|
// stole this from the function above
|
|
|
|
let toOpen = this.initialLoadComplete && !this.firstLoad;
|
|
|
|
let exit = !toOpen || this.openLearningTaskId || qolLearningTaskOpened;
|
2024-02-05 12:25:36 +00:00
|
|
|
originalFOLTOL.apply(this, arguments);
|
2023-08-31 07:39:57 +00:00
|
|
|
if (exit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-01 23:02:00 +00:00
|
|
|
this.openUrlLearningTask();
|
2023-08-31 07:39:57 +00:00
|
|
|
qolLearningTaskOpened = true;
|
2023-11-01 23:02:00 +00:00
|
|
|
};
|
|
|
|
LearningTasksDetailsWidgetNew.prototype.openUrlLearningTask = function() {
|
2023-08-31 07:39:57 +00:00
|
|
|
let learningTask = parseInt(getHashSearch().get("qol_learning_task"), 10);
|
|
|
|
if (isNaN(learningTask)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let learningTaskRecord = this.taskStore.findRecord("id", learningTask);
|
|
|
|
if (!learningTaskRecord) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.launchLearningTasksSubmissionWidget(learningTaskRecord.data.gridRecordId, false);
|
|
|
|
};
|
2024-02-05 12:25:36 +00:00
|
|
|
|
|
|
|
// Show "Grades" and "Task" visibility for learning tasks
|
|
|
|
let originalCreateBasicTaskGrid = LearningTasksDetailsWidgetNew.prototype.createBasicTaskGrid;
|
|
|
|
LearningTasksDetailsWidgetNew.prototype.createBasicTaskGrid = function() {
|
|
|
|
let widget = this;
|
|
|
|
let taskGrid = originalCreateBasicTaskGrid.apply(this, arguments);
|
|
|
|
|
|
|
|
let originalRenderer = taskGrid.columns[0].renderer;
|
|
|
|
taskGrid.columns[0].renderer = function() {
|
|
|
|
let isStudentView = widget.isStudentView;
|
|
|
|
let isStudentOrParent = widget.isStudentOrParent;
|
|
|
|
widget.isStudentView = widget.isStudentOrParent = false;
|
|
|
|
let ret = originalRenderer.apply(this, arguments);
|
|
|
|
widget.isStudentView = isStudentView;
|
|
|
|
widget.isStudentOrParent = isStudentOrParent;
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
return taskGrid;
|
|
|
|
}
|
2024-02-07 03:20:12 +00:00
|
|
|
|
|
|
|
// Add refresh button to learning tasks
|
|
|
|
let originalInitTBar = LearningTasksDetailsWidgetNew.prototype.initTBar;
|
|
|
|
LearningTasksDetailsWidgetNew.prototype.initTBar = function() {
|
|
|
|
originalInitTBar.apply(this, arguments);
|
|
|
|
let widget = this;
|
|
|
|
let refreshButton = {
|
|
|
|
itemId: "refreshButton",
|
|
|
|
text: "Refresh",
|
|
|
|
handler: function() {
|
|
|
|
widget.taskStore.load();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.tbar.splice(this.tbar.indexOf("->") + 1, 0, refreshButton);
|
|
|
|
};
|
2023-08-31 07:39:57 +00:00
|
|
|
}
|
|
|
|
|
2023-09-05 06:22:54 +00:00
|
|
|
// Automatically add (and remove) the currently open learning task to the URL
|
2023-09-06 07:26:52 +00:00
|
|
|
function handleLearningTaskShow() {
|
2023-11-01 23:02:00 +00:00
|
|
|
if (!modifyUrlHash) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-05 06:22:54 +00:00
|
|
|
let search = getHashSearch();
|
2023-09-06 07:26:52 +00:00
|
|
|
search.set("qol_learning_task", this.learningTask.data.id);
|
2023-11-29 07:24:27 +00:00
|
|
|
window.location.hash = `#${search.laxToString()}`;
|
2023-09-05 06:22:54 +00:00
|
|
|
}
|
|
|
|
function handleLearningTaskClose() {
|
2023-11-01 23:02:00 +00:00
|
|
|
if (!modifyUrlHash) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-05 06:22:54 +00:00
|
|
|
let search = getHashSearch();
|
|
|
|
search.delete("qol_learning_task");
|
2023-11-29 07:24:27 +00:00
|
|
|
window.location.hash = `#${search.laxToString()}`;
|
2023-09-05 06:22:54 +00:00
|
|
|
}
|
|
|
|
let LearningTasksSubmissionWidget = getExtClass("Compass.widgets.LearningTasksSubmissionWidget");
|
|
|
|
if (LearningTasksSubmissionWidget) {
|
|
|
|
let original = LearningTasksSubmissionWidget.prototype.initComponent;
|
|
|
|
LearningTasksSubmissionWidget.prototype.initComponent = function() {
|
|
|
|
original.apply(this, arguments);
|
2023-09-06 07:26:52 +00:00
|
|
|
this.on("show", handleLearningTaskShow.bind(this));
|
2023-09-05 06:22:54 +00:00
|
|
|
this.on("close", handleLearningTaskClose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-14 09:43:21 +00:00
|
|
|
function updateInstanceButton(instanceDetails, instanceButton, offset) {
|
|
|
|
// Make previous/next session buttons links
|
|
|
|
let index = instanceDetails.instanceStore.indexOfId(instanceDetails.m_instanceId);
|
|
|
|
index += offset;
|
|
|
|
if (index >= 0 && index < instanceDetails.instanceStore.count()) {
|
|
|
|
let url = `#session/${instanceDetails.instanceStore.getAt(index).internalId}`;
|
|
|
|
instanceButton.el.dom.href = url;
|
|
|
|
} else {
|
|
|
|
instanceButton.el.dom.removeAttribute("href");
|
|
|
|
}
|
|
|
|
}
|
2023-08-31 07:39:57 +00:00
|
|
|
let InstanceDetailsWidget = getExtClass("Compass.widgets.InstanceDetailsWidget");
|
|
|
|
if (InstanceDetailsWidget) {
|
2023-11-29 07:24:27 +00:00
|
|
|
// recreation of updateURLHash to fix qol_learning_task being stripped
|
|
|
|
// example: /Organise/Activities/Activity.aspx#activity/67672&openLearningTaskTab&qol_learning_task=77334
|
|
|
|
InstanceDetailsWidget.prototype.updateURLHash = function(useInstanceId) {
|
|
|
|
let match = window.location.hash.match(/^#.*?[?&](.+)$/);
|
|
|
|
let hash = useInstanceId ? `session/${this.m_instanceId}` : `activity/${this.m_activityId}`;
|
|
|
|
if (match) {
|
|
|
|
hash += `&${match[1]}`;
|
|
|
|
}
|
|
|
|
window.location.hash = `#${hash}`;
|
|
|
|
};
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
let originalUpdateInstanceHeader = InstanceDetailsWidget.prototype.updateInstanceHeader;
|
|
|
|
InstanceDetailsWidget.prototype.updateInstanceHeader = function() {
|
|
|
|
originalUpdateInstanceHeader.apply(this, arguments);
|
|
|
|
let toolbar = this.getInstanceNavigatorToolbar();
|
|
|
|
updateInstanceButton(this, toolbar.getComponent("previousInstanceButton"), -1);
|
|
|
|
updateInstanceButton(this, toolbar.getComponent("nextInstanceButton"), 1);
|
|
|
|
};
|
2023-08-14 09:43:21 +00:00
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
let originalGetInstanceNavigatorToolbar = InstanceDetailsWidget.prototype.getInstanceNavigatorToolbar;
|
|
|
|
InstanceDetailsWidget.prototype.getInstanceNavigatorToolbar = function() {
|
|
|
|
if (this.instanceNavigatorToolbar) {
|
|
|
|
return this.instanceNavigatorToolbar;
|
|
|
|
}
|
|
|
|
let toolbar = originalGetInstanceNavigatorToolbar.apply(this, arguments);
|
|
|
|
let previousButton = toolbar.getComponent("previousInstanceButton");
|
|
|
|
let nextButton = toolbar.getComponent("nextInstanceButton");
|
|
|
|
|
|
|
|
previousButton.preventDefault = false;
|
|
|
|
let originalPreviousButtonHandler = previousButton.handler;
|
|
|
|
previousButton.handler = function(_, event) {
|
|
|
|
if (!event.ctrlKey) {
|
|
|
|
event.preventDefault();
|
|
|
|
originalPreviousButtonHandler.apply(this, arguments);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
nextButton.preventDefault = false;
|
|
|
|
let originalNextButtonHandler = nextButton.handler;
|
|
|
|
nextButton.handler = function(_, event) {
|
|
|
|
if (!event.ctrlKey) {
|
|
|
|
event.preventDefault();
|
|
|
|
originalNextButtonHandler.apply(this, arguments);
|
|
|
|
}
|
|
|
|
};
|
2023-08-14 09:43:21 +00:00
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
return toolbar;
|
2023-08-14 09:43:21 +00:00
|
|
|
};
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
// not a typo :)
|
|
|
|
let originalGetCmbSelectIntance = InstanceDetailsWidget.prototype.getCmbSelectIntance;
|
|
|
|
InstanceDetailsWidget.prototype.getCmbSelectIntance = function() {
|
|
|
|
if (this.cmbSelectInstance) {
|
|
|
|
return this.cmbSelectInstance;
|
2023-08-14 09:43:21 +00:00
|
|
|
}
|
2023-08-31 07:39:57 +00:00
|
|
|
let combo = originalGetCmbSelectIntance.apply(this, arguments);
|
|
|
|
// Make sessions in the sessions dropdown links
|
|
|
|
combo.tpl.html = combo.tpl.html.replace(
|
|
|
|
/<div (.+?) style="(.+?)">(.+?)<\/div>/,
|
|
|
|
"<a href='#session/{id}' onclick='event.ctrlKey && event.stopImmediatePropagation()' $1 style='display: block; text-decoration: none; $2'>$3</a>"
|
|
|
|
);
|
|
|
|
return combo;
|
|
|
|
};
|
2023-08-14 09:43:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-11 05:00:26 +00:00
|
|
|
// Sort by name in wiki/resources
|
|
|
|
function wikiNodeSort(lhs, rhs) {
|
|
|
|
function isFolder(node) {
|
|
|
|
return node.data.type === unsafeWindow.Compass.enums.WikiNodeType.Folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isFolder(lhs) && !isFolder(rhs)) {
|
|
|
|
return -1;
|
|
|
|
} else if (!isFolder(lhs) && isFolder(rhs)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
let lhsName = lhs.data.name.toLowerCase();
|
|
|
|
let rhsName = rhs.data.name.toLowerCase();
|
|
|
|
if (lhsName < rhsName) {
|
|
|
|
return -1;
|
|
|
|
} else if (lhsName === rhsName) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let WikiBrowserPanel = getExtClass("Compass.widgets.WikiBrowserPanel");
|
|
|
|
if (WikiBrowserPanel) {
|
2023-10-13 03:49:09 +00:00
|
|
|
let originalInitComponent = WikiBrowserPanel.prototype.initComponent;
|
2023-10-04 02:01:03 +00:00
|
|
|
WikiBrowserPanel.prototype.initComponent = function() {
|
|
|
|
this.on("treeDataLoaded", function() {
|
|
|
|
this.treePanel.store.sort({sorterFn: wikiNodeSort});
|
|
|
|
});
|
2023-10-13 03:49:09 +00:00
|
|
|
originalInitComponent.apply(this, arguments);
|
2023-09-11 05:00:26 +00:00
|
|
|
}
|
2023-10-13 03:49:09 +00:00
|
|
|
|
|
|
|
let originalRenderLayout = WikiBrowserPanel.prototype.renderLayout;
|
|
|
|
WikiBrowserPanel.prototype.renderLayout = function() {
|
2023-11-04 03:15:08 +00:00
|
|
|
// Reveal filter and refresh toolbars
|
|
|
|
let readOnly = this.readOnly;
|
|
|
|
this.readOnly = false;
|
2023-10-13 03:49:09 +00:00
|
|
|
originalRenderLayout.apply(this, arguments);
|
2023-11-04 03:15:08 +00:00
|
|
|
this.readOnly = readOnly;
|
|
|
|
|
|
|
|
// hide tools button and context menu since it is useless to us
|
|
|
|
this.treePanel.down("#toolButton").hidden = true;
|
|
|
|
this.treePanel.events.itemcontextmenu = true;
|
|
|
|
|
|
|
|
// check if root node exists, otherwise pages like /Communicate/SchoolDocumentation.aspx will die
|
|
|
|
if (this.treePanel.getRootNode()) {
|
2023-10-13 03:49:09 +00:00
|
|
|
this.treePanel.store.sort({sorterFn: wikiNodeSort});
|
2023-11-04 03:15:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let originalSelectedNodeChanged = WikiBrowserPanel.prototype.selectedNodeChanged;
|
|
|
|
WikiBrowserPanel.prototype.selectedNodeChanged = function() {
|
|
|
|
// Reveal "View Permissions", "Visible to", and "Created by"
|
|
|
|
let readOnly = this.readOnly;
|
|
|
|
this.readOnly = false;
|
|
|
|
originalSelectedNodeChanged.apply(this, arguments);
|
|
|
|
this.readOnly = readOnly;
|
|
|
|
|
|
|
|
// hide things we can't touch
|
|
|
|
let toolbar = this.nodeViewerPanel.down("toolbar");
|
|
|
|
for (let item of toolbar.items.items) {
|
|
|
|
if (item.disabled) {
|
|
|
|
toolbar.remove(item);
|
|
|
|
}
|
2023-10-13 03:49:09 +00:00
|
|
|
}
|
|
|
|
};
|
2023-11-07 11:16:17 +00:00
|
|
|
|
|
|
|
let originalUpdateNodePermissions = WikiBrowserPanel.prototype.updateNodePermissions;
|
|
|
|
WikiBrowserPanel.prototype.updateNodePermissions = function() {
|
|
|
|
// prevent a network request from coming out to prevent arousing suspicion and to speed up things
|
|
|
|
let originalPostWithCallback = unsafeWindow.Compass.postWithCallback;
|
|
|
|
unsafeWindow.Compass.postWithCallback = function(url, data, callback) {
|
|
|
|
callback({d: false});
|
|
|
|
};
|
|
|
|
originalUpdateNodePermissions.apply(this, arguments);
|
|
|
|
unsafeWindow.Compass.postWithCallback = originalPostWithCallback;
|
|
|
|
};
|
2023-09-11 05:00:26 +00:00
|
|
|
}
|
2023-08-31 07:39:57 +00:00
|
|
|
|
|
|
|
|
2023-08-14 09:43:21 +00:00
|
|
|
function handleNewCalendarEvent(element, calendar) {
|
2023-07-22 11:04:28 +00:00
|
|
|
// Turn each calendar event into a link so that Link Hints can recognize it
|
|
|
|
let a = document.createElement("a");
|
|
|
|
for (let attr of element.attributes) {
|
|
|
|
a.setAttribute(attr.name, attr.value);
|
|
|
|
}
|
|
|
|
// fix learning tasks shrinking for some reason
|
|
|
|
a.style.display = "block";
|
2023-08-10 07:57:04 +00:00
|
|
|
// fix weird aboveline (underline but above the text) on hover
|
|
|
|
a.style.textDecoration = "none";
|
2023-07-22 11:04:28 +00:00
|
|
|
a.replaceChildren(...element.childNodes);
|
|
|
|
|
2023-08-06 10:11:30 +00:00
|
|
|
let calendarData = calendar.getEventRecordFromEl(element).data;
|
|
|
|
|
2023-07-22 11:04:28 +00:00
|
|
|
if (a.classList.contains("activity-type-1")) {
|
2023-08-06 10:11:30 +00:00
|
|
|
// Add a link for activities/"standard classes"
|
|
|
|
a.href = `/Organise/Activities/Activity.aspx?targetUserId=${calendarData.targetStudentId}#session/${calendarData.instanceId}`;
|
|
|
|
} 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}`;
|
|
|
|
}
|
2023-07-22 11:04:28 +00:00
|
|
|
} else if (a.classList.contains("activity-type-10")) {
|
|
|
|
// Add a link for learning tasks
|
2023-07-26 06:05:23 +00:00
|
|
|
let calendarPanel = calendar.ownerCalendarPanel;
|
2023-08-31 07:39:57 +00:00
|
|
|
a.href = "/Records/User.aspx"
|
|
|
|
if (calendarPanel.targetUserId !== undefined) {
|
|
|
|
a.href += `?userId=${calendarPanel.targetUserId}`;
|
|
|
|
}
|
2023-10-23 02:44:34 +00:00
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
// Link specifically to the learning task
|
|
|
|
a.href += `#learningTasks&qol_learning_task=${calendarData.learningTaskId}`;
|
2023-10-23 02:44:34 +00:00
|
|
|
|
|
|
|
// Hide user's last name on learning tasks
|
|
|
|
calendarData.longTitleWithoutTime = calendarData.longTitleWithoutTime.replace(/^.+?, /, "");
|
2023-07-22 11:04:28 +00:00
|
|
|
}
|
|
|
|
|
2023-08-06 10:11:30 +00:00
|
|
|
// 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);
|
2023-08-22 11:35:11 +00:00
|
|
|
let textElement = a.querySelector(".ext-evt-bd") || a;
|
2023-08-06 10:11:30 +00:00
|
|
|
// yes, innerHTML. longTitleWithoutTime can apparently contain HTML. lets hope that startString and finishString don't
|
2023-12-06 00:39:10 +00:00
|
|
|
if (textElement.innerHTML.startsWith(`${startString}: `)) {
|
2023-08-06 10:11:30 +00:00
|
|
|
textElement.innerHTML = `${startString} - ${finishString}: ${calendarData.longTitleWithoutTime}`;
|
|
|
|
}
|
|
|
|
|
2023-07-22 11:04:28 +00:00
|
|
|
// prevent ctrl-clicking from changing the current tab
|
|
|
|
// it seems like the link thing actually effectively killed the default handler anyway
|
2023-08-31 07:39:57 +00:00
|
|
|
if (a.href) {
|
2023-07-22 11:04:28 +00:00
|
|
|
a.addEventListener("click", function(event) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}, {passive: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
element.replaceWith(a);
|
|
|
|
}
|
|
|
|
|
2023-11-01 23:02:00 +00:00
|
|
|
function handlePanel(panel) {
|
|
|
|
let tabToOpen = window.location.pathname === "/Organise/Activities/Activity.aspx"
|
|
|
|
? getHashSearch().get("qol_open_tab")
|
|
|
|
: (window.location.hash.replace(/^#(.+?)(?:&.*)?$/, "$1") || null);
|
|
|
|
for (let i = 0; i < panel.items.items.length; i++) {
|
|
|
|
handlePanelItem(panel, panel.items.items[i], i === 0, tabToOpen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-26 01:12:52 +00:00
|
|
|
function handlePanelItem(panel, panelItem, isDefault, tabToOpen) {
|
|
|
|
let panelId = panelItem.itemId || panelItem.id;
|
2023-09-05 06:22:54 +00:00
|
|
|
// example of panel-<id>: /Organise/Subjects/Subject.aspx
|
2023-11-04 03:15:08 +00:00
|
|
|
// example of panelItem.title being undefined: /Communicate/SchoolDocumentation.aspx
|
|
|
|
if (panelId.startsWith("panel-") && panelItem.title) {
|
2023-09-05 06:22:54 +00:00
|
|
|
panelId = panelItem.title.toLowerCase().replaceAll(" ", "-");
|
|
|
|
}
|
2023-08-14 09:43:21 +00:00
|
|
|
let panelItemHash = getPanelItemHash(panelId, isDefault);
|
2023-09-01 01:35:11 +00:00
|
|
|
|
2023-07-26 01:12:52 +00:00
|
|
|
// Automatically open tab specified in fragment
|
|
|
|
if (panelId === tabToOpen) {
|
2023-09-01 01:26:10 +00:00
|
|
|
// if the sessions tab is automatically opened, the currently selected tab is still dashboard for some reason,
|
|
|
|
// hence this hook to open it when the dashboard finishes loading
|
2023-11-01 23:02:00 +00:00
|
|
|
if (!qolTabOpened && panel.setDashboardToLoading) {
|
2023-09-01 01:26:10 +00:00
|
|
|
let original = panel.setDashboardToLoading;
|
|
|
|
panel.setDashboardToLoading = function(loading) {
|
|
|
|
original.apply(this, arguments);
|
|
|
|
!loading && panel.setActiveTab(panelItem);
|
|
|
|
}
|
|
|
|
} else {
|
2023-07-26 06:05:23 +00:00
|
|
|
panel.setActiveTab(panelItem);
|
2023-09-01 01:26:10 +00:00
|
|
|
}
|
2023-07-22 11:04:28 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 05:48:24 +00:00
|
|
|
// /Communicate/SchoolDocumentation.aspx does not have tabs
|
|
|
|
if (!panelItem.tab) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-26 01:12:52 +00:00
|
|
|
panelItem.tab.preventDefault = false;
|
|
|
|
panelItem.tab.el.dom.href = panelItemHash;
|
|
|
|
|
|
|
|
panelItem.tab.el.dom.addEventListener("click", function(event) {
|
|
|
|
if (event.ctrlKey) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// prevent the browser from scrolling to the body
|
|
|
|
event.preventDefault();
|
2023-11-29 07:24:27 +00:00
|
|
|
if (modifyUrlHash && (window.location.pathname === "/Organise/Activities/Activity.aspx" || !window.location.hash.startsWith(`${panelItemHash}&`))) {
|
2023-07-26 01:12:52 +00:00
|
|
|
// Automatically add a reference to the tab when it is clicked
|
2023-11-29 07:24:27 +00:00
|
|
|
window.location.hash = panelItemHash;
|
2023-07-26 01:12:52 +00:00
|
|
|
}
|
|
|
|
});
|
2023-07-22 11:04:28 +00:00
|
|
|
}
|
|
|
|
|
2023-08-11 04:57:24 +00:00
|
|
|
function handleLearningTasksTable(element) {
|
|
|
|
// Make ctrl-clicking activities in a user's learning tasks tab no longer collapse everything else
|
|
|
|
for (let a of element.querySelectorAll(".x-grid-group-title a")) {
|
|
|
|
a.addEventListener("click", function(event) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}, {passive: true});
|
|
|
|
}
|
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
// Add links to learning tasks themselves
|
|
|
|
let gridView = Ext.getCmp(element.parentElement.id);
|
|
|
|
for (let item of gridView.store.data.items) {
|
|
|
|
let data = item.data;
|
|
|
|
let a = element.querySelector(`[gridrecordid="${data.gridRecordId}"]`);
|
2023-08-14 09:43:21 +00:00
|
|
|
|
2023-08-31 07:39:57 +00:00
|
|
|
let query = getHashSearch();
|
|
|
|
query.set("qol_learning_task", data.id);
|
|
|
|
a.href = `#${query.laxToString()}`;
|
|
|
|
a.addEventListener("click", function(event) {
|
|
|
|
if (event.ctrlKey) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
} else {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-08-14 09:43:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 07:26:52 +00:00
|
|
|
// Make links submitted to a learning task actual links
|
|
|
|
function handleLearningTaskSubmissionTable(element) {
|
|
|
|
let items = unsafeWindow.Ext.getCmp(element.id).store.data.items;
|
|
|
|
let lastColumns = element.querySelectorAll(".x-grid-cell-last img");
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
let item = items[i].data;
|
|
|
|
let img = lastColumns[i];
|
|
|
|
if (item.submissionFileType !== unsafeWindow.Compass.enums.LearningTasksSubmissionFileType.SubmissionUrl) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let a = document.createElement("a");
|
|
|
|
a.href = item.fileName;
|
|
|
|
a.addEventListener("click", function(event) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}, {passive: true});
|
|
|
|
img.replaceWith(a);
|
|
|
|
a.append(img);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-04 03:15:08 +00:00
|
|
|
// Make permissions grid more visible
|
2023-11-04 03:42:10 +00:00
|
|
|
function handlePermissionsWindow(node) {
|
|
|
|
node.querySelector(".x-mask").remove();
|
|
|
|
node.querySelector(".x-grid-body").style.pointerEvents = "none";
|
2023-11-04 03:15:08 +00:00
|
|
|
}
|
|
|
|
|
2023-08-03 11:25:19 +00:00
|
|
|
function handleCKEditor(instance) {
|
|
|
|
instance.on("contentDom", function() {
|
|
|
|
let editable = instance.editable();
|
|
|
|
for (let element of editable.$.querySelectorAll("a")) {
|
|
|
|
handleCKEditorLink(element);
|
|
|
|
}
|
|
|
|
observer.observe(editable.$, {childList: true, subtree: true});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleCKEditorLink(element) {
|
|
|
|
// Make links inside lesson plans open in the parent instead of a new tab
|
2023-09-10 22:31:47 +00:00
|
|
|
if (element.target === "_parent") {
|
2023-08-03 11:25:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
element.target = "_parent";
|
|
|
|
element.addEventListener("click", function(event) {
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}, {passive: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleNewNode(node, observer) {
|
|
|
|
if (node.nodeType !== 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-06 10:11:30 +00:00
|
|
|
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"))) {
|
2023-08-14 09:43:21 +00:00
|
|
|
let calendar = unsafeWindow.Ext.getCmp(node.closest(".x-component").id);
|
|
|
|
if (calendar.view) {
|
|
|
|
calendar = calendar.view;
|
|
|
|
}
|
2023-08-03 11:25:19 +00:00
|
|
|
for (let element of node.querySelectorAll("div.ext-cal-evt")) {
|
2023-08-14 09:43:21 +00:00
|
|
|
handleNewCalendarEvent(element, calendar);
|
2023-08-03 11:25:19 +00:00
|
|
|
}
|
|
|
|
} else if (!qolTabOpened && node.classList.contains("x-panel")) {
|
2023-09-01 01:26:10 +00:00
|
|
|
let topMostPanel = node;
|
|
|
|
while (topMostPanel.parentElement.closest(".x-panel")) {
|
|
|
|
topMostPanel = topMostPanel.parentElement.closest(".x-panel");
|
|
|
|
}
|
2023-11-01 23:02:00 +00:00
|
|
|
handlePanel(unsafeWindow.Ext.getCmp(topMostPanel.id));
|
|
|
|
qolTabOpened = true;
|
2023-08-03 11:25:19 +00:00
|
|
|
} else if (node.closest("[id^='wikibrowserpanel-'], #CompassWidgetsWikiBrowserPanel")) {
|
|
|
|
// Make files and folders in wiki/resources clickable for Link Hints
|
|
|
|
if (node.localName === "td") {
|
|
|
|
node.setAttribute("role", "button");
|
|
|
|
}
|
|
|
|
for (let element of node.querySelectorAll("td, .x-tree-expander")) {
|
|
|
|
element.setAttribute("role", "button");
|
|
|
|
}
|
2023-08-11 04:57:24 +00:00
|
|
|
} else if (node.localName === "table" && node.closest(".sel-learning-tasks-widget")) {
|
|
|
|
handleLearningTasksTable(node);
|
2023-09-06 07:26:52 +00:00
|
|
|
} else if (node.classList.contains("x-grid-view") && unsafeWindow.Ext.getCmp(node.id).up("#submissionsPanel")) {
|
|
|
|
handleLearningTaskSubmissionTable(node);
|
2023-11-10 00:38:48 +00:00
|
|
|
} else if (node.classList.contains("x-window")) {
|
|
|
|
let titleElement = node.querySelector(".x-window-header-text");
|
|
|
|
let title = titleElement ? titleElement.textContent : "";
|
|
|
|
if (title.startsWith("View Permissions for ")) {
|
|
|
|
handlePermissionsWindow(node);
|
|
|
|
}
|
2023-09-15 01:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (node.classList.contains("cke")) {
|
2023-08-03 11:25:19 +00:00
|
|
|
let instance = unsafeWindow.CKEDITOR.instances[node.id.substring(4)];
|
|
|
|
handleCKEditor(instance);
|
|
|
|
} else if (node.localName === "a" && /\bcke_/.test(node.closest("body").className)) {
|
|
|
|
handleCKEditorLink(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-14 09:43:21 +00:00
|
|
|
|
|
|
|
|
2023-08-03 11:25:19 +00:00
|
|
|
let observer = new MutationObserver(function(mutations, observer) {
|
|
|
|
for (let mutation of mutations) {
|
|
|
|
if (mutation.type !== "childList") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (let node of mutation.addedNodes) {
|
|
|
|
handleNewNode(node, observer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-08-14 09:43:21 +00:00
|
|
|
|
2023-08-03 11:25:19 +00:00
|
|
|
observer.observe(document.body, {childList: true, subtree: true});
|
|
|
|
document.body.addEventListener("click", function(event) {
|
2023-11-04 03:15:08 +00:00
|
|
|
if (event.target.classList.contains("x-mask") && event.target.parentElement.localName === "body") {
|
2023-08-03 11:35:10 +00:00
|
|
|
// Add the ability to close windows by clicking on the background
|
|
|
|
let maskZIndex = BigInt(event.target.style.zIndex);
|
|
|
|
for (let maskMsg of document.querySelectorAll(".x-mask-msg")) {
|
|
|
|
if (BigInt(maskMsg.style.zIndex) >= maskZIndex && maskMsg.style.display !== "none") {
|
|
|
|
return;
|
|
|
|
}
|
2023-08-03 11:25:19 +00:00
|
|
|
}
|
|
|
|
|
2023-08-10 08:07:52 +00:00
|
|
|
let closeButton = document.querySelector(".x-window-closable.x-window-active .x-tool-close");
|
|
|
|
if (closeButton) {
|
|
|
|
closeButton.click();
|
|
|
|
}
|
2023-08-03 11:35:10 +00:00
|
|
|
} else if (event.target.classList.contains("x-form-file-btn")) {
|
|
|
|
// Make Link Hints work with uploading files
|
|
|
|
event.target.querySelector("input[type=file]").click();
|
|
|
|
}
|
2023-08-03 11:25:19 +00:00
|
|
|
}, {passive: true});
|
|
|
|
|
2023-10-11 00:05:34 +00:00
|
|
|
// Allow submitting links by pressing Enter instead of clicking the button
|
|
|
|
document.body.addEventListener("keydown", function(event) {
|
|
|
|
if (event.key !== "Enter" || event.target.localName !== "input" || event.target.type !== "text") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let window = unsafeWindow.Ext.getCmp(event.target.closest(".x-window").id);
|
|
|
|
if (!window || window.itemId !== "urlSelectionModal") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.down("#saveButton").handler();
|
|
|
|
}, {passive: true});
|
|
|
|
|
2023-11-01 23:02:00 +00:00
|
|
|
// Re-open panel tabs and learning tasks when the URL changes
|
|
|
|
function getLearningTaskWindow() {
|
|
|
|
let LearningTasksSubmissionWidget = getExtClass("Compass.widgets.LearningTasksSubmissionWidget");
|
|
|
|
|
|
|
|
for (let window of document.querySelectorAll(".x-window")) {
|
|
|
|
window = unsafeWindow.Ext.getCmp(window.id);
|
|
|
|
if (unsafeWindow.Ext.getClass(window) === LearningTasksSubmissionWidget) {
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
function getLearningTaskTab(panel) {
|
|
|
|
return panel.items.items.find(function(tab) {
|
|
|
|
return tab.itemId === "learningtasks";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
window.addEventListener("hashchange", function(event) {
|
2024-01-31 05:40:34 +00:00
|
|
|
// workaround window.onhashchange being ignored by window.addEventListener("hashchange", ...)
|
|
|
|
if (window.onhashchange) {
|
|
|
|
window.onhashchange();
|
|
|
|
}
|
|
|
|
|
2023-11-01 23:02:00 +00:00
|
|
|
modifyUrlHash = false;
|
|
|
|
let isActivityPage = window.location.pathname === "/Organise/Activities/Activity.aspx";
|
|
|
|
let hashSearch = getHashSearch();
|
|
|
|
|
|
|
|
let panel = document.querySelector(".x-panel");
|
|
|
|
if (panel) {
|
|
|
|
panel = unsafeWindow.Ext.getCmp(panel.id);
|
|
|
|
if (isActivityPage && hashSearch.has("openLearningTaskTab")) {
|
|
|
|
panel.setActiveTab(getLearningTaskTab(panel));
|
2023-11-04 03:42:10 +00:00
|
|
|
} else if (hashSearch.size === 0 || (isActivityPage && hashSearch.size === 1)) {
|
2023-11-01 23:02:00 +00:00
|
|
|
event.stopImmediatePropagation();
|
|
|
|
panel.setActiveTab(panel.items.items[0]);
|
|
|
|
} else {
|
|
|
|
handlePanel(panel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let learningTaskWindow = getLearningTaskWindow();
|
|
|
|
if (learningTaskWindow) {
|
|
|
|
learningTaskWindow.close();
|
|
|
|
}
|
|
|
|
let learningTaskWidget = document.querySelector(".sel-learning-tasks-widget");
|
|
|
|
if (learningTaskWidget) {
|
|
|
|
unsafeWindow.Ext.getCmp(learningTaskWidget.id).openUrlLearningTask();
|
|
|
|
}
|
|
|
|
|
|
|
|
modifyUrlHash = true;
|
|
|
|
});
|
|
|
|
|
2023-08-22 11:35:11 +00:00
|
|
|
// Stop the calendar and email buttons from opening in a new tab
|
|
|
|
for (let element of document.querySelectorAll("#productNavBar a[target='_blank']")) {
|
|
|
|
element.removeAttribute("target");
|
2023-08-10 07:57:04 +00:00
|
|
|
}
|
|
|
|
|
2023-11-07 11:16:17 +00:00
|
|
|
// Prevent clicking "Loading Class Items..." from reloading the current page
|
|
|
|
let loadingClassItems = document.querySelector(".toolbar-classes-loading");
|
|
|
|
if (loadingClassItems) {
|
|
|
|
loadingClassItems.addEventListener("click", function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Preload subjects and classes when the page loads
|
|
|
|
let teachingAndLearning = document.querySelector(".toolbar-clickable-teaching-and-learning");
|
|
|
|
if (teachingAndLearning) {
|
|
|
|
new MutationObserver(function(mutations, observer) {
|
|
|
|
observer.disconnect();
|
|
|
|
teachingAndLearning.dispatchEvent(new MouseEvent("mouseover"));
|
|
|
|
}).observe(teachingAndLearning, {attributes: true});
|
|
|
|
}
|
|
|
|
|
2023-07-23 05:30:36 +00:00
|
|
|
// unsafeWindow.CKEDITOR may not be set if you're on the login page, for example
|
|
|
|
if (unsafeWindow.CKEDITOR) {
|
2023-09-10 22:31:47 +00:00
|
|
|
// Suppress that annoying barebones context menu that only has Copy
|
|
|
|
unsafeWindow.CKEDITOR.plugins.load("contextmenu", function() {
|
|
|
|
unsafeWindow.CKEDITOR.plugins.contextMenu.prototype.addTarget = function() {};
|
|
|
|
});
|
|
|
|
|
|
|
|
// Workaround https://github.com/lydell/LinkHints/issues/86
|
|
|
|
CKEDITOR.dom.document.prototype.write = function(data) {
|
|
|
|
this.$.documentElement.innerHTML = data;
|
|
|
|
for (let script of this.$.documentElement.querySelectorAll("script")) {
|
|
|
|
// script.cloneNode() makes it not execute for some reason
|
|
|
|
let scriptClone = document.createElement("script");
|
|
|
|
for (let attr of script.attributes) {
|
|
|
|
scriptClone.setAttribute(attr.name, attr.value);
|
|
|
|
}
|
|
|
|
scriptClone.innerText = script.innerText;
|
|
|
|
script.replaceWith(scriptClone);
|
2023-07-23 05:30:36 +00:00
|
|
|
}
|
2023-09-10 22:31:47 +00:00
|
|
|
this.$.dispatchEvent(new Event("DOMContentLoaded"));
|
2023-07-23 05:30:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uncheck the Remember Me button by default
|
|
|
|
if (window.location.pathname === "/login.aspx") {
|
|
|
|
document.querySelector("#rememberMeChk").checked = false;
|
|
|
|
}
|