Skip to content

Commit

Permalink
Merge pull request #259 from aopell/develop
Browse files Browse the repository at this point in the history
Version 7.2.4
  • Loading branch information
aopell authored Mar 17, 2021
2 parents 78866e8 + 929464e commit f519763
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 21 deletions.
5 changes: 3 additions & 2 deletions js/all-idle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading all-idle.js");
(async function() {
await loadDependencies("all-idle", ["all"]);
})();

// hack for course aliases
(async function () {
Expand Down
10 changes: 7 additions & 3 deletions js/all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
while (!window.splusLoaded || !window.splusLoaded.has("preload")) { }
Logger.debug("Started loading all.js");
(async function() {
// Wait for preload.js to finish running
while (!window.splusLoaded) {
await new Promise(resolve => setTimeout(resolve, 10));
}
await loadDependencies("all", ["preload"]);
})();

// Inform user about theme
{
Expand Down Expand Up @@ -1259,5 +1264,4 @@ function indicateSubmittedAssignments() {
setTimeout(indicateSubmitted, 1000);
}

window.splusLoaded.add("all");
Logger.debug("Finished loading all.js");
5 changes: 3 additions & 2 deletions js/assessment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading assessment.js");
(async function() {
await loadDependencies("assessment", ["all"]);
})();

// modifications to Confirm Submission assessment popup
(function () {
Expand Down
5 changes: 3 additions & 2 deletions js/course.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading course.js");
(async function() {
await loadDependencies("course", ["all"]);
})();

let courseIdNumber;
let courseSettingsCourseName;
Expand Down
5 changes: 3 additions & 2 deletions js/courses.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading courses.js");
(async function() {
await loadDependencies("courses", ["all"]);
})();

for (let course of document.querySelectorAll("li.course-item.list-item")) {
let parent = course.parentNode;
Expand Down
5 changes: 3 additions & 2 deletions js/grades.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading grades.js");
(async function() {
await loadDependencies("grades", ["all"]);
})();

const timeout = ms => new Promise(res => setTimeout(res, ms));
const BUG_REPORT_FORM_LINK = "https://docs.google.com/forms/d/e/1FAIpQLScF1_MZofOWT9pkWp3EfKSvzCPpyevYtqbAucp1K5WKGlckiA/viewform?entry.118199430=";
Expand Down
5 changes: 3 additions & 2 deletions js/home.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading home.js");
(async function() {
await loadDependencies("home", ["all"]);
})();

/** @typedef {{id:number,title:string,message:string,timestamp?:Date,icon?:string}} Broadcast */

Expand Down
5 changes: 3 additions & 2 deletions js/materials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

"use strict";

while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading materials.js");
(async function() {
await loadDependencies("materials", ["all"]);
})();

(async function () {
let classId = window.location.pathname.match(/\/course\/(\d+)\/materials/)[1]; // ID of current course ("section"), as a string
Expand Down
5 changes: 3 additions & 2 deletions js/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
while (!window.splusLoaded || !window.splusLoaded.has("all")) { }
Logger.debug("Started loading page.js");
(async function() {
await loadDependencies("page", ["all"]);
})();

// Adds an "Open in New Tab" link to /page pages which simply embed something.
(function () {
Expand Down
15 changes: 15 additions & 0 deletions js/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1152,4 +1152,19 @@ new Setting(
);

window.splusLoaded = new Set(["preload"]);

async function loadDependencies(name, dependencies) {
if(window.splusLoaded.has(name)) {
throw new Error(`Already loaded ${name}`);
}

while (!dependencies.every(d => window.splusLoaded.has(d))) {
Logger.debug(`Waiting to load ${name}: some of ${dependencies} not in ${window.splusLoaded}`);
await new Promise(resolve => setTimeout(resolve, 100));
}

window.splusLoaded.add(name);
Logger.debug(`Starting loading ${name}.js`);
}

Logger.debug("Finished loading preload.js");
9 changes: 8 additions & 1 deletion js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,17 @@ class Theme {
};
let customSrc = Theme.getIcon(img.alt);
if(img.src !== customSrc) {
Logger.debug(img, img.src, customSrc)
img.src = customSrc;
}
img.classList.add("injected-course-icon");

if (img == bigCourseIcon && !document.querySelector("head > link[rel='icon'][type='image/svg+xml']")) {
let favicon = document.createElement("link");
favicon.rel = "icon";
favicon.type = "image/svg+xml";
favicon.href = customSrc;
document.head.appendChild(favicon);
}
}

if (isLAUSD() && !shownMissingIconsNotification && coursesMissingDefaultIcons.size > 0 && showToast) {
Expand Down
4 changes: 4 additions & 0 deletions js/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
(async function() {
await loadDependencies("user", ["all"]);
})();

(async function () {
// I hate try..catch but It will work
try {
Expand Down
8 changes: 8 additions & 0 deletions js/version-specific.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
(async function() {
// Wait for preload.js to finish running
while (!window.splusLoaded) {
await new Promise(resolve => setTimeout(resolve, 10));
}
await loadDependencies("version-specific", ["preload"]);
})();

/** Compares two version strings a and b.
* @param {string} a A string representing a numerical version.
* @param {string} b A string representing a numerical version.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"id": "[email protected]"
}
},
"version": "7.2.2",
"version": "7.2.4",
"icons": {
"128": "imgs/[email protected]",
"64": "imgs/[email protected]",
Expand Down

0 comments on commit f519763

Please sign in to comment.