diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index a8a8bc52..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,10 +0,0 @@ - - -#### ISSUE TYPE - -- [ ] Bug Report -- [ ] Feature Request - -#### DESCRIPTION - - diff --git a/js/all.js b/js/all.js index 0cf26c46..a27b8fea 100644 --- a/js/all.js +++ b/js/all.js @@ -7,24 +7,26 @@ document.getElementById("home").innerHTML = svg; document.documentElement.style.setProperty("--default-visibility", "visible"); document.body.appendChild(createElement("script", undefined, { src: "https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.7.1/gist-embed.min.js" })); -let footerText = `© Aaron Opell 2018 | Schoology Plus v${chrome.runtime.getManifest().version}${chrome.runtime.getManifest().update_url ? '' : ' dev'} | View Source and Contribute | Contributors | Changelog`; +let footerText = `© Aaron Opell 2018 | Schoology Plus v${chrome.runtime.getManifest().version}${chrome.runtime.getManifest().update_url ? '' : ' dev'} | Send Feedback | View Source & Contribute | Contributors | Changelog`; let frame = document.createElement("iframe"); frame.src = "data:text/html;charset=utf-8,"; let modals = [ - new Modal("settings-modal", "Schoology Plus Settings", getModalContents(), footerText, openOptionsMenu), + new Modal( + "settings-modal", + "Schoology Plus Settings", + getModalContents(), + footerText, + openOptionsMenu + ), new Modal( "changelog-modal", "Schoology Plus Changelog", frame, "© Aaron Opell 2018", - () => { - let updateText = document.querySelector(".new-update"); - if (updateText) updateText.outerHTML = ""; - let notifier = document.querySelector(".schoology-plus-icon .nav-icon-button .notifier"); - if (notifier) notifier.outerHTML = ""; - chrome.storage.sync.set({ newVersion: chrome.runtime.getManifest().version }); + function () { + clearNewUpdate(true); } ), new Modal( @@ -53,25 +55,32 @@ let modals = [ ) ]; -chrome.storage.sync.get("newVersion", s => { +chrome.storage.sync.get(["newVersion", "hideUpdateIndicator"], s => { if (!s.newVersion || s.newVersion != chrome.runtime.getManifest().version) { - document.getElementById("open-changelog") - .insertAdjacentElement( - "afterbegin", - createElement( - "span", - ["new-update"], - { textContent: "New Update" } - )); + chrome.storage.sync.set({ hideUpdateIndicator: false }, showUpdateIndicator); document.querySelector(".schoology-plus-icon .nav-icon-button") .appendChild(createElement( "span", ["notifier"], { textContent: "!!" } )); + } else if (!s.hideUpdateIndicator) { + showUpdateIndicator(); } }); +function showUpdateIndicator() { + console.log("Showing update indicator"); + document.getElementById("open-changelog") + .insertAdjacentElement( + "afterbegin", + createElement( + "span", + ["new-update"], + { textContent: "New Update" } + )); +} + let video = document.body.appendChild(createElement("video", ["easter-egg"], { onended: function () { this.style.visibility = "hidden"; @@ -118,11 +127,23 @@ window.onclick = function (event) { } } +function clearNewUpdate(clearAll) { + let notifier = document.querySelector(".schoology-plus-icon .nav-icon-button .notifier"); + if (notifier) notifier.outerHTML = ""; + chrome.storage.sync.set({ newVersion: chrome.runtime.getManifest().version }); + if (clearAll) { + chrome.storage.sync.set({ hideUpdateIndicator: true }); + let updateText = document.querySelector(".new-update"); + if (updateText) updateText.outerHTML = ""; + } +} + function openOptionsMenu(settingsModal) { settingsModal.body.innerHTML = ""; settingsModal.body.appendChild(getModalContents()); - settingsModal.element.querySelector("#open-changelog").addEventListener("click", () => openModal("changelog-modal")); - settingsModal.element.querySelector("#open-contributors").addEventListener("click", () => openModal("contributors-modal")); + settingsModal.element.querySelector("#open-changelog").addEventListener("click", () => openModal("changelog-modal"), { once: true }); + settingsModal.element.querySelector("#open-contributors").addEventListener("click", () => openModal("contributors-modal"), { once: true }); + clearNewUpdate(false); } function openModal(id) { @@ -142,6 +163,7 @@ function modalClose(element) { if (!confirm("You have unsaved settings.\nAre you sure you want to exit?")) return; updateSettings(); } + element.style.display = "none"; } diff --git a/js/background.js b/js/background.js index 9cbc8ba2..1e9410d8 100644 --- a/js/background.js +++ b/js/background.js @@ -72,11 +72,7 @@ function onAlarm(alarm) { if (notificationDate > time) { time = notificationDate; timeModified = true; - let count = 0; - if (extraTextElement) { - count = +extraTextElement.textContent.match(/\d+/)[0]; - } - totalAssignments += count + assignments.length; + totalAssignments++; console.dir(notification); } } diff --git a/js/grades.js b/js/grades.js index 2ae75876..fe4bdd24 100644 --- a/js/grades.js +++ b/js/grades.js @@ -148,7 +148,7 @@ for (let course of courses) { let grade = createElement("span",["awarded-grade","injected-title-grade",courseGrade ? "grade-active-color" : "grade-none-color"]); grade.textContent = courseGrade ? courseGrade.textContent : "—"; - if (grade.textContent.match(/^\d+\.?\d*%/) !== null) { + if (storage["assumeScale"] != "disabled" && grade.textContent.match(/^\d+\.?\d*%/) !== null) { let percent = Number.parseFloat(grade.textContent.substr(0, grade.textContent.length - 1)); let letterGrade = percent >= 90 ? "A" : (percent >= 80 ? "B" : (percent >= 70 ? "C" : (percent >= 60 ? "D" : "F"))); grade.textContent = `${letterGrade} (${percent}%)`; @@ -246,7 +246,7 @@ function setGradeText(gradeElement, sum, max, row, doNotDisplay) { // move the letter grade over to the right span = row.querySelector(".comment-column").firstChild; span.textContent = text; - if (span.textContent.match(/^\d+\.?\d*%/) !== null) { + if (storage["assumeScale"] != "disabled" && span.textContent.match(/^\d+\.?\d*%/) !== null) { let percent = Number.parseFloat(span.textContent.substr(0, span.textContent.length - 1)); let letterGrade = percent >= 90 ? "A" : (percent >= 80 ? "B" : (percent >= 70 ? "C" : (percent >= 60 ? "D" : "F"))); span.textContent = `${letterGrade} (${percent}%)`; diff --git a/js/preload.js b/js/preload.js index cc17d438..a25ad06f 100644 --- a/js/preload.js +++ b/js/preload.js @@ -106,6 +106,27 @@ function updateSettings() { undefined, element => element.value ), + createSetting( + "assumeScale", + "Assume Grading Scale", + "[Refresh required] Assumes a 10%-based grading scale (90-100 A, 80-89 B, etc.) when a class has no grading scale", + "select", + { + options: [ + { + text: "Enabled", + value: "tenPercent" + }, + { + text: "Disabled", + value: "disabled" + } + ] + }, + (value, element) => element.value = value || "tenPercent", + undefined, + element => element.value + ), createElement("div", ["settings-buttons-wrapper"], undefined, [ createElement("span", ["submit-span-wrapper", "modal-button"], { onclick: saveSettings }, [createElement("input", ["form-submit"], { type: "button", value: "Save Settings", id: "save-settings" })]), createElement("a", ["restore-defaults"], { textContent: "Restore Defaults", onclick: restoreDefaults, href: "#" }) diff --git a/manifest.json b/manifest.json index f16d3d9d..74c2a550 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Schoology Plus", "short_name": "Schoology+", "description": "Provides some enhancements to your LAUSD Schoology experience", - "version": "3.4", + "version": "3.5", "icons": { "128": "imgs/icon@128.png", "64": "imgs/icon@64.png",