v3.0.2
diff --git a/chrome/communicator.js b/chrome/communicator.js
index c3d6cef..6a593d3 100644
--- a/chrome/communicator.js
+++ b/chrome/communicator.js
@@ -25,7 +25,7 @@
node.innerHTML = /*html*/`
<div dtps="true" id="dtpsNativeOverlay" style="background-color: #151515; position: fixed; top: 0px; left: 0px; width: 100%; height: 100vh; z-index: 99;text-align: center;z-index: 999;transition: opacity 0.2s;">
<img dtps="true" style="height: 100px; margin-top: 132px;" src="https://i.imgur.com/7dDUVh2.png" />
- <br dtps="true" />
+ <br dtps="true" />
<div dtps="true" class="progress"><div dtps="true" class="indeterminate"></div></div>
<style dtps="true">body {background-color: #151515; overflow: hidden;}*,:after,:before{box-sizing:border-box}.progress{position:relative;width:600px;height:5px;overflow:hidden;border-radius:12px;background:#262626;backdrop-filter:opacity(.4);display:inline-block;margin-top:75px}.progress .indeterminate{position:absolute;background:#e3ba4b;height:5px;animation:indeterminate 1.4s infinite;animation-timing-function:linear}@keyframes indeterminate{0%{width:5%;left:-15%}to{width:100%;left:110%}}</style>
</div>
@@ -72,13 +72,27 @@
//Stop observer
observer.disconnect();
+ //Determine LMS script to load
+ var lmsScript = null;
+ if (window.location.hostname.startsWith("dtechhs")) {
+ lmsScript = "dtech";
+ } else if (window.location.hostname.includes("instructure.com")) {
+ lmsScript = "canvas";
+ } else {
+ console.log("[DTPS CHROME]", "Could not find a valid LMS script for this site. Is Power+ supported on " + window.location.hostname + "?");
+ return;
+ }
+
+ //Check for debugging LMS overrides
+ if (window.localStorage.dtpsLMSOverride) lmsScript = window.localStorage.dtpsLMSOverride;
+
//load Power+ script
window.dtpsLoader = 4;
- var script = "https://powerplus.app/scripts/lms/dtech.js";
+ var script = "https://powerplus.app/scripts/lms/" + lmsScript + ".js";
//Check for debugging/canary scripts
- var debuggingPath = window.localStorage.dtpsDebuggingPort ? "http://localhost:" + window.localStorage.dtpsDebuggingPort + "/scripts/lms/dtech.js" : null;
- var canaryPath = window.localStorage.githubCanary ? "https://jottocraft.github.io/" + window.localStorage.githubCanary : null;
+ var debuggingPath = window.localStorage.dtpsDebuggingPort ? "http://localhost:" + window.localStorage.dtpsDebuggingPort + "/scripts/lms/" + lmsScript + ".js" : null;
+ var canaryPath = window.localStorage.githubCanary ? "https://jottocraft.github.io/" + window.localStorage.githubCanary + "/scripts/lms/" + lmsScript + ".js" : null;
//Check for version preference
if (debuggingPath && (window.localStorage.dtpsLoaderPref == "debugging")) {
@@ -98,7 +112,7 @@
console.log("[DTPS CHROME] Failed to load debugging script. Falling back to production.");
window.localStorage.dtpsLoaderPref = "prod";
var ss = document.createElement("script");
- ss.src = "https://powerplus.app/scripts/lms/dtech.js";
+ ss.src = "https://powerplus.app/scripts/lms/" + lmsScript + ".js";
ss.async = false;
ss.setAttribute("dtps", "true");
document.documentElement.appendChild(ss);
@@ -110,19 +124,25 @@
console.log("[DTPS Chrome] Redirecting after login...")
window.location.href = "/power+"
} else {
+ var releaseType = null;
+ if (window.localStorage.dtpsLoaderPref == "debugging") releaseType = "DEBUG";
+ if (window.localStorage.dtpsLoaderPref == "canary") releaseType = "CANARY";
+
const observer = new MutationObserver(mutations => {
mutations.forEach(({ addedNodes }) => {
addedNodes.forEach(node => {
//Power+ button
if (node.nodeType === 1 && node.id == "menu") {
- node.insertAdjacentHTML("beforeend", `<li class="ic-app-header__menu-list-item">
- <a href="/power+" style="cursor: pointer;" class="ic-app-header__menu-list-link">
- <div class="menu-item-icon-container" aria-hidden="true">
- <img src="https://powerplus.app/whiteOutline.png" class="ic-icon-svg">
- </div>
- <div class="menu-item__text" style="font-size: 14px;">Power+</div>
- </a>
- </li>`)
+ node.insertAdjacentHTML("beforeend", /*html*/`
+ <li class="menu-item ic-app-header__menu-list-item ">
+ <a id="global_nav_dtps_link" role="button" href="/power+" class="ic-app-header__menu-list-link">
+ <div class="menu-item-icon-container" aria-hidden="true">
+ <svg xmlns="http://www.w3.org/2000/svg" class="ic-icon-svg ic-icon-svg--dtps" version="1.1" viewBox="0 0 48 63.999"><path d="m5.333 0c-2.946 0-5.333 2.4-5.333 5.333v48c0 2.933 2.388 5.333 5.333 5.333h5.333v5.333l6.667-5.333 6.667 5.333v-5.333h18.667c2.947 0 5.333-2.4 5.333-5.333v-2.667c0 2.933-2.387 5.333-5.333 5.333h-18.667v-5.333h-13.333v5.333h-4c-2.209 0-4-1.867-4-4 0-2.4 1.791-4 4-4h36c2.947 0 5.333-2.4 5.333-5.333v-37.333c0-2.933-2.387-5.333-5.333-5.333h-37.333z"/></svg>
+ </div>
+ <div class="menu-item__text">${releaseType || "Power+"}</div>
+ </a>
+ </li>
+ `);
}
})
})
diff --git a/chrome/manifest.json b/chrome/manifest.json
index 0915878..42fd1a3 100644
--- a/chrome/manifest.json
+++ b/chrome/manifest.json
@@ -2,15 +2,15 @@
"manifest_version": 2,
"name": "Power+",
- "description": "A redesigned UI for Canvas LMS",
- "version": "3.0.0",
+ "description": "A better UI for Canvas LMS",
+ "version": "3.0.1",
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"run_at": "document_start",
- "matches": ["https://dtechhs.instructure.com/*", "https://powerplus.app/"],
+ "matches": ["https://*.instructure.com/*", "https://powerplus.app/"],
"js": ["communicator.js"]
}
],
diff --git a/dtps.css b/dtps.css
index 83e2184..e3f3aa3 100644
--- a/dtps.css
+++ b/dtps.css
@@ -1008,30 +1008,6 @@
border-color: #b7630a;
}
-.badge.dev {
- color: #0090ff;
- background-color: transparent !important;
- margin: 0px !important;
-}
-
-.badge.sudo {
- color: #d64c0c;
- background-color: transparent !important;
- margin: 0px !important;
-}
-
-.badge.marketer {
- color: var(--secText);
- background-color: transparent !important;
- margin: 0px !important;
-}
-
-.badge.contributor {
- color: #20da61;
- background-color: transparent !important;
- margin: 0px !important;
-}
-
.weight.parent {
padding: 0px !important;
overflow: visible;
@@ -1335,6 +1311,7 @@
margin: 0px 4px;
border-radius: 12px;
cursor: pointer;
+ color: var(--text);
}
.items.toolbar .itemButton i {
diff --git a/scripts/assignments.js b/scripts/assignments.js
index 8617efb..b38b03f 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -147,19 +147,21 @@
dtps.renderUpdates();
//Render upcoming assignments stream
- dtps.renderUpcoming();
+ dtps.renderUpcoming(doneLoading);
//Render calendar
dtps.calendar();
//Render due today
- dtps.renderDueToday();
+ dtps.renderDueToday(doneLoading);
}
/**
* Compiles and displays due today / to-do stream
+ *
+ * @param {boolean} doneLoading True if all classes have finished loading their assignment lists
*/
-dtps.renderDueToday = function () {
+dtps.renderDueToday = function (doneLoading) {
//Combine class stream arrays
var combinedStream = [];
if (dtps.classes) {
@@ -194,7 +196,11 @@
if (combinedStream.length == 0) {
//Nothing due today
- combinedHTML = `<p style="text-align: center;margin: 10px 25px 10px 75px; font-size: 18px;"><i class="material-icons">done</i> Nothing due today</p>`;
+ if (doneLoading) {
+ combinedHTML = `<p style="text-align: center;margin: 10px 25px 10px 75px; font-size: 18px;"><i class="material-icons">done</i> Nothing due today</p>`;
+ } else {
+ combinedHTML = ``;
+ }
} else {
//Add header
combinedHTML = /*html*/`
@@ -553,7 +559,7 @@
${assignment.category ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">category</i> Category: ${assignment.category}</p>` : ""}
${assignment.rubric ? assignment.rubric.map(function (rubricItem) { return `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">adjust</i> ${rubricItem.title}</p>`; }).join("") : ""}
<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">class</i> Class: ${dtps.classes[assignment.class].subject}</p>
- <p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">code</i> Assignment ID: ${assignment.id}</p>
+ ${dtps.env == "dev" ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">code</i> Assignment ID: ${assignment.id}</p>` : ""}
<br />
<div class="row">
@@ -648,8 +654,20 @@
//Get module action
var action = "";
if (item.type == "assignment") action = "dtps.assignment('" + item.id + "', " + classNum + ")";
- if (item.type == "page") action = "fluid.screen('pages', '" + classID + "|" + item.id + "')";
- if (item.type == "discussion") action = "fluid.screen('discussions', '" + classID + "|" + item.id + "')";
+ if (item.type == "page") {
+ if (dtps.classes[classNum].pages) {
+ action = "fluid.screen('pages', '" + classID + "|" + item.id + "')";
+ } else {
+ action = "window.open('" + item.url + "')";
+ }
+ }
+ if (item.type == "discussion") {
+ if (dtps.classes[classNum].discussions) {
+ action = "fluid.screen('discussions', '" + classID + "|" + item.id + "')";
+ } else {
+ action = "window.open('" + item.url + "')";
+ }
+ }
if (item.type == "url") action = "window.open('" + item.url + "')";
if (item.type == "header") action = "";
if (item.type == "embed") action = "dtps.showIFrameCard('" + item.url + "')";
@@ -683,6 +701,10 @@
`;
});
+ 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>`;
+ }
+
//Render module HTML
if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "moduleStream")) {
jQuery(".classContent").html(modulesHTML);
@@ -800,7 +822,7 @@
<p style="color: var(--secText)">${dtps.classes[num].description || ""}</p>
<div class="assignmentChip"><i class="material-icons">group</i><span>${dtps.classes[num].numStudents} students</span></div>
- <div class="assignmentChip"><i class="material-icons">code</i><span>Class ID: ${dtps.classes[num].id}</span></div>
+ ${dtps.env == "dev" ? `<div class="assignmentChip"><i class="material-icons">code</i><span>Class ID: ${dtps.classes[num].id}</span></div>` : ``}
<br />
@@ -1056,7 +1078,7 @@
* @property {string} type Either "assignment", "page", "discussion", "url", "embed", or "header".
* @property {string} [title] Required for URL and header items, and can be used to override the title of assignment, page, and discussion items.
* @property {string} [id] Required for assignment, page, and discussion items.
- * @property {string} [url] Required for URL and embed items.
+ * @property {string} [url] Required for URL and embed items. Required for discussion and page items if the class does not support the pages or discussions feature.
* @property {number} [indent] Indent level
*/
diff --git a/scripts/core.js b/scripts/core.js
index ad4e67d..4ed44fc 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -1,7 +1,7 @@
/**
* @file DTPS Core functions and module loader
* @author jottocraft
- * @version v3.0.1
+ * @version v3.0.2
*
* @copyright Copyright (c) 2018-2020 jottocraft. All rights reserved.
* @license GPL-2.0-only
@@ -17,6 +17,7 @@
* @global
* @namespace dtps
* @property {number} ver Comparable version number
+ * @property {string} env DTPS enviornment ("prod" or "dev")
* @property {string} readableVer Formatted semantic version number
* @property {Class[]} classes DTPS classes array
* @property {string} baseURL The base URL that DTPS is being loaded from
@@ -33,8 +34,9 @@
* @property {DashboardItem[]} rightDashboard Items on the right side of the dashboard based on dtps.dashboardItems and user prefrences. Set in dtps.loadDashboardPrefs.
*/
var dtps = {
- ver: 301,
- readableVer: "v3.0.1",
+ ver: 302,
+ readableVer: "v3.0.2",
+ env: window.jottocraftSatEnv || "prod",
classes: [],
baseURL: String(document.currentScript.src).split('/')[0] + "//" + String(document.currentScript.src).split('/')[2],
unstable: window.localStorage.dtpsLoaderPref == "canary" || window.localStorage.dtpsLoaderPref == "debugging" || String(document.currentScript.src).includes("http://localhost"),
@@ -150,7 +152,7 @@
* @param {string} msg The debugging message to log
*/
dtps.log = function (msg) {
- console.debug("[DTPS] ", msg);
+ if (dtps.env == "dev") console.log("[DTPS]", msg);
}
@@ -785,7 +787,7 @@
}
if ((dtps.selectedContent == "moduleStream") && dtps.classes[dtps.selectedClass]) {
- fluid.screen("modules", dtps.classes[dtps.selectedClass].id);
+ fluid.screen("moduleStream", dtps.classes[dtps.selectedClass].id);
}
if ((dtps.selectedContent == "grades") && dtps.classes[dtps.selectedClass]) {
@@ -1236,7 +1238,7 @@
<img src="https://powerplus.app/icon.svg" style="width: 50px;vertical-align: middle;padding: 7px; padding-top: 14px;" />
<div style="vertical-align: middle; display: inline-block;">
<h5 style="font-weight: bold;display: inline-block;vertical-align: middle;">Power+</h5>
- <p>${dtps.readableVer}</p>
+ <p>${dtps.readableVer + (window.localStorage.dtpsLoaderPref ? ` <span style="font-size: 12px;">(${window.localStorage.dtpsLoaderPref})</span>` : "")}</p>
</div>
</div>
@@ -1246,6 +1248,11 @@
<div onclick="$('.abtpage').hide();$('.abtpage.dashboard').show();" class="item">
<i class="material-icons">dashboard</i> Dashboard
</div>
+ ${dtps.env == "dev" ? /*html*/`
+ <div onclick="$('.abtpage').hide();$('.abtpage.debugging').show();" class="item">
+ <i class="material-icons">bug_report</i> Debugging
+ </div>
+ ` : ``}
<div onclick="$('.abtpage').hide();$('.abtpage.about').show(); if ($('body').hasClass('sudo')) { $('.advancedOptions').show(); $('.advOp').hide(); } else { $('.advancedOptions').hide(); $('.advOp').show(); }" class="item abt">
<i class="material-icons">info</i> About
</div>
@@ -1329,6 +1336,27 @@
</div>
+ ${dtps.env == "dev" ? /*html*/`
+ <div style="display: none;" class="abtpage debugging">
+ <h5>Debugging</h5>
+ <p>These settings are for development only and might break Power+. Use at your own risk.</p>
+
+ <br />
+
+ <div>
+ <input id="dtpsDebuggingPort" value="${window.localStorage.dtpsDebuggingPort || ""}" placeholder="Debugging Port" />
+ <button class="btn small" onclick="window.localStorage.setItem('dtpsDebuggingPort', $('#dtpsDebuggingPort').val())"><i class="material-icons">save</i> Save</button>
+ </div>
+
+ <br />
+
+ <div>
+ <input id="dtpsLMSOverride" value="${window.localStorage.dtpsLMSOverride || ""}" placeholder="LMS override" />
+ <button class="btn small" onclick="window.localStorage.setItem('dtpsLMSOverride', $('#dtpsLMSOverride').val())"><i class="material-icons">save</i> Save</button>
+ </div>
+ </div>
+ ` : ``}
+
<div style="display: none;" class="abtpage about">
<h5>About</h5>
@@ -1351,10 +1379,12 @@
</div>
<div class="card" style="padding: 10px 20px; box-shadow: none !important; border: 2px solid var(--elements); margin-top: 20px;">
- <img src="${dtps.user.photoURL}" style="height: 50px; margin-right: 10px; vertical-align: middle; margin-top: 20px; border-radius: 50%;" />
+ <div style="margin-top: 12px;">
+ <img src="${dtps.user.photoURL}" style="height: 50px; margin-right: 10px; vertical-align: middle; border-radius: 50%;" />
- <div style="display: inline-block; vertical-align: middle;">
- <h4 style="font-weight: bold; font-size: 32px; margin-bottom: 0px;">${dtps.user.name} <span style="font-size: 12px;">${dtps.user.id}</span></h4>
+ <div style="display: inline-block; vertical-align: middle;">
+ <h4 style="font-weight: bold; font-size: 32px; margin: 0px;">${dtps.user.name} <span style="font-size: 12px; line-height: 0px;">${dtps.user.id}</span></h4>
+ </div>
</div>
<div style="margin-top: 15px; margin-bottom: 7px;">
@@ -1416,7 +1446,7 @@
</div>
<div style="margin-top: 5px; display: inline-block; text-align: right; float: right;">
- <div onclick="window.location.href = '/';" class="itemButton"><i class="material-icons">exit_to_app</i> Go to ${dtpsLMS.shortName || dtpsLMS.name}</div>
+ <a href="/" class="itemButton"><i class="material-icons">exit_to_app</i> Go to ${dtpsLMS.shortName || dtpsLMS.name}</a>
${dtps.unstable ? `<div onclick="window.open('https://github.com/jottocraft/dtps/issues/new/choose')" class="itemButton"><i class="material-icons">feedback</i> Feedback</div>` : ""}
<div onclick="dtps.settings();" class="itemButton"><i class="material-icons">settings</i> Settings</div>
</div>
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 3361ea0..1e19c4a 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -318,14 +318,16 @@
type: "page",
title: item.title,
id: item.page_url,
- indent: item.indent
+ indent: item.indent,
+ url: item.html_url
})
} else if (item.type.toUpperCase() == "DISCUSSION") {
moduleItems.push({
type: "discussion",
title: item.title,
id: item.content_id,
- indent: item.indent
+ indent: item.indent,
+ url: item.html_url
})
} else if (item.type.toUpperCase() == "EXTERNALURL") {
moduleItems.push({