faster load times, class icons, bugfixes
diff --git a/dtps.css b/dtps.css
index fd5d6c0..01f3fcd 100644
--- a/dtps.css
+++ b/dtps.css
@@ -1453,6 +1453,22 @@
#headText {
transition: color 0.2s;
+ white-space: nowrap;
+ max-width: 95%;
+ text-align: center;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+#headText span {
+ font-weight: bold;
+ vertical-align: middle;
+}
+
+#headText i {
+ margin-right: 5px;
+ vertical-align: middle;
+ font-size: 36px;
}
.gradeSummaryShowHide {
diff --git a/scripts/assignments.js b/scripts/assignments.js
index 650ecec..6750f63 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -546,7 +546,14 @@
} else if (assignments.length == 0) {
//This class doesn't have any assignments
if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "stream")) {
- $(".classContent").html(dtps.renderStreamTools(classNum, "stream") + `<div style="cursor: auto;" class="card"><h4>No assignments</h4><p>There aren't any assignments in this class yet</p></div>`);
+ $(".classContent").html(dtps.renderStreamTools(classNum, "stream") + /*html*/`
+ <div style="text-align: center;">
+ <div style="margin: 60px; padding: 20px 40px; display: inline-block; border: 2px solid var(--elements); border-radius: var(--elementRadius);">
+ <h5>No Assignments</h5>
+ <p>There aren't any assignments in this class yet.</p>
+ </div>
+ </div>
+ `);
}
} else {
//Sort assignments
@@ -913,7 +920,14 @@
});
if (data.length == 0) {
- modulesHTML += `<div style="cursor: auto;" class="card assignment"><h4>No modules</h4><p>There aren't any modules in this class yet</p></div>`;
+ modulesHTML += /*html*/`
+ <div style="text-align: center;">
+ <div style="margin: 60px; padding: 20px 40px; display: inline-block; border: 2px solid var(--elements); border-radius: var(--elementRadius);">
+ <h5>No Modules</h5>
+ <p>There aren't any modules in this class yet.</p>
+ </div>
+ </div>
+ `;
}
//Render module HTML
diff --git a/scripts/core.js b/scripts/core.js
index 7f21f03..a95902a 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -385,7 +385,7 @@
var promises = [];
dtps.user.children.forEach(child => {
- promises.push(new Promise(function(resolve, reject) {
+ promises.push(new Promise(function (resolve, reject) {
dtpsLMS.fetchClasses(child.id).then((data) => {
//Prepend child ID to class ID
data.forEach(course => {
@@ -608,16 +608,16 @@
...announcement
});
});
-
+
//Sort updates array from newest -> oldest
dtps.updates.sort(function (a, b) {
//Sort by postedAt (announcements) or gradedAt (assignments)
return new Date(b.gradedAt || b.postedAt).getTime() - new Date(a.gradedAt || a.postedAt).getTime()
});
-
+
//Keep only the 15 most recent updates
if (dtps.updates.length > 15) dtps.updates.length = 15;
-
+
if (dtps.selectedClass == "dash") {
fluid.screen();
}
@@ -797,7 +797,11 @@
}
if ((dtps.selectedContent == "moduleStream") && dtps.classes[dtps.selectedClass]) {
- fluid.screen("moduleStream", dtps.classes[dtps.selectedClass].id);
+ if (dtps.classes[dtps.selectedClass].modules) {
+ fluid.screen("moduleStream", dtps.classes[dtps.selectedClass].id);
+ } else {
+ fluid.screen("stream", dtps.classes[dtps.selectedClass].id);
+ }
}
if ((dtps.selectedContent == "people") && dtps.classes[dtps.selectedClass]) {
@@ -851,7 +855,14 @@
//Update title to show class name
//If the dashboard is selected, this is just "Dashboard". Otherwise, this is Class.subject
- $("#headText").html(classNum == "dash" ? "Dashboard" : dtps.classes[classNum] && dtps.classes[classNum].subject);
+ $("#headText span").text(classNum == "dash" ? "Dashboard" : dtps.classes[classNum] && dtps.classes[classNum].subject);
+ var icon = classNum == "dash" ? "dashboard" : dtps.classes[classNum] && dtps.classes[classNum].icon
+ if (icon) {
+ $("#headText i").text(icon);
+ $("#headText i").show();
+ } else {
+ $("#headText i").hide();
+ }
$("#headText").css("color", classNum == "dash" ? "var(--text)" : dtps.classes[classNum] && dtps.classes[classNum].color);
//If the class doesn't exist, hide the tabs
@@ -917,10 +928,29 @@
if (dtps.classes[classNum].videoMeetingURL) {
$("#classInfo .videoMeeting").attr("onclick", "window.open('" + dtps.classes[classNum].videoMeetingURL + "')");
+ $("#classInfo .videoMeeting").removeClass("shimmerParent");
+ $("#classInfo .videoMeeting").show();
+ } else if ((dtps.classes[classNum].videoMeetingURL !== null) && dtpsLMS.fetchMeetingURL) {
+ $("#classInfo .videoMeeting").attr("onclick", "");
+ $("#classInfo .videoMeeting").addClass("shimmerParent");
$("#classInfo .videoMeeting").show();
} else {
$("#classInfo .videoMeeting").hide();
}
+
+ dtpsLMS.fetchMeetingURL(dtps.classes[classNum].lmsID).then(url => {
+ dtps.classes[classNum].videoMeetingURL = url;
+
+ if (dtps.selectedClass == classNum) {
+ if (url) {
+ $("#classInfo .videoMeeting").attr("onclick", "window.open('" + dtps.classes[classNum].videoMeetingURL + "')");
+ $("#classInfo .videoMeeting").removeClass("shimmerParent");
+ $("#classInfo .videoMeeting").show();
+ } else {
+ $("#classInfo .videoMeeting").hide();
+ }
+ }
+ });
}
}
@@ -1360,7 +1390,7 @@
<div class="headerArea classImage">
<img style="display: none;" />
<div class="content">
- <h1 id="headText">Dashboard</h1>
+ <h1 id="headText"><i class="material-icons">dashboard</i> <span>Dashboard</span></h1>
<div id="classInfo" style="min-height: 18px;">
<p class="teacher" style="display: none;">
<span class="teacherImage"></span> <span class="teacherName"></span>
@@ -1539,7 +1569,7 @@
<div onclick="fluid.set('pref-formatAssignmentContent');" class="switch pref-formatAssignmentContent active"><span class="head"></span></div>
<div class="label"><i class="material-icons">format_paint</i> Reformat assignment content</div>
` : ""
- }
+ }
</div>
@@ -1833,6 +1863,14 @@
*/
/**
+* @name dtpsLMS.fetchMeetingURL
+* @description [OPTIONAL] Fetches the videoMeetingURL for a class
+* @kind function
+* @param {string} classID The class ID to get the videoMeetingURL for
+* @return {Promise<string>} A promise which resolves to the videoMeetingURL for the class, or null if the class does not have a videoMeetingURL
+*/
+
+/**
* @name dtpsLMS.fetchHomepage
* @description [OPTIONAL] Fetches homepage HTML for a course from the LMS
* @kind function
@@ -1957,6 +1995,7 @@
* @property {string} userID The ID of the user this class is associated with (from the parameter of dtpsLMS.fetchClasses)
* @property {number} num Index of the class in the dtps.classes array
* @property {string} subject Class subject
+* @property {string} [icon] The icon to show with this class
* @property {string} [group] The name of the group that this class is in
* @property {number|string} [period] The period or section the user has this class at
* @property {Date} [endDate] The end date for this course
@@ -1965,10 +2004,7 @@
* @property {DiscussionThread[]|boolean} [discussions] Class discussion threads. Assume this class supports discussions, but not yet loaded, if this is true and that the class has no threads if this is an empty array. For LMSs that do not support discussions, either keep it undefined or set it to false.
* @property {Page[]|boolean} [pages] Class pages. Assume this class supports the pages feature, but not yet loaded, if true and that the class has no pages if this is an empty array. For LMSs that do not support pages, either keep it undefined or set it to false.
* @property {string} [newDiscussionThreadURL] A URL the user can visit to create a new discussion thread in this class
-* @property {string} [syllabus] Class syllabus HTML
* @property {boolean} [homepage] True if the class has a homepage. If a class has a homepage, dtpsLMS.fetchHomepage must be implemented.
-* @property {string} [description] Class description HTML
-* @property {number} [numStudents] Number of students in the class
* @property {string} [term] Class term
* @property {string} [color] Class color
* @property {number} [grade] Current percentage grade in the class
@@ -1978,5 +2014,5 @@
* @property {User} [teacher] Class teacher. If the class has multiple teachers, this is the primary teacher.
* @property {boolean} [hasGradebook] Automatically managed by DTPS. True if the class should show the gradebook tab.
* @property {object} [gradeCalculation] Automatically managed by DTPS. If custom grade calculation is implemented, this will be the results from custom grade calculation returned by dtpsLMS.calculateGrade.
-* @property {string} [videoMeetingURL] The URL used to join this class' online meeting
+* @property {string} [videoMeetingURL] The URL used to join this class' online meeting. If dtpsLMS.fetchMeetingURL is implemented, DTPS will use it to get the meeting URL if this property is undefined. If this property is null, DTPS will not call dtpsLMS.fetchMeeting URL for the class.
*/
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 306dd7b..6e95f9e 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -88,7 +88,7 @@
headers: dtpsLMS.commonHeaders,
success: function (dashboardData) {
jQuery.ajax({
- url: "/api/v1/users/" + userID + "/courses?per_page=100&enrollment_state=active&include[]=term&include[]=total_scores&include[]=public_description&include[]=total_students&include[]=account&include[]=teachers&include[]=course_image&include[]=syllabus_body&include[]=tabs&include[]=sections",
+ url: "/api/v1/users/" + userID + "/courses?per_page=100&enrollment_state=active&include[]=term&include[]=total_scores&include[]=account&include[]=teachers&include[]=course_image&include[]=tabs&include[]=sections",
type: "GET",
headers: dtpsLMS.commonHeaders,
success: function (courseData) {
@@ -105,10 +105,7 @@
userID: userID,
period: course.sections && course.sections[0] && course.sections[0].name,
subject: window.localStorage["pref-fullNames"] == "true" ? course.course_code : course.course_code.split(" - ")[0],
- syllabus: course.syllabus_body,
homepage: course.default_view == "wiki",
- description: course.public_description,
- numStudents: course.total_students,
term: course.course_code.split(" - ")[1],
color: colorData.custom_colors["course_" + course.id],
grade: course.enrollments[0].computed_current_score,
diff --git a/scripts/lms/dtech.js b/scripts/lms/dtech.js
index 1781d3d..dfc71c1 100644
--- a/scripts/lms/dtech.js
+++ b/scripts/lms/dtech.js
@@ -26,7 +26,7 @@
dtpsLMS.dtech = true;
//Check if due date is usual
- dtpsLMS.isUsualDueDate = function(date) {
+ dtpsLMS.isUsualDueDate = function (date) {
var date = new Date(date);
if (date.getHours() >= 22) {
@@ -78,11 +78,16 @@
tmpNewArray.push(course);
}
+ //Check if course is ineligible for videoMeetingURL
+ if (!dtps.remoteConfig.showVideoMeetingButton || !course.homepage || (course.term !== dtps.remoteConfig.dtechCurrentTerm)) {
+ course.videoMeetingURL = null;
+ }
+
//Get course period
var matches = course.period.match(/[0-9](?=\(A)/);
if (matches && matches[0]) {
course.period = matches[0] == "7" ? 0 : Number(matches[0]);
- } else if (/((d|design).?lab)/gi.test(course.subject)) {
+ } else if (/(d|design)(\.| |-)?lab/gi.test(course.subject)) {
course.period = 11;
} else if (/exploration/gi.test(course.subject)) {
course.period = 12;
@@ -100,6 +105,47 @@
course.group = "Intersession";
}
}
+
+ //Add course icon
+ if (course.id == dtps.remoteConfig.debugClassID) {
+ course.icon = "bug_report";
+ } else if (/Game/gi.test(course.subject)) {
+ course.icon = "games";
+ } else if (/Architecture/gi.test(course.subject)) {
+ course.icon = "architecture";
+ } else if (/History/gi.test(course.subject)) {
+ course.icon = "history_edu";
+ } else if (/Biology/gi.test(course.subject)) {
+ course.icon = "biotech";
+ } else if (/Physics|Science|Chemistry/gi.test(course.subject)) {
+ course.icon = "science";
+ } else if (/Math|Algebra|Geometry|Calculus|Statistics/gi.test(course.subject)) {
+ course.icon = "calculate";
+ } else if (/Engineering|DRG/gi.test(course.subject)) {
+ course.icon = "engineering";
+ } else if (/((d|design)(\.| |-)?lab)|Prototyping/gi.test(course.subject)) {
+ course.icon = "design_services";
+ } else if (/Exploration/gi.test(course.subject)) {
+ course.icon = "explore";
+ } else if (/@d.?tech/gi.test(course.subject)) {
+ course.icon = "school";
+ } else if (/English/gi.test(course.subject)) {
+ course.icon = "description";
+ } else if (/Model( |-|)(United Nations|UN)/gi.test(course.subject)) {
+ course.icon = "public";
+ } else if (/Spanish|Language/gi.test(course.subject)) {
+ course.icon = "translate";
+ } else if (/Government/gi.test(course.subject)) {
+ course.icon = "gavel";
+ } else if (/(Koi|Live)( |-|)Stream/gi.test(course.subject)) {
+ course.icon = "live_tv";
+ } else if (/Film/gi.test(course.subject)) {
+ course.icon = "camera_roll";
+ } else if (/Leadership/gi.test(course.subject)) {
+ course.icon = "stars";
+ } else if (/Athletics/gi.test(course.subject)) {
+ course.icon = "sports_handball";
+ }
});
classes = tmpNewArray;
@@ -109,51 +155,43 @@
return a.period - b.period;
});
}
-
- //Don't fetch videoMeetingURL if disable by remoteConfig
- if (!dtps.remoteConfig.showVideoMeetingButton) {
- resolve(classes);
- return;
- }
- var promises = [];
-
- //Create a new promise for each class
- classes.forEach(course => {
- if (course.homepage && (course.term == dtps.remoteConfig.dtechCurrentTerm)) {
- promises.push(new Promise((resolve, reject) => {
- dtpsLMS.fetchHomepage(course.lmsID).then(homepage => {
- //get zoom link
- var matches = 0;
- for (var i = 0; i < $(homepage).find("a").length; i++) {
- var link = $($(homepage).find("a")[i]);
- if (link.children("img").attr("alt") && link.children("img").attr("alt").toUpperCase().includes("ZOOM BUTTON") && link.attr("href")) {
- //Button labelled as zoom button
- course.videoMeetingURL = link.attr("href");
- } else if (link.attr("href") && link.attr("href").includes("zoom.us")) {
- //Button link goes to a zoom meeting, only use this if there is no other zoom link
- //if (!course.videoMeetingURL) course.videoMeetingURL = link.attr("href");
- }
- }
-
- if (matches > 1) {
- //Multiple zoom links found
- course.videoMeetingURL = null;
- }
-
- resolve();
- })
- }))
- }
- })
-
- //Run all promises
- Promise.all(promises).then(() => {
- resolve(classes);
- })
+ resolve(classes);
});
}
+ //Fetch videoMeetingURL for a class
+ dtpsLMS.fetchMeetingURL = function (classID) {
+ return new Promise((resolve, reject) => {
+ var course = dtps.classes.find(course => course.id == classID);
+
+ if (course.homepage && (course.term == dtps.remoteConfig.dtechCurrentTerm)) {
+ dtpsLMS.fetchHomepage(classID).then(homepage => {
+ //get zoom link
+ var meetingURL = null;
+ var matches = 0;
+ for (var i = 0; i < $(homepage).find("a").length; i++) {
+ var link = $($(homepage).find("a")[i]);
+ if (link.children("img").attr("alt") && link.children("img").attr("alt").toUpperCase().includes("ZOOM BUTTON") && link.attr("href")) {
+ //Button labelled as zoom button
+ meetingURL = link.attr("href");
+ } else if (link.attr("href") && link.attr("href").includes("zoom.us")) {
+ //Button link goes to a zoom meeting, only use this if there is no other zoom link
+ //if (!meetingURL) meetingURL = link.attr("href");
+ }
+ }
+
+ if (matches > 1) {
+ //Multiple zoom links found
+ meetingURL = null;
+ }
+
+ resolve(meetingURL);
+ });
+ }
+ })
+ }
+
//Run d.tech grade calculation algorithm (defined below)
dtpsLMS.calculateGrade = function (course, assignments) {
//If grade calculation is disabled, don't run grade calc
diff --git a/scripts/people.js b/scripts/people.js
index cb0f55e..4367e63 100644
--- a/scripts/people.js
+++ b/scripts/people.js
@@ -98,7 +98,7 @@
jQuery(".classContent").html(/*html*/`
<div style="--size: 250px; margin: 0px 20px;" class="grid flex">
<div class="block status card">
- <h2 class="main">${currentSection || "--"}</h2>
+ <h2 style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="main">${currentSection || "--"}</h2>
<h5 class="bottom"><i class="material-icons">contact_page</i> Your section</h5>
</div>
<div class="block status">