fixes
diff --git a/scripts/assignments.js b/scripts/assignments.js
index c6aa0c2..8df6c0d 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -660,56 +660,15 @@
body = dtps.brightenTextForDarkMode(assignment.body, computedBackgroundColor);
}
- var hasKeywords = false;
- if (body.toLowerCase().includes("deliverable") && body.toLowerCase().includes("instruction") && body.toLowerCase().includes("look for")) hasKeywords = true;
- if ((fluid.get('pref-formatAssignmentContent') !== "false") && dtpsLMS.dtech && hasKeywords && ($('<div></div>').append(body).children("table").find("tbody tr").length > 1)) {
- var sections = [];
- $('<div></div>').append(body).children("table").find("tbody tr").toArray().forEach((element, i) => {
- var text = $(element).find("h4:first-child").text().toLowerCase();
- if (!text) return;
-
- var tmpjQuery = $(element);
- tmpjQuery.find("h4:first-child").remove();
- var innerHTML = tmpjQuery.html();
- if (!innerHTML) return;
-
- var icon = null;
- if (text.includes("deliverable")) { icon = "description"; text = "Deliverables"; }
- if (text.includes("instruction")) { icon = "assignment"; text = "Instructions"; }
- if (text.includes("look for")) { icon = "find_in_page"; text = "Look Fors"; }
-
- sections.push({ text, icon, innerHTML });
- });
-
- var tmpjQuery = $('<div></div>').append(body);
- tmpjQuery.children("table").replaceWith(sections.map(s => {
- return `
- <div class="dtpsFormattedAssignmentSection" style="margin: 20px 0px;">
- <h2><i style="vertical-align: middle; margin-right: 10px; font-size: 24px;" class="material-icons-outlined">${s.icon}</i><span style="vertical-align: middle;text-decoration: underline;">${s.text}</span></h2>
- ${s.innerHTML}
- </div>
- `;
- }).join(""));
- var outerHTML = tmpjQuery.html();
-
- var blob = new Blob([`
+ //Generate a blob with the assignment body and get its data URL
+ var blob = new Blob([`
<base target="_blank" />
<link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
- <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};} .dtpsFormattedAssignmentSection *:not(a) { color: ${computedTextColor} !important; } .dtpsFormattedAssignmentSection * { background: none !important; }</style>
- ${outerHTML}
- `], { type: 'text/html' });
- assignmentBodyHTML = `<iframe id="assignmentParts" onload="dtps.iframeLoad('assignmentParts')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${window.URL.createObjectURL(blob)}" />`;
- } else {
- //Generate a blob with the assignment body and get its data URL
- var blob = new Blob([`
- <base target="_blank" />
- <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
- <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};}</style>
- ${body}
- `], { type: 'text/html' });
- assignmentBodyHTML = `<iframe id="assignmentIframe" onload="dtps.iframeLoad('assignmentIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${window.URL.createObjectURL(blob)}" />`;
- }
+ <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};}</style>
+ ${body}
+ `], { type: 'text/html' });
+ assignmentBodyHTML = `<iframe id="assignmentIframe" onload="dtps.iframeLoad('assignmentIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${window.URL.createObjectURL(blob)}" />`;
+
}
//Get assignment rubric HTML
diff --git a/scripts/core.js b/scripts/core.js
index 7aa541b..9757cce 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -1,7 +1,7 @@
/**
* @file DTPS Core functions and module loader
* @author jottocraft
- * @version v3.1.2
+ * @version v3.1.3
*
* @copyright Copyright (c) 2018-2021 jottocraft
* @license GPL-2.0-only
@@ -38,8 +38,8 @@
* @property {object} gtag The {@link https://developers.google.com/analytics/devguides/collection/ga4|gtag} object for Google Analytics configuration
*/
var dtps = {
- ver: 312,
- readableVer: "v3.1.2",
+ ver: 313,
+ readableVer: "v3.1.3",
env: new URL(window.dtpsBaseURL || "https://powerplus.app").hostname == "localhost" ? "dev" : window.jottocraftSatEnv || "prod",
classes: [],
baseURL: window.dtpsBaseURL || "https://powerplus.app",
@@ -108,6 +108,55 @@
*/
dtps.class = function () {
return dtps.classes[dtps.selectedClass];
+};
+
+//Detect debug info shortcut
+document.onkeydown = function (event) {
+ if (event.ctrlKey && event.altKey && (event.code == "KeyD")) {
+ var replacer = function(key, value) {
+ //Truncate long properties
+ if (["assignments", "people", "modules", "discussions", "pages", "outcomes"].includes(key)) {
+ if (value instanceof Array) return "[truncated] (array, length " + value.length + ")";
+ if (typeof value == "object") return "[truncated] (object, keys " + Object.keys(value).length + ")";
+ return value;
+ }
+
+ //Remove sensitive properties/PII
+ if (["letter", "number75", "grade", "lowestScore"].includes(key)) return "[redacted] (" + (typeof value) + ")";
+
+ return value;
+ };
+
+ $(".card.details").html(/*html*/`
+ <i onclick="fluid.cards.close('.card.details'); $('.card.details').html('');" class="fluid-icon close">close</i>
+
+ <h4 style="font-weight: bold;">Debug</h4>
+
+ <div style="margin: 40px 0px;">
+ <h5>User</h5>
+ <pre><code class="prettyprint">${JSON.stringify(dtps.user, null, '\t')}</code></pre>
+ </div>
+
+ ${
+ dtps.classes[dtps.selectedClass] ? /*html*/`
+ <div style="margin: 40px 0px;">
+ <h5>Selected class</h5>
+ <pre><code class="prettyprint">${JSON.stringify(dtps.classes[dtps.selectedClass], replacer, '\t')}</code></pre>
+ </div>
+ ` : ``
+ }
+ `);
+
+ if (!window.PR) {
+ $.getScript("https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=json");
+ } else {
+ PR.prettyPrint();
+ }
+
+ //Close other active cards and open the assignment details card
+ fluid.cards.close(".card.focus");
+ fluid.cards(".card.details");
+ }
}
/**
@@ -272,8 +321,8 @@
//Firebase modules
jQuery.getScript("https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js", () => {
jQuery.getScript("https://www.gstatic.com/firebasejs/8.2.4/firebase-analytics.js", () => {
- //Check for user opt-out
- if (window.localStorage.dtpsAnalyticsOptOut == "true") {
+ //Check for user opt-out (analytics temporarily disabled)
+ if ((window.localStorage.dtpsAnalyticsOptOut == "true") || true) {
window['ga-disable-G-KLKEMX3T6F'] = true;
}
@@ -1190,6 +1239,18 @@
//Use dark mode algorithm
if (!bg) bg = "black";
var fakeRoot = $('<div></div>').append(html);
+
+ //Reset text color to black if there is a background color set and no other color set
+ fakeRoot.find("*").filter(function () {
+ return ($(this).css("background-color") || $(this).css("background")) && !$(this).css("color") && !$(this).parents().filter(function () {
+ return $(this).css("color");
+ }).length;
+ }).toArray().forEach(element => {
+ //Reset to black
+ $(element).css("color", "#2D3B45");
+ });
+
+ //Brighten text colors
fakeRoot.find("span").filter(function () {
return $(this).css("color") && !($(this).css("background-color") || $(this).css("background")) && !$(this).parents().filter(function () {
return $(this).css("background-color") || $(this).css("background");
@@ -1206,6 +1267,7 @@
$(element).css("color", "#" + tinycolor($(element).css("color")).darken(Math.abs(brightnessDiff)).toHex());
}
});
+
return fakeRoot.html();
}
@@ -1827,19 +1889,9 @@
<div onclick="fluid.set('pref-hideClassImages')" class="switch pref-hideClassImages"><span class="head"></span></div>
<div class="label"><i class="fluid-icon">image</i> Hide class images</div>
- ${dtpsLMS.dtech ? /*html*/`
- <br /><br />
- <p>Assignments</p>
-
- <div onclick="fluid.set('pref-formatAssignmentContent');" class="switch pref-formatAssignmentContent active"><span class="head"></span></div>
- <div class="label"><i class="fluid-icon">format_paint</i> Reformat assignment content</div>
- ` : ""
- }
-
<div id="dtpsPrereleaseTesting" style="${window.localStorage.prereleaseEnabled || (dtps.env == "dev") || window.localStorage.githubRepo || window.localStorage.externalReleaseURL ? "" : "display: none;"}">
<br /><br />
<p>Prerelease testing</p>
- <p style="font-size: 12px;"><i>The dev version of Power+ has been temporarily disabled</i></p>
<div>
<div class="btns row small">
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 9b6c82c..4483689 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -118,6 +118,7 @@
people: !dtps.user.parent,
userID: userID,
period: course.sections && course.sections[0] && (course.sections.find(section => /[0-9](?=\(A)/.test(section.name)) || course.sections[0]).name,
+ section: course.sections && course.sections[0] && (course.sections.find(section => /[0-9](?=\(A)/.test(section.name)) || course.sections[0]).name,
subject: window.localStorage["pref-fullNames"] == "true" ? course.course_code : (course.original_name ? course.name : course.course_code.split(" - ")[0]),
homepage: course.default_view == "wiki",
term: course.course_code.split(" - ")[1],
@@ -136,12 +137,27 @@
//Save teachers in cache
dtpsLMS.teacherCache[course.id] = course.teachers;
- if (course.teachers[0]) {
+ if (course.teachers.length == 1) {
dtpsCourse.teacher = {
name: course.teachers[0] && course.teachers[0].display_name,
id: course.teachers[0] && course.teachers[0].id,
photoURL: course.teachers[0] && course.teachers[0].avatar_image_url
};
+ } else {
+ var matches = 0;
+ course.teachers.forEach(teacher => {
+ teacher.display_name.split(" ").forEach((fragment) => {
+ if (dtpsCourse.name.includes(fragment)) {
+ dtpsCourse.teacher = {
+ name: teacher.display_name,
+ id: teacher.id,
+ photoURL: teacher.avatar_image_url
+ };
+ matches++;
+ }
+ });
+ });
+ if (matches > 1) delete dtpsCourse.teacher;
}
courses.push(dtpsCourse);
diff --git a/scripts/lms/dtech.js b/scripts/lms/dtech.js
index 50a9ea6..48fa90b 100644
--- a/scripts/lms/dtech.js
+++ b/scripts/lms/dtech.js
@@ -70,6 +70,9 @@
if (course.term == "20-21") return;
if (course.endDate && (new Date() > new Date(course.endDate))) return;
+ //Manually filter out other stale courses
+ if (course.name.toUpperCase().includes("FEB 2021")) return;
+
//Check if course is ineligible for videoMeetingURL
if (!dtps.remoteConfig.showVideoMeetingButton || dtps.user.parent || !course.homepage || (course.term !== dtps.remoteConfig.dtechCurrentTerm)) {
course.videoMeetingURL = null;
@@ -79,16 +82,16 @@
var matches = course.period.match(/[0-9](?=\(A)/);
if (matches && matches[0]) {
course.period = matches[0] == "7" ? 0 : Number(matches[0]);
- } else if (/exploration/gi.test(course.subject)) {
- course.period = (/PM/g.test(course.subject) || /afternoon/gi.test(course.subject)) ? 12 : 11;
+ } else if (/(exploration)|(april 2021)/gi.test(course.name)) {
+ course.period = (/PM/g.test(course.name) || /afternoon/gi.test(course.name)) ? 12 : 11;
//Remove old intersession courses
var startDate = new Date(course.startDate);
if ((startDate.getFullYear() == 2020) && (startDate.getMonth() == 9)) return;
//Automatically detect AM/PM exploration and set the class name accordingly
- if (/AM/g.test(course.subject) || /morning/gi.test(course.subject)) course.subject = "Morning Exploration";
- if (/PM/g.test(course.subject) || /afternoon/gi.test(course.subject)) course.subject = "Afternoon Exploration";
+ if (/AM/g.test(course.name) || /morning/gi.test(course.name)) course.subject = "Morning Exploration";
+ if (/PM/g.test(course.name) || /afternoon/gi.test(course.name)) course.subject = "Afternoon Exploration";
} else {
course.period = Infinity;
}
@@ -131,7 +134,7 @@
} else if (/Exploration/gi.test(course.subject)) {
course.icon = "explore";
} else if (/@d.?tech/gi.test(course.subject)) {
- course.icon = "school";
+ course.icon = "supervisor_account";
} else if (/English/gi.test(course.subject)) {
course.icon = "description";
} else if (/Model( |-|)(United Nations|UN)/gi.test(course.subject)) {
@@ -148,6 +151,8 @@
course.icon = "stars";
} else if (/Athletics/gi.test(course.subject)) {
course.icon = "sports_handball";
+ } else if (/Beyond/gi.test(course.subject)) {
+ course.icon = "school";
}
//Add course to list
diff --git a/www/dev/index.html b/www/dev/index.html
index 5242cba..c5150b2 100644
--- a/www/dev/index.html
+++ b/www/dev/index.html
@@ -142,7 +142,7 @@
<img src="assets/dev.svg" />
<div class="description">
<h3>Development Status</h3>
- <p>v4 alpha - Very early development of Power+ v4 has begun. The dev version of Power+ will be temporarily disabled while some changes are being made.</p>
+ <p>Power+ (dev) has been deactivated</p>
<span>To start using the dev version of Power+, visit Settings -> About -> Advanced Options and
select "Test prerelease versions". Then, navigate to Settings -> Prerelease testing and select
"Dev". Once you've done that, just reload Power+ to load the dev version. Keep in mind that the