Update Compass QoL Enhancer to 1.17.0

- Sort files and folders alphabetically
This commit is contained in:
blankie 2023-09-11 15:00:26 +10:00
parent eb1a4ab0a3
commit 77b73718a6
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 32 additions and 1 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer
// @namespace blankie-scripts
// @match http*://*.compass.education/*
// @version 1.16.0
// @version 1.17.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
@ -205,6 +205,36 @@ if (InstanceDetailsWidget) {
};
}
// 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) {
let original = WikiBrowserPanel.prototype.renderLayout;
WikiBrowserPanel.prototype.renderLayout = function() {
original.apply(this, arguments);
this.treePanel.store.sort({sorterFn: wikiNodeSort});
}
}
function handleNewCalendarEvent(element, calendar) {

View File

@ -48,6 +48,7 @@ A userscript that adds small but useful features for Compass. Features are:
- The context menu that only says "Copy" is now suppressed
- Workaround a [Link Hints bug](https://github.com/lydell/LinkHints/issues/86)
that prevents it from seeing links inside lesson plans and such
- FIles and folders in Resources are now sorted alphabetically
- The option to remember logins is unchecked by default
- The dashboard tab in a user's profile no longer points you to #dsh