add CONTRIBUTING, load from localhost, and remoteConfig
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..88cec2a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,29 @@
+# Contributing
+
+Before adding new features or making major changes, please open an issue or contact me at [[email protected]](mailto:[email protected]).
+
+## Documentation
+
+You can read the Power+ docs at [powerplus.app/docs](https://powerplus.app/docs).
+
+## Code Organization
+
+- `/scripts` Power+ script files
+- `/scripts/lms` LMS integration files
+- `/www` Static website files
+- `/docs` JSDoc configuration
+- `/chrome` Chrome extension source
+- `/build` Public website and optimized JavaScript files generated by `npm run build`
+
+## Development Environment
+
+To get Power+ up and running locally, you'll need git and node installed on your system. When the server is ready, open Power+ and go to Settings -> About -> Show Advanced Options -> Load from localhost and type in the port the server is running on (the default is 2750).
+
+```bash
+git clone https://github.com/jottocraft/dtps.git dtps
+cd dtps
+npm install
+npm start
+```
+
+## NPM scripts
diff --git a/README.md b/README.md
index e712c53..774ba72 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,6 @@
- [Documentation](https://powerplus.app/docs/)
- [Contributing](CONTRIBUTING.md)
-- [Contact me](mailto:[email protected])
## Bookmarklet
If you cannot use the Power+ [Chrome Extension](https://chrome.google.com/webstore/detail/power%20/pakgdifknldaiglefmpkkgfjndemfapo), you can add a bookmarklet instead to access Power+.
diff --git a/dtps.css b/dtps.css
index e3f3aa3..cb814e1 100644
--- a/dtps.css
+++ b/dtps.css
@@ -1262,7 +1262,7 @@
}
body.dashboard .background:before {
- background: linear-gradient(to bottom right, var(--cards), var(--background));
+ background: var(--grad, linear-gradient(to bottom right, var(--cards), var(--background)));
}
.cover.image {
diff --git a/scripts/core.js b/scripts/core.js
index d959ac6..788ecbd 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -32,11 +32,12 @@
* @property {DashboardItem[]} dashboardItems Array of items that can be shown on the dashboard
* @property {DashboardItem[]} leftDashboard Items on the left side of the dashboard based on dtps.dashboardItems and user prefrences. Set in dtps.loadDashboardPrefs.
* @property {DashboardItem[]} rightDashboard Items on the right side of the dashboard based on dtps.dashboardItems and user prefrences. Set in dtps.loadDashboardPrefs.
+ * @property {object} remoteConfig Configuration variables that can be remotely changed
*/
var dtps = {
ver: 304,
readableVer: "v3.0.4",
- env: window.jottocraftSatEnv || "prod",
+ env: window.localStorage.dtpsLoaderPref == "debugging" ? "dev" : window.jottocraftSatEnv || "prod",
classes: [],
baseURL: document.currentScript.src ? (String(document.currentScript.src).split('/')[0] + "//" + String(document.currentScript.src).split('/')[2]) : "https://powerplus.app",
unstable: window.localStorage.dtpsLoaderPref == "canary" || window.localStorage.dtpsLoaderPref == "debugging" || String(document.currentScript.src).includes("http://localhost"),
@@ -68,7 +69,14 @@
size: 250,
defaultSide: "right"
}
- ]
+ ],
+ remoteConfig: {
+ showFeedbackButton: false,
+ gradeCalculationEnabled: true,
+ showDonateButton: true,
+ allowWhatIfGrades: true,
+ showVideoMeetingButton: true
+ }
};
//Load jQuery ASAP
@@ -342,6 +350,10 @@
//Render loading screen
dtps.renderLoadingScreen();
+ //Get URL parameters
+ var urlParams = new URLSearchParams(window.location.search);
+ if (Array.from(urlParams).length) window.history.replaceState(null, null, window.location.pathname);
+
//Fluid UI settings
fluidThemes = [["midnight", "tome"], ["rainbow"]];
fluidAutoLoad = false;
@@ -358,8 +370,16 @@
//Begin loading static DTPS HTML
dtps.render();
- //Fetch user and class data
- dtpsLMS.fetchUser().then(data => {
+ //Fetch remote config
+ new Promise((r) => {
+ jQuery.getJSON('https://project-dtps.firebaseio.com/config.json', (remoteConfig) => {
+ if (remoteConfig) Object.assign(dtps.remoteConfig, remoteConfig);
+ r();
+ }).fail(r);
+ }).then(() => {
+ //Fetch user and class data
+ return dtpsLMS.fetchUser();
+ }).then(data => {
//Prevent resetting the user if the user is already set (for parent accounts)
if (!dtps.user) {
dtps.user = data;
@@ -598,6 +618,21 @@
//Changelog will only show if the release notes are on GitHub
dtps.changelog(true);
}
+
+ //Check URL parameter
+ if ((urlParams.get("prerelease") == "canary") && urlParams.get("repo")) {
+ fluid.alert("Power+ Canary", "<p>Do you want to add this release configuration to Power+?</p>", "build_circle", [
+ {
+ name: "Add",
+ icon: "add",
+ action: "window.localStorage.githubCanary = '" + urlParams.get("repo") + "'; alert('Please reload the page for changes to take effect');"
+ },
+ {
+ name: "Cancel",
+ icon: "cancel"
+ }
+ ]);
+ }
});
}).catch(function (err) {
//Web request error
@@ -864,7 +899,7 @@
//Set 500ms transition
dtps.bgTimeout = setTimeout(function () {
//Set theme to something random to force the theme change listener to update
- dtps.oldTheme = "squidward theme park";
+ dtps.oldTheme = "nklfsdlflsdajflks";
document.dispatchEvent(new CustomEvent('fluidTheme'));
//Remove transition
@@ -1382,8 +1417,8 @@
</div>
<div style="margin-top: 15px; margin-bottom: 7px;"><a onclick="dtps.changelog();" style="color: var(--lightText); margin: 0px 5px;" href="#"><i class="material-icons" style="vertical-align: middle">update</i> Changelog</a>
- <a onclick="if (window.confirm('Are you sure you want to uninstall Power+? The extension will be removed and all of your Power+ data will be erased. If you use the Power+ bookmarklet, you will have to remove that yourself.')) { document.dispatchEvent(new CustomEvent('extensionData', { detail: 'extensionUninstall' })); window.localStorage.clear(); window.alert('Power+ has been uninstalled. Reload the page to go back to ${dtpsLMS.shortName}.') }" style="color: var(--lightText); margin: 0px 5px;" href="#"><i class="material-icons" style="vertical-align: middle">delete_outline</i> Uninstall</a>
- <a style="color: var(--lightText); margin: 0px 5px;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=***REMOVED***&item_name=Donate+to+Power%2B¤cy_code=USD&source=url"><i class="material-icons" style="vertical-align: middle">attach_money</i> Donate</a>
+ <a onclick="if (window.confirm('Are you sure you want to uninstall Power+? The extension will be removed and all of your Power+ data will be erased. If you use the Power+ bookmarklet, you will have to remove that yourself.')) { document.dispatchEvent(new CustomEvent('extensionData', { detail: 'extensionUninstall' })); window.localStorage.clear(); window.alert('Power+ has been uninstalled. Reload the page to go back to ${dtpsLMS.shortName}.') }" style="color: var(--lightText); margin: 0px 5px; cursor: pointer;"><i class="material-icons" style="vertical-align: middle">delete_outline</i> Uninstall</a>
+ ${dtps.remoteConfig.showDonateButton ? `<a style="color: var(--lightText); margin: 0px 5px;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=***REMOVED***&item_name=Donate+to+Power%2B¤cy_code=USD&source=url"><i class="material-icons" style="vertical-align: middle">attach_money</i> Donate</a>` : ""}
<a style="color: var(--lightText); margin: 0px 5px;" href="mailto:[email protected]"><i class="material-icons" style="vertical-align: middle">email</i> Contact</a>
</div>
</div>
@@ -1423,8 +1458,8 @@
</div>
<div style="margin-top: 15px; margin-bottom: 7px;">
- <a style="color: var(--lightText); margin: 0px 5px;" onclick="dtps.clearData();" href="#"><i class="material-icons" style="vertical-align: middle">refresh</i> Reset Power+</a>
- <a style="color: var(--lightText); margin: 0px 5px;" href="https://github.com/jottocraft/dtps/issues/new/choose"><i class="material-icons" style="vertical-align: middle">bug_report</i> Bug Report / Feedback</a>
+ <a style="color: var(--lightText); margin: 0px 5px; cursor: pointer;" onclick="dtps.clearData();"><i class="material-icons" style="vertical-align: middle">refresh</i> Reset Power+</a>
+ <a style="color: var(--lightText); margin: 0px 5px; cursor: pointer;" onclick="window.localStorage.dtpsDebuggingPort = window.prompt('Please enter the port the server is running on'); alert('Reload the page for changes to take effect');"><i class="material-icons" style="vertical-align: middle">bug_report</i> Load from localhost</a>
</div>
</div>
@@ -1457,7 +1492,7 @@
<div style="margin-top: 5px; display: inline-block; text-align: right; float: right;">
<a href="/" class="itemButton"><i class="material-icons">exit_to_app</i> ${dtpsLMS.isDemoLMS ? "Exit demo" : "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>` : ""}
+ ${dtps.remoteConfig.showFeedbackButton || 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/dtech.js b/scripts/lms/dtech.js
index 1e7607c..b6273d3 100644
--- a/scripts/lms/dtech.js
+++ b/scripts/lms/dtech.js
@@ -52,6 +52,12 @@
//Update classes
dtpsLMS.updateClasses = function (classes) {
return new Promise((resolve, reject) => {
+ //Don't fetch videoMeetingURL if disable by remoteConfig
+ if (!dtps.remoteConfig.showVideoMeetingButton) {
+ resolve(classes);
+ return;
+ }
+
var promises = [];
//Create a new promise for each class
@@ -92,6 +98,9 @@
//Run d.tech grade calculation algorithm (defined below)
dtpsLMS.calculateGrade = function (course, assignments) {
+ //If grade calculation is disabled, don't run grade calc
+ if (!dtps.remoteConfig.gradeCalculationEnabled) return;
+
var formula = null;
//Get d.tech grade calculation formula
@@ -506,7 +515,7 @@
return /*html*/`
<p id="outcome${assessment.outcome}assessment${aIndex}" class="${aIndex == outcome.droppedScore ? "dropped" : ""}" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 6px 0px;">
<span aIndex="${aIndex}" outcomeID="${outcomeID}"
- style="outline: none;margin-right: 5px; font-size: 20px; vertical-align: middle; color: ${assessment.color}" class="editableScore" contenteditable>${assessment.score}</span>
+ style="outline: none;margin-right: 5px; font-size: 20px; vertical-align: middle; color: ${assessment.color}" class="editableScore" ${dtps.remoteConfig.allowWhatIfGrades ? `contenteditable` : ""}>${assessment.score}</span>
<span class="assessmentTitle" style="cursor: pointer;" onclick="dtps.assignment('${assessment.assignmentID}', ${course.num});">${assessment.assignmentTitle}</span>
</p>
`;
@@ -514,10 +523,12 @@
}
</div>
- <p class="addWhatIf" outcomeID="${outcomeID}" style="font-size: 14px; color: var(--secText); margin: 0px; margin-top: 16px; cursor: pointer;">
- <i style="cursor: pointer; vertical-align: middle; font-size: 16px;" class="material-icons down">add_box</i>
- Add a What-If grade
- </p>
+ ${dtps.remoteConfig.allowWhatIfGrades ? /*html*/`
+ <p class="addWhatIf" outcomeID="${outcomeID}" style="font-size: 14px; color: var(--secText); margin: 0px; margin-top: 16px; cursor: pointer;">
+ <i style="cursor: pointer; vertical-align: middle; font-size: 16px;" class="material-icons down">add_box</i>
+ Add a What-If grade
+ </p>
+ ` : ""}
</div>
`);
})