',
+ ).firstChild;
textcontainer.append(textheader);
text = stringToHTML(
@@ -160,18 +169,24 @@ function OpenWhatsNewPopup() {
Independent Light Mode and Dark Mode
Dark mode and Light mode are now available to pick alongside your chosen Theme Colour. Your Theme Colour will now become an accent colour for the page.
Light/Dark mode can be toggled with the new button, found in the top-right of the menu bar.
-
+
Create Custom Shortcuts
Found in the Even BetterSEQTA Settings menu, custom shortcuts can now be created with a name and URL of your choice.
-
+
- `
+ `,
).firstChild;
footer = stringToHTML(`
Report bugs and feedback:
-
+
- `).firstChild
+ `).firstChild;
- exitbutton = document.createElement('div')
- exitbutton.innerText = 'x';
- exitbutton.id = 'whatsnewclosebutton';
+ exitbutton = document.createElement("div");
+ exitbutton.innerText = "x";
+ exitbutton.id = "whatsnewclosebutton";
container.append(header);
container.append(imagecont);
@@ -192,21 +207,21 @@ function OpenWhatsNewPopup() {
container.append(footer);
container.append(exitbutton);
- document.getElementById('container').append(background);
- document.getElementById('container').append(container);
+ document.getElementById("container").append(background);
+ document.getElementById("container").append(container);
chrome.storage.local.remove(["justupdated"]);
- var bkelement = document.getElementById('whatsnewbk');
- bkelement.addEventListener('click', function () {
+ var bkelement = document.getElementById("whatsnewbk");
+ bkelement.addEventListener("click", function () {
DeleteWhatsNew();
WhatsNewOpen = false;
- })
- var closeelement = document.getElementById('whatsnewclosebutton');
- closeelement.addEventListener('click', function (e) {
+ });
+ var closeelement = document.getElementById("whatsnewclosebutton");
+ closeelement.addEventListener("click", function (e) {
DeleteWhatsNew();
WhatsNewOpen = false;
- })
+ });
}
async function finishLoad() {
@@ -215,7 +230,7 @@ async function finishLoad() {
loadingbk.style.opacity = "0";
await delay(501);
loadingbk.remove();
- } catch(err) {
+ } catch (err) {
console.log(err);
}
@@ -224,16 +239,14 @@ async function finishLoad() {
WhatsNewOpen = true;
OpenWhatsNewPopup();
}
- })
-
-
+ });
}
async function DeleteWhatsNew() {
- var bkelement = document.getElementById('whatsnewbk');
+ var bkelement = document.getElementById("whatsnewbk");
var popup = document.getElementsByClassName("whatsnewContainer")[0];
- bkelement.classList.add('whatsnewfadeout');
- popup.classList.add('whatsnewzoomout');
+ bkelement.classList.add("whatsnewfadeout");
+ popup.classList.add("whatsnewzoomout");
await delay(500);
bkelement.remove();
popup.remove();
@@ -281,11 +294,12 @@ function waitForElm(selector) {
var LoadingDone = false;
async function RunColourCheck(element) {
- if (typeof element.contentDocument.documentElement.childNodes[1] == 'undefined') {
+ if (
+ typeof element.contentDocument.documentElement.childNodes[1] == "undefined"
+ ) {
await delay(1000);
RunColourCheck(element);
- }
- else {
+ } else {
element.contentDocument.documentElement.childNodes[1].style.color = "white";
}
}
@@ -307,43 +321,47 @@ function CheckiFrameItems() {
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
-
if (added_node.tagName == "IFRAME") {
-
chrome.storage.local.get(["DarkMode"], function (result) {
- DarkModeResult = result.DarkMode
+ DarkModeResult = result.DarkMode;
if (DarkModeResult) {
RunColourCheck(added_node);
- if (added_node.contentDocument.documentElement.childNodes[1].style.color != "white") {
- added_node.contentDocument.documentElement.childNodes[1].style.color = "white";
+ if (
+ added_node.contentDocument.documentElement.childNodes[1].style
+ .color != "white"
+ ) {
+ added_node.contentDocument.documentElement.childNodes[1].style.color =
+ "white";
}
if (
!added_node.contentDocument.documentElement.firstChild.innerHTML.includes(
- "iframe.css"
+ "iframe.css",
)
) {
added_node.contentDocument.documentElement.firstChild.appendChild(
- fileref
+ fileref,
);
}
added_node.addEventListener("load", function () {
- if (added_node.contentDocument.documentElement.childNodes[1].style.color != "white") {
- added_node.contentDocument.documentElement.childNodes[1].style.color = "white";
+ if (
+ added_node.contentDocument.documentElement.childNodes[1].style
+ .color != "white"
+ ) {
+ added_node.contentDocument.documentElement.childNodes[1].style.color =
+ "white";
}
if (
!added_node.contentDocument.documentElement.firstChild.innerHTML.includes(
- "iframe.css"
+ "iframe.css",
)
) {
added_node.contentDocument.documentElement.firstChild.appendChild(
- fileref
+ fileref,
);
}
});
}
-
});
-
}
});
});
@@ -356,11 +374,13 @@ function CheckiFrameItems() {
}
function SortMessagePageItems(messagesParentElement) {
- filterbutton = document.createElement('div');
+ filterbutton = document.createElement("div");
filterbutton.classList.add("messages-filterbutton");
filterbutton.innerText = "Filter";
- header = document.getElementsByClassName('MessageList__MessageList___3DxoC')[0].firstChild;
+ header = document.getElementsByClassName(
+ "MessageList__MessageList___3DxoC",
+ )[0].firstChild;
header.append(filterbutton);
const observer = new MutationObserver(function (mutations_list) {
@@ -377,7 +397,6 @@ function SortMessagePageItems(messagesParentElement) {
subtree: true,
childList: true,
});
-
}
function LoadPageElements() {
@@ -397,24 +416,25 @@ function LoadPageElements() {
xhr3.open(
"POST",
`${location.origin}/seqta/student/heartbeat?`,
- true
+ true,
);
xhr3.setRequestHeader(
"Content-Type",
- "application/json; charset=utf-8"
+ "application/json; charset=utf-8",
);
xhr3.onreadystatechange = function () {
if (xhr3.readyState === 4) {
var Notifications = JSON.parse(xhr3.response);
var alertdiv = document.getElementsByClassName(
- "notifications__bubble___1EkSQ"
+ "notifications__bubble___1EkSQ",
)[0];
- if (typeof alertdiv == 'undefined') {
- console.log("[Even BetterSEQTA] No notifications currently")
-
- }
- else {
- alertdiv.textContent = Notifications.payload.notifications.length;
+ if (typeof alertdiv == "undefined") {
+ console.log(
+ "[Even BetterSEQTA] No notifications currently",
+ );
+ } else {
+ alertdiv.textContent =
+ Notifications.payload.notifications.length;
}
}
};
@@ -422,14 +442,13 @@ function LoadPageElements() {
JSON.stringify({
timestamp: "1970-01-01 00:00:00.0",
hash: "#?page=/home",
- })
+ }),
);
}
});
finishLoad();
}
-
});
break;
@@ -451,24 +470,23 @@ function LoadPageElements() {
xhr3.open(
"POST",
`${location.origin}/seqta/student/heartbeat?`,
- true
+ true,
);
xhr3.setRequestHeader(
"Content-Type",
- "application/json; charset=utf-8"
+ "application/json; charset=utf-8",
);
xhr3.onreadystatechange = function () {
if (xhr3.readyState === 4) {
var Notifications = JSON.parse(xhr3.response);
var alertdiv = document.getElementsByClassName(
- "notifications__bubble___1EkSQ"
+ "notifications__bubble___1EkSQ",
)[0];
- if (typeof alertdiv == 'undefined') {
- console.log("[Even BetterSEQTA] No notifications currently")
-
- }
- else {
- alertdiv.textContent = Notifications.payload.notifications.length;
+ if (typeof alertdiv == "undefined") {
+ console.log("[Even BetterSEQTA] No notifications currently");
+ } else {
+ alertdiv.textContent =
+ Notifications.payload.notifications.length;
}
}
};
@@ -476,7 +494,7 @@ function LoadPageElements() {
JSON.stringify({
timestamp: "1970-01-01 00:00:00.0",
hash: "#?page=/home",
- })
+ }),
);
}
});
@@ -486,41 +504,38 @@ function LoadPageElements() {
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
- if (added_node.classList.contains('messages')) {
- element = document.getElementById('title').firstChild;
+ if (added_node.classList.contains("messages")) {
+ element = document.getElementById("title").firstChild;
element.innerText = "Direct Messages";
document.title = "Direct Messages ― SEQTA Learn";
SortMessagePageItems(added_node);
- }
- else if (added_node.classList.contains('notices')) {
+ } else if (added_node.classList.contains("notices")) {
CheckNoticeTextColour(added_node);
}
});
});
});
- observer.observe(document.querySelector('#main'), {
+ observer.observe(document.querySelector("#main"), {
subtree: false,
childList: true,
});
-
-
}
function CheckNoticeTextColour(notice) {
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
- chrome.storage.local.get(['DarkMode'], function (result) {
+ chrome.storage.local.get(["DarkMode"], function (result) {
Darkmode = result.DarkMode;
- if (added_node.classList.contains('notice')) {
- var hex = added_node.style.cssText.split(' ')[1];
+ if (added_node.classList.contains("notice")) {
+ var hex = added_node.style.cssText.split(" ")[1];
var threshold = GetThresholdofHex(hex);
if (Darkmode && threshold < 100) {
added_node.style.cssText = "--color: undefined;";
}
}
- })
+ });
});
});
});
@@ -529,7 +544,6 @@ function CheckNoticeTextColour(notice) {
subtree: true,
childList: true,
});
-
}
function tryLoad() {
@@ -544,51 +558,47 @@ function tryLoad() {
});
waitForElm("[data-key=welcome]").then((elm) => {
- elm.classList.remove('active')
+ elm.classList.remove("active");
});
waitForElm(".code").then((elm) => {
- if (!elm.innerText.includes("BetterSEQTA"))
- LoadPageElements();
+ if (!elm.innerText.includes("BetterSEQTA")) LoadPageElements();
});
-
-
// Waits for page to call on load, run scripts
document.addEventListener(
"load",
function () {
CheckiFrameItems();
},
- true
+ true,
);
}
function ChangeMenuItemPositions(storage) {
menuorder = storage;
- var menuList = document.querySelector('#menu').firstChild.childNodes;
+ var menuList = document.querySelector("#menu").firstChild.childNodes;
- listorder = []
+ listorder = [];
for (let i = 0; i < menuList.length; i++) {
- namevalue = menuList[i].dataset.key
+ namevalue = menuList[i].dataset.key;
- a = menuorder.indexOf(menuList[i].dataset.key)
+ a = menuorder.indexOf(menuList[i].dataset.key);
- listorder.push(a)
+ listorder.push(a);
}
- var newArr = []
+ var newArr = [];
for (var i = 0; i < listorder.length; i++) {
- newArr[listorder[i]] = menuList[i]
+ newArr[listorder[i]] = menuList[i];
}
-
- listItemsDOM = document.getElementById('menu').firstChild
+ listItemsDOM = document.getElementById("menu").firstChild;
for (let i = 0; i < newArr.length; i++) {
const element = newArr[i];
if (element) {
- element.setAttribute('data-checked', 'true')
+ element.setAttribute("data-checked", "true");
listItemsDOM.appendChild(element);
}
}
@@ -596,16 +606,17 @@ function ChangeMenuItemPositions(storage) {
async function ObserveMenuItemPosition() {
chrome.storage.local.get(null, function (result) {
-
- menuorder = result.menuorder
+ menuorder = result.menuorder;
if (menuorder && result.onoff) {
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
-
if (!added_node?.dataset?.checked && !MenuOptionsOpen) {
if (MenuitemSVGKey[added_node?.dataset?.key]) {
- ReplaceMenuSVG(added_node, MenuitemSVGKey[added_node.dataset.key])
+ ReplaceMenuSVG(
+ added_node,
+ MenuitemSVGKey[added_node.dataset.key],
+ );
}
ChangeMenuItemPositions(menuorder);
}
@@ -613,21 +624,18 @@ async function ObserveMenuItemPosition() {
});
});
- observer.observe(document.querySelector('#menu').firstChild, {
+ observer.observe(document.querySelector("#menu").firstChild, {
subtree: true,
childList: true,
});
}
-
-
- })
-
+ });
}
function AppendElementsToDisabledPage() {
AddBetterSEQTAElements(false);
- settingsStyle = document.createElement('style')
+ settingsStyle = document.createElement("style");
settingsStyle.innerText = `
.addedButton {
position: absolute !important;
@@ -647,16 +655,23 @@ function AppendElementsToDisabledPage() {
.outside-container {
top: 48px !important;
}
- `
- document.head.append(settingsStyle)
+ `;
+ document.head.append(settingsStyle);
}
-function lightenAndPaleColor(hexColor, lightenFactor = 0.75, paleFactor = 0.55) {
+function lightenAndPaleColor(
+ hexColor,
+ lightenFactor = 0.75,
+ paleFactor = 0.55,
+) {
// Convert a RGB value to HSL
function rgbToHsl(r, g, b) {
- r /= 255, g /= 255, b /= 255;
- let max = Math.max(r, g, b), min = Math.min(r, g, b);
- let h, s, l = (max + min) / 2;
+ (r /= 255), (g /= 255), (b /= 255);
+ let max = Math.max(r, g, b),
+ min = Math.min(r, g, b);
+ let h,
+ s,
+ l = (max + min) / 2;
if (max === min) {
h = s = 0;
@@ -664,9 +679,15 @@ function lightenAndPaleColor(hexColor, lightenFactor = 0.75, paleFactor = 0.55)
let d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
+ case r:
+ h = (g - b) / d + (g < b ? 6 : 0);
+ break;
+ case g:
+ h = (b - r) / d + 2;
+ break;
+ case b:
+ h = (r - g) / d + 4;
+ break;
}
h /= 6;
}
@@ -679,9 +700,9 @@ function lightenAndPaleColor(hexColor, lightenFactor = 0.75, paleFactor = 0.55)
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
- if (t < 1/6) return p + (q - p) * 6 * t;
- if (t < 1/2) return q;
- if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
+ if (t < 1 / 2) return q;
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
}
@@ -691,9 +712,9 @@ function lightenAndPaleColor(hexColor, lightenFactor = 0.75, paleFactor = 0.55)
} else {
let q = l < 0.5 ? l * (1 + s) : l + s - l * s;
let p = 2 * l - q;
- r = hue2rgb(p, q, h + 1/3);
+ r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
- b = hue2rgb(p, q, h - 1/3);
+ b = hue2rgb(p, q, h - 1 / 3);
}
return [r * 255, g * 255, b * 255];
@@ -715,27 +736,28 @@ function lightenAndPaleColor(hexColor, lightenFactor = 0.75, paleFactor = 0.55)
[r, g, b] = hslToRgb(h, s, l);
// Convert RGB to hex
- r = Math.round(r).toString(16).padStart(2, '0');
- g = Math.round(g).toString(16).padStart(2, '0');
- b = Math.round(b).toString(16).padStart(2, '0');
+ r = Math.round(r).toString(16).padStart(2, "0");
+ g = Math.round(g).toString(16).padStart(2, "0");
+ b = Math.round(b).toString(16).padStart(2, "0");
- return '#' + r + g + b;
+ return "#" + r + g + b;
}
function ColorLuminance(hex, lum) {
-
// validate hex string
- hex = String(hex).replace(/[^0-9a-f]/gi, '');
+ hex = String(hex).replace(/[^0-9a-f]/gi, "");
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;
// convert to decimal and change luminosity
- var rgb = "#", c, i;
+ var rgb = "#",
+ c,
+ i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
- c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
+ c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
rgb += ("00" + c).substring(c.length);
}
@@ -745,45 +767,63 @@ function ColorLuminance(hex, lum) {
chrome.storage.onChanged.addListener(function (changes) {
if (changes.selectedColor) {
try {
- document.documentElement.style.setProperty('--better-pale', lightenAndPaleColor(changes.selectedColor.newValue));
- } catch(err) {
- console.log(err)
+ document.documentElement.style.setProperty(
+ "--better-pale",
+ lightenAndPaleColor(changes.selectedColor.newValue),
+ );
+ } catch (err) {
+ console.log(err);
}
- rbg = GetThresholdofHex(changes.selectedColor.newValue)
+ rbg = GetThresholdofHex(changes.selectedColor.newValue);
if (rbg > 210) {
- document.documentElement.style.setProperty('--text-color', 'black');
- document.documentElement.style.setProperty('--betterseqta-logo', `url(${chrome.runtime.getURL('icons/betterseqta-dark-full.png')})`);
- }
- else {
- document.documentElement.style.setProperty('--text-color', 'white');
- document.documentElement.style.setProperty('--betterseqta-logo', `url(${chrome.runtime.getURL('icons/betterseqta-light-full.png')})`);
+ document.documentElement.style.setProperty("--text-color", "black");
+ document.documentElement.style.setProperty(
+ "--betterseqta-logo",
+ `url(${chrome.runtime.getURL("icons/betterseqta-dark-full.png")})`,
+ );
+ } else {
+ document.documentElement.style.setProperty("--text-color", "white");
+ document.documentElement.style.setProperty(
+ "--betterseqta-logo",
+ `url(${chrome.runtime.getURL("icons/betterseqta-light-full.png")})`,
+ );
}
- document.documentElement.style.setProperty('--better-main', changes.selectedColor.newValue);
+ document.documentElement.style.setProperty(
+ "--better-main",
+ changes.selectedColor.newValue,
+ );
// document.documentElement.style.setProperty('--better-sub', ColorLuminance(changes.selectedColor.newValue, -0.15));
-
- if (changes.selectedColor.newValue == '#ffffff') {
- document.documentElement.style.setProperty('--better-light', '#b7b7b7');
+
+ if (changes.selectedColor.newValue == "#ffffff") {
+ document.documentElement.style.setProperty("--better-light", "#b7b7b7");
} else {
- document.documentElement.style.setProperty('--better-light', ColorLuminance(changes.selectedColor.newValue, 0.99));
+ document.documentElement.style.setProperty(
+ "--better-light",
+ ColorLuminance(changes.selectedColor.newValue, 0.99),
+ );
}
}
if (changes?.customshortcuts?.newValue) {
if (changes.customshortcuts.oldValue.length > 0) {
- CreateCustomShortcutDiv(changes.customshortcuts.newValue[(changes.customshortcuts.oldValue.length)]);
+ CreateCustomShortcutDiv(
+ changes.customshortcuts.newValue[
+ changes.customshortcuts.oldValue.length
+ ],
+ );
} else {
CreateCustomShortcutDiv(changes.customshortcuts.newValue[0]);
}
}
-})
+});
var PageLoaded = false;
async function CheckLoadOnPeriods() {
if (!PageLoaded) {
await delay(1000);
- var code = document.getElementsByClassName('code')[0];
+ var code = document.getElementsByClassName("code")[0];
if (code && !UserInitalCode) {
LoadPageElements();
finishLoad();
@@ -797,11 +837,10 @@ async function CheckLoadOnPeriods() {
function RunFunctionOnTrue(storedSetting) {
// If the option is 'on', open BetterSEQTA
- if (typeof storedSetting.onoff == 'undefined') {
+ if (typeof storedSetting.onoff == "undefined") {
chrome.runtime.sendMessage({ type: "setDefaultStorage" });
}
if (storedSetting.onoff) {
-
console.log("[Even BetterSEQTA] Enabled");
// Injecting CSS File to the webpage to overwrite SEQTA's default CSS
var cssFile = chrome.runtime.getURL("inject/injected.css");
@@ -812,49 +851,75 @@ function RunFunctionOnTrue(storedSetting) {
document.head.appendChild(fileref);
document.getElementsByTagName("html")[0].appendChild(fileref);
- document.documentElement.style.setProperty('--better-sub', "#161616");
- document.documentElement.style.setProperty('--better-alert-highlight', "#c61851");
+ document.documentElement.style.setProperty("--better-sub", "#161616");
+ document.documentElement.style.setProperty(
+ "--better-alert-highlight",
+ "#c61851",
+ );
-
-
if (storedSetting.DarkMode) {
- document.documentElement.style.setProperty('--background-primary', "#232323");
- document.documentElement.style.setProperty('--background-secondary', "#1a1a1a");
- document.documentElement.style.setProperty('--text-primary', "white");
- }
- else {
+ document.documentElement.style.setProperty(
+ "--background-primary",
+ "#232323",
+ );
+ document.documentElement.style.setProperty(
+ "--background-secondary",
+ "#1a1a1a",
+ );
+ document.documentElement.style.setProperty("--text-primary", "white");
+ } else {
try {
- document.documentElement.style.setProperty('--better-pale', lightenAndPaleColor(storedSetting.selectedColor));
- } catch(err) {
- console.log(err)
+ document.documentElement.style.setProperty(
+ "--better-pale",
+ lightenAndPaleColor(storedSetting.selectedColor),
+ );
+ } catch (err) {
+ console.log(err);
}
- document.documentElement.style.setProperty('--background-primary', "#ffffff");
- document.documentElement.style.setProperty('--background-secondary', "#e5e7eb");
- document.documentElement.style.setProperty('--text-primary', "black");
+ document.documentElement.style.setProperty(
+ "--background-primary",
+ "#ffffff",
+ );
+ document.documentElement.style.setProperty(
+ "--background-secondary",
+ "#e5e7eb",
+ );
+ document.documentElement.style.setProperty("--text-primary", "black");
}
- document.querySelector('link[rel*="icon"]').href = chrome.runtime.getURL("icons/icon-48.png");
+ document.querySelector('link[rel*="icon"]').href =
+ chrome.runtime.getURL("icons/icon-48.png");
rbg = GetThresholdofHex(storedSetting.selectedColor);
if (rbg > 210) {
- document.documentElement.style.setProperty('--text-color', 'black');
- document.documentElement.style.setProperty('--betterseqta-logo', `url(${chrome.runtime.getURL('icons/betterseqta-dark-full.png')})`);
- }
- else {
- document.documentElement.style.setProperty('--text-color', 'white');
- document.documentElement.style.setProperty('--betterseqta-logo', `url(${chrome.runtime.getURL('icons/betterseqta-light-full.png')})`);
+ document.documentElement.style.setProperty("--text-color", "black");
+ document.documentElement.style.setProperty(
+ "--betterseqta-logo",
+ `url(${chrome.runtime.getURL("icons/betterseqta-dark-full.png")})`,
+ );
+ } else {
+ document.documentElement.style.setProperty("--text-color", "white");
+ document.documentElement.style.setProperty(
+ "--betterseqta-logo",
+ `url(${chrome.runtime.getURL("icons/betterseqta-light-full.png")})`,
+ );
}
- document.documentElement.style.setProperty('--better-main', storedSetting.selectedColor);
+ document.documentElement.style.setProperty(
+ "--better-main",
+ storedSetting.selectedColor,
+ );
// document.documentElement.style.setProperty('--better-sub', ColorLuminance(storedSetting.selectedColor, -0.15));
- if (storedSetting.selectedColor == '#ffffff') {
- document.documentElement.style.setProperty('--better-light', '#b7b7b7');
+ if (storedSetting.selectedColor == "#ffffff") {
+ document.documentElement.style.setProperty("--better-light", "#b7b7b7");
} else {
- document.documentElement.style.setProperty('--better-light', ColorLuminance(storedSetting.selectedColor, 0.95));
+ document.documentElement.style.setProperty(
+ "--better-light",
+ ColorLuminance(storedSetting.selectedColor, 0.95),
+ );
}
-
ApplyCSSToHiddenMenuItems();
loading();
@@ -868,8 +933,7 @@ function RunFunctionOnTrue(storedSetting) {
window.addEventListener("load", function () {
tryLoad();
});
- }
- else {
+ } else {
if (!isChrome || isChrome == "undefined") {
waitForElm(".code").then((elm) => {
AppendElementsToDisabledPage();
@@ -879,23 +943,20 @@ function RunFunctionOnTrue(storedSetting) {
waitForElm(".code").then((elm) => {
AppendElementsToDisabledPage();
});
-
});
- };
+ }
}
async function CheckForMenuList() {
if (!MenuItemMutation) {
try {
- if (document.getElementById('menu').firstChild) {
+ if (document.getElementById("menu").firstChild) {
ObserveMenuItemPosition();
MenuItemMutation = true;
}
- }
- catch (error) {
+ } catch (error) {
return;
}
-
}
}
@@ -906,8 +967,14 @@ document.addEventListener(
"load",
function () {
CheckForMenuList();
- var weblink = window.location.origin
- if (document.childNodes[1].textContent?.includes("Copyright (c) SEQTA Software") && document.title.includes("SEQTA Learn") && !IsSEQTAPage) {
+ var weblink = window.location.origin;
+ if (
+ document.childNodes[1].textContent?.includes(
+ "Copyright (c) SEQTA Software",
+ ) &&
+ document.title.includes("SEQTA Learn") &&
+ !IsSEQTAPage
+ ) {
IsSEQTAPage = true;
console.log("[BetterSEQTA] Verified SEQTA Page");
@@ -928,12 +995,12 @@ document.addEventListener(
NonSEQTAPage = true;
}
},
- true
+ true,
);
function RunExtensionSettingsJS() {
- const whatsnewsettings = document.getElementById('whatsnewsettings');
- whatsnewsettings.addEventListener('click', function () {
+ const whatsnewsettings = document.getElementById("whatsnewsettings");
+ whatsnewsettings.addEventListener("click", function () {
if (!WhatsNewOpen) {
WhatsNewOpen = true;
OpenWhatsNewPopup();
@@ -945,31 +1012,37 @@ function RunExtensionSettingsJS() {
const lessonalert = document.querySelector("#lessonalert");
const aboutsection = document.querySelector("#aboutsection");
const shortcutsection = document.querySelector("#shortcutsection");
- const miscsection = document.querySelector('#miscsection');
+ const miscsection = document.querySelector("#miscsection");
const mainpage = document.querySelector("#mainpage");
const colorpicker = document.querySelector("#colorpicker");
- const animatedbk = document.querySelector('#animatedbk');
- const customshortcutbutton = document.getElementsByClassName('custom-shortcuts-button')[0];
- const customshortcutdiv = document.getElementsByClassName('custom-shortcuts-container')[0];
- const customshortcutsubmit = document.getElementsByClassName('custom-shortcuts-submit')[0];
- const customshortcutinputname = document.querySelector('#shortcutname');
- const customshortcutinputurl = document.querySelector('#shortcuturl');
+ const animatedbk = document.querySelector("#animatedbk");
+ const customshortcutbutton = document.getElementsByClassName(
+ "custom-shortcuts-button",
+ )[0];
+ const customshortcutdiv = document.getElementsByClassName(
+ "custom-shortcuts-container",
+ )[0];
+ const customshortcutsubmit = document.getElementsByClassName(
+ "custom-shortcuts-submit",
+ )[0];
+ const customshortcutinputname = document.querySelector("#shortcutname");
+ const customshortcutinputurl = document.querySelector("#shortcuturl");
- const shortcutmenuitemselection = document.getElementsByClassName('menushortcut')[0];
+ const shortcutmenuitemselection =
+ document.getElementsByClassName("menushortcut")[0];
-
- const applybutton = document.querySelector('#applychanges')
+ const applybutton = document.querySelector("#applychanges");
const navbuttons = document.getElementsByClassName("navitem");
- const menupages = document.getElementsByClassName("menu-page")
+ const menupages = document.getElementsByClassName("menu-page");
- const allinputs = document.getElementsByTagName('input');
+ const allinputs = document.getElementsByTagName("input");
const menupage = document.querySelector("#menupage");
const shortcutpage = document.querySelector("#shortcutpage");
- const miscpage = document.querySelector('#miscpage');
+ const miscpage = document.querySelector("#miscpage");
var shortcutbuttons = document.getElementsByClassName("shortcutitem");
@@ -984,16 +1057,15 @@ function RunExtensionSettingsJS() {
function resetActive() {
for (let i = 0; i < navbuttons.length; i++) {
- navbuttons[i].classList.remove('activenav');
+ navbuttons[i].classList.remove("activenav");
}
for (let i = 0; i < menupages.length; i++) {
- menupages[i].classList.add('hiddenmenu');
+ menupages[i].classList.add("hiddenmenu");
}
-
}
function FindSEQTATab() {
- chrome.runtime.sendMessage({ type: "reloadTabs", });
+ chrome.runtime.sendMessage({ type: "reloadTabs" });
}
/*
Store the currently selected settings using chrome.storage.local.
@@ -1005,13 +1077,13 @@ function RunExtensionSettingsJS() {
}
function storeNotificationSettings() {
- chrome.storage.local.set(
- { notificationcollector: notificationcollector.checked });
+ chrome.storage.local.set({
+ notificationcollector: notificationcollector.checked,
+ });
chrome.storage.local.set({ lessonalert: lessonalert.checked });
chrome.storage.local.set({ animatedbk: animatedbk.checked });
}
-
function StoreAllSettings() {
chrome.storage.local.get(["shortcuts"], function (result) {
var shortcuts = Object.values(result)[0];
@@ -1028,7 +1100,7 @@ function RunExtensionSettingsJS() {
or the default settings if the stored settings are empty.
*/
function updateUI(restoredSettings) {
- if (typeof restoredSettings.onoff == 'undefined') {
+ if (typeof restoredSettings.onoff == "undefined") {
chrome.runtime.sendMessage({ type: "setDefaultStorage" });
chrome.storage.local.get(null, function (result) {
@@ -1049,9 +1121,7 @@ function RunExtensionSettingsJS() {
}
}
-
function CreateShortcutDiv(name) {
-
div = stringtoHTML(`
@@ -1065,7 +1135,7 @@ function RunExtensionSettingsJS() {
shortcutmenuitemselection.append(div);
const deletebutton = document.getElementById(`delete-${name}`);
- deletebutton.addEventListener('click', function () {
+ deletebutton.addEventListener("click", function () {
DeleteCustomShortcut(name);
applybutton.style.left = "4px";
});
@@ -1076,9 +1146,7 @@ function RunExtensionSettingsJS() {
var customshortcuts = Object.values(result)[0];
for (let i = 0; i < customshortcuts.length; i++) {
const element = customshortcuts[i];
- CreateShortcutDiv(
- element.name,
- )
+ CreateShortcutDiv(element.name);
}
});
}
@@ -1095,61 +1163,84 @@ function RunExtensionSettingsJS() {
}
chrome.storage.local.set({ customshortcuts: customshortcuts });
});
-
}
function CustomShortcutMenu() {
- customshortcutinputname.value = '';
- customshortcutinputurl.value = '';
+ customshortcutinputname.value = "";
+ customshortcutinputurl.value = "";
validURL = false;
validName = false;
customshortcutsubmit.classList.remove("customshortcut-submit-valid");
- if (customshortcutdiv.classList.contains('custom-shortcuts-container-shown')) {
- customshortcutdiv.classList.remove('custom-shortcuts-container-shown')
+ if (
+ customshortcutdiv.classList.contains("custom-shortcuts-container-shown")
+ ) {
+ customshortcutdiv.classList.remove("custom-shortcuts-container-shown");
} else {
- customshortcutdiv.classList.add('custom-shortcuts-container-shown')
- };
+ customshortcutdiv.classList.add("custom-shortcuts-container-shown");
+ }
}
function CreateCustomShortcut() {
const shortcutname = customshortcutinputname.value;
var shortcuturl = customshortcutinputurl.value;
- if (!(shortcuturl.includes('http'))) {
+ if (!shortcuturl.includes("http")) {
shortcuturl = "https://" + shortcuturl;
}
chrome.storage.local.get(["customshortcuts"], function (result) {
var customshortcuts = Object.values(result)[0];
- customshortcuts.push({ name: shortcutname, url: shortcuturl, icon: (shortcutname[0]).toUpperCase() });
+ customshortcuts.push({
+ name: shortcutname,
+ url: shortcuturl,
+ icon: shortcutname[0].toUpperCase(),
+ });
chrome.storage.local.set({ customshortcuts: customshortcuts });
});
- CreateShortcutDiv(
- shortcutname
- );
- document.getElementsByClassName("shortcut-container")[0].style.display = "block";
+ CreateShortcutDiv(shortcutname);
+ document.getElementsByClassName("shortcut-container")[0].style.display =
+ "block";
}
-
function onError(e) {
console.error(e);
}
chrome.storage.local.get(null, function (result) {
- document.getElementsByClassName('clr-field')[0].style.color = result.selectedColor;
+ document.getElementsByClassName("clr-field")[0].style.color =
+ result.selectedColor;
colorpicker.value = result.selectedColor;
updateUI(result);
});
github.addEventListener("click", openGithub);
- aboutsection.addEventListener("click", () => { resetActive(); aboutsection.classList.add('activenav'); menupage.classList.remove('hiddenmenu') });
+ aboutsection.addEventListener("click", () => {
+ resetActive();
+ aboutsection.classList.add("activenav");
+ menupage.classList.remove("hiddenmenu");
+ });
- shortcutsection.addEventListener("click", () => { resetActive(); shortcutsection.classList.add('activenav'); shortcutpage.classList.remove('hiddenmenu') });
+ shortcutsection.addEventListener("click", () => {
+ resetActive();
+ shortcutsection.classList.add("activenav");
+ shortcutpage.classList.remove("hiddenmenu");
+ });
- miscsection.addEventListener("click", () => { resetActive(); miscsection.classList.add('activenav'); miscpage.classList.remove('hiddenmenu') });
+ miscsection.addEventListener("click", () => {
+ resetActive();
+ miscsection.classList.add("activenav");
+ miscpage.classList.remove("hiddenmenu");
+ });
- customshortcutbutton.addEventListener("click", () => { CustomShortcutMenu(); })
- customshortcutsubmit.addEventListener("click", () => { if (validName && validURL) { CreateCustomShortcut(); CustomShortcutMenu() } });
+ customshortcutbutton.addEventListener("click", () => {
+ CustomShortcutMenu();
+ });
+ customshortcutsubmit.addEventListener("click", () => {
+ if (validName && validURL) {
+ CreateCustomShortcut();
+ CustomShortcutMenu();
+ }
+ });
var sameName = false;
customshortcutinputname.addEventListener("input", function () {
@@ -1162,7 +1253,11 @@ function RunExtensionSettingsJS() {
}
}
- if (customshortcutinputname.value.length > 0 && customshortcutinputname.value.length < 22 && !sameName) {
+ if (
+ customshortcutinputname.value.length > 0 &&
+ customshortcutinputname.value.length < 22 &&
+ !sameName
+ ) {
validName = true;
} else {
validName = false;
@@ -1170,15 +1265,17 @@ function RunExtensionSettingsJS() {
if (validName && validURL) {
customshortcutsubmit.classList.add("customshortcut-submit-valid");
- }
- else {
+ } else {
customshortcutsubmit.classList.remove("customshortcut-submit-valid");
}
});
});
customshortcutinputurl.addEventListener("input", function () {
- if (customshortcutinputurl.value.length > 0 && customshortcutinputurl.value.includes('.')) {
+ if (
+ customshortcutinputurl.value.length > 0 &&
+ customshortcutinputurl.value.includes(".")
+ ) {
validURL = true;
} else {
validURL = false;
@@ -1186,50 +1283,51 @@ function RunExtensionSettingsJS() {
if (validName && validURL) {
customshortcutsubmit.classList.add("customshortcut-submit-valid");
- }
- else {
+ } else {
customshortcutsubmit.classList.remove("customshortcut-submit-valid");
}
- })
+ });
AddCustomShortcuts();
onoffselection.addEventListener("change", storeSettings);
- notificationcollector.addEventListener(
- "change",
- storeNotificationSettings
- );
- lessonalert.addEventListener("change", storeNotificationSettings)
+ notificationcollector.addEventListener("change", storeNotificationSettings);
+ lessonalert.addEventListener("change", storeNotificationSettings);
-
- animatedbk.addEventListener("change", storeNotificationSettings)
+ animatedbk.addEventListener("change", storeNotificationSettings);
for (let i = 0; i < allinputs.length; i++) {
- if (allinputs[i].id != 'colorpicker' && allinputs[i].id != "shortcuturl" && allinputs[i].id != "shortcutname") {
- allinputs[i].addEventListener("change", () => { applybutton.style.left = "4px" })
+ if (
+ allinputs[i].id != "colorpicker" &&
+ allinputs[i].id != "shortcuturl" &&
+ allinputs[i].id != "shortcutname"
+ ) {
+ allinputs[i].addEventListener("change", () => {
+ applybutton.style.left = "4px";
+ });
}
}
- applybutton.addEventListener('click', () => { StoreAllSettings(); applybutton.style.left = "-150px" })
-
+ applybutton.addEventListener("click", () => {
+ StoreAllSettings();
+ applybutton.style.left = "-150px";
+ });
colorpicker.addEventListener("input", function () {
- var colorPreview = document.querySelector('#clr-color-preview')
+ var colorPreview = document.querySelector("#clr-color-preview");
if (colorPreview.style.color) {
var hex = colorPreview.style.color.split("(")[1].split(")")[0];
hex = hex.split(",");
- var b = hex.map(function (x) { //For each array element
- x = parseInt(x).toString(16); //Convert to a base16 string
- return (x.length == 1) ? "0" + x : x; //Add zero if we get only one character
- })
+ var b = hex.map(function (x) {
+ //For each array element
+ x = parseInt(x).toString(16); //Convert to a base16 string
+ return x.length == 1 ? "0" + x : x; //Add zero if we get only one character
+ });
b = "#" + b.join("");
- chrome.storage.local.set({ selectedColor: b })
+ chrome.storage.local.set({ selectedColor: b });
}
-
-
- })
-
+ });
}
function CallExtensionSettings() {
@@ -1253,8 +1351,11 @@ function CallExtensionSettings() {
fileref.setAttribute("href", cssFile);
document.head.append(fileref);
- NextPageImage = chrome.runtime.getURL('popup/page.png')
- Settings = stringToHTML(`
`;
if (lesson.programmeID != 0) {
- lessonstring += `
${assessmentsicon}
${coursesicon}
`
+ lessonstring += `
${assessmentsicon}
${coursesicon}
`;
}
if (lesson.assessments.length > 0) {
for (let i = 0; i < lesson.assessments.length; i++) {
- const element = lesson.assessments[i]
- assessmentstring += `
${element.title}
`
+ const element = lesson.assessments[i];
+ assessmentstring += `
${element.title}
`;
}
lessonstring += `
${assessmentstring}
`
+
${assessmentstring}
`;
}
- lessonstring += '
';
+ lessonstring += "
";
var lessondiv = stringToHTML(lessonstring);
return lessondiv;
}
@@ -2217,8 +2353,7 @@ function MakeLessonDiv(lesson, num) {
function CheckUnmarkedAttendance(lessonattendance) {
if (lessonattendance) {
var lesson = lessonattendance.label;
- }
- else {
+ } else {
var lesson = " ";
}
return lesson;
@@ -2227,11 +2362,7 @@ function CheckUnmarkedAttendance(lessonattendance) {
function callHomeTimetable(date, change) {
// Creates a HTTP Post Request to the SEQTA page for the students timetable
var xhr = new XMLHttpRequest();
- xhr.open(
- "POST",
- `${location.origin}/seqta/student/load/timetable?`,
- true
- );
+ xhr.open("POST", `${location.origin}/seqta/student/load/timetable?`, true);
// Sets the response type to json
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
@@ -2240,7 +2371,7 @@ function callHomeTimetable(date, change) {
if (xhr.readyState === 4) {
var serverResponse = JSON.parse(xhr.response);
lessonArray = [];
- var DayContainer = document.getElementById("day-container")
+ var DayContainer = document.getElementById("day-container");
// If items in response:
if (serverResponse.payload.items.length > 0) {
if (!DayContainer.innerText || change) {
@@ -2256,15 +2387,15 @@ function callHomeTimetable(date, change) {
GetLessonColours().then((colours) => {
subjects = colours;
for (let i = 0; i < lessonArray.length; i++) {
+ subjectname = `timetable.subject.colour.${lessonArray[i].code}`;
- subjectname = `timetable.subject.colour.${lessonArray[i].code}`
-
- subject = subjects.find(element => element.name === subjectname)
+ subject = subjects.find(
+ (element) => element.name === subjectname,
+ );
if (!subject) {
- lessonArray[i].colour = `--item-colour: #8e8e8e;`
- }
- else {
- lessonArray[i].colour = `--item-colour: ${subject.value};`
+ lessonArray[i].colour = `--item-colour: #8e8e8e;`;
+ } else {
+ lessonArray[i].colour = `--item-colour: ${subject.value};`;
result = GetThresholdofHex(subject.value);
if (result > 300) {
@@ -2277,15 +2408,16 @@ function callHomeTimetable(date, change) {
// Checks if attendance is unmarked, and sets the string to " ".
lessonArray[i].attendanceTitle = CheckUnmarkedAttendance(
- lessonArray[i].attendance)
+ lessonArray[i].attendance,
+ );
}
// If on home page, apply each lesson to HTML with information in each div
- DayContainer.innerText = '';
+ DayContainer.innerText = "";
for (let i = 0; i < lessonArray.length; i++) {
var div = MakeLessonDiv(lessonArray[i], i + 1);
// Append each of the lessons into the day-container
if (lessonArray[i].invert) {
- div.firstChild.classList.add('day-inverted');
+ div.firstChild.classList.add("day-inverted");
}
DayContainer.append(div.firstChild);
@@ -2299,20 +2431,17 @@ function callHomeTimetable(date, change) {
// For each lesson, check the start and end times
CheckCurrentLessonAll(lessonArray);
}
- })
-
-
+ });
}
- }
- else {
+ } else {
if (!DayContainer.innerText || change) {
- DayContainer.innerText = '';
+ DayContainer.innerText = "";
var dummyDay = document.createElement("div");
dummyDay.classList.add("day-empty");
- img = document.createElement('img')
- img.src = chrome.runtime.getURL('icons/betterseqta-light-icon.png')
- text = document.createElement('p')
- text.innerText = "No lessons available."
+ img = document.createElement("img");
+ img.src = chrome.runtime.getURL("icons/betterseqta-light-icon.png");
+ text = document.createElement("p");
+ text.innerText = "No lessons available.";
dummyDay.append(img);
dummyDay.append(text);
DayContainer.append(dummyDay);
@@ -2327,23 +2456,22 @@ function callHomeTimetable(date, change) {
until: date,
// Funny number
student: 69,
- })
+ }),
);
}
function GetUpcomingAssessments() {
-
func = fetch(`${location.origin}/seqta/student/assessment/list/upcoming?`, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
- body: JSON.stringify({ "student": 69 })
- })
+ body: JSON.stringify({ student: 69 }),
+ });
return func
.then((result) => result.json())
- .then(response => (response.payload))
+ .then((response) => response.payload);
}
function GetActiveClasses() {
@@ -2352,12 +2480,12 @@ function GetActiveClasses() {
headers: {
"Content-Type": "application/json; charset=utf-8",
},
- body: JSON.stringify({})
- })
+ body: JSON.stringify({}),
+ });
return func
.then((result) => result.json())
- .then(response => (response.payload))
+ .then((response) => response.payload);
}
function comparedate(obj1, obj2) {
@@ -2387,63 +2515,64 @@ function CreateElement(type, class_, id, innerText, innerHTML, style) {
if (style !== undefined) {
element.style = style;
}
- return element
+ return element;
}
function createAssessmentDateDiv(date, value, datecase = undefined) {
- var options = { weekday: 'long', month: 'long', day: 'numeric' };
- const FormattedDate = new Date(date)
+ var options = { weekday: "long", month: "long", day: "numeric" };
+ const FormattedDate = new Date(date);
const assessments = value.assessments;
const container = value.div;
- DateTitleDiv = document.createElement('div');
- DateTitleDiv.classList.add('upcoming-date-title');
+ DateTitleDiv = document.createElement("div");
+ DateTitleDiv.classList.add("upcoming-date-title");
if (datecase) {
- datetitle = document.createElement('h5');
- datetitle.classList.add('upcoming-special-day')
+ datetitle = document.createElement("h5");
+ datetitle.classList.add("upcoming-special-day");
datetitle.innerText = datecase;
DateTitleDiv.append(datetitle);
- container.setAttribute('data-day', datecase);
+ container.setAttribute("data-day", datecase);
}
- DateTitle = document.createElement('h5')
+ DateTitle = document.createElement("h5");
DateTitle.innerText = FormattedDate.toLocaleDateString("en-AU", options);
DateTitleDiv.append(DateTitle);
-
-
container.append(DateTitleDiv);
- assessmentContainer = document.createElement('div')
- assessmentContainer.classList.add('upcoming-date-assessments');
+ assessmentContainer = document.createElement("div");
+ assessmentContainer.classList.add("upcoming-date-assessments");
for (let i = 0; i < assessments.length; i++) {
const element = assessments[i];
- item = document.createElement('div')
- item.classList.add('upcoming-assessment');
- item.setAttribute('data-subject', element.code);
+ item = document.createElement("div");
+ item.classList.add("upcoming-assessment");
+ item.setAttribute("data-subject", element.code);
item.id = `assessment${element.id}`;
item.style = element.colour;
- titlediv = document.createElement('div');
- titlediv.classList.add('upcoming-subject-title');
+ titlediv = document.createElement("div");
+ titlediv.classList.add("upcoming-subject-title");
- titlesvg = stringToHTML(``).firstChild;
titlediv.append(titlesvg);
- detailsdiv = document.createElement('div');
- detailsdiv.classList.add('upcoming-details');
- detailstitle = document.createElement('h5');
+ detailsdiv = document.createElement("div");
+ detailsdiv.classList.add("upcoming-details");
+ detailstitle = document.createElement("h5");
detailstitle.innerText = `${element.subject} assessment`;
- subject = document.createElement('p');
+ subject = document.createElement("p");
subject.innerText = element.title;
- subject.classList.add('upcoming-assessment-title');
- subject.onclick = function () { location.href = `../#?page=/assessments/${element.programmeID}:${element.metaclassID}&item=${element.id}` };
+ subject.classList.add("upcoming-assessment-title");
+ subject.onclick = function () {
+ location.href = `../#?page=/assessments/${element.programmeID}:${element.metaclassID}&item=${element.id}`;
+ };
detailsdiv.append(detailstitle);
detailsdiv.append(subject);
@@ -2456,7 +2585,11 @@ function createAssessmentDateDiv(date, value, datecase = undefined) {
headers: {
"Content-Type": "application/json; charset=utf-8",
},
- body: JSON.stringify({ "assessment": element.id, "metaclass": element.metaclassID, "student": 69 })
+ body: JSON.stringify({
+ assessment: element.id,
+ metaclass: element.metaclassID,
+ student: 69,
+ }),
})
.then((result) => result.json())
.then((response) => {
@@ -2466,30 +2599,24 @@ function createAssessmentDateDiv(date, value, datecase = undefined) {
// ticksvg = stringToHTML(``).firstChild
// ticksvg.classList.add('upcoming-tick');
// assessment.append(ticksvg);
- submittedtext = document.createElement('div')
- submittedtext.classList.add('upcoming-submittedtext');
+ submittedtext = document.createElement("div");
+ submittedtext.classList.add("upcoming-submittedtext");
submittedtext.innerText = "Submitted";
assessment.append(submittedtext);
-
-
}
- })
-
-
-
+ });
}
container.append(assessmentContainer);
return container;
-
}
function CheckSpecialDay(date1, date2) {
if (
date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
- (date1.getDate() - 1) === date2.getDate()
+ date1.getDate() - 1 === date2.getDate()
) {
return "Yesterday";
}
@@ -2504,7 +2631,7 @@ function CheckSpecialDay(date1, date2) {
if (
date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
- (date1.getDate() + 1) === date2.getDate()
+ date1.getDate() + 1 === date2.getDate()
) {
TomorrowinUpcoming = true;
return "Tomorrow";
@@ -2512,76 +2639,92 @@ function CheckSpecialDay(date1, date2) {
}
function CreateDateCheckedDiv(text, date) {
- upcomingitemcontainer = document.querySelector('#upcoming-items')
- container = CreateElement(type = 'div', class_ = 'upcoming-date-container');
- datecontainer = CreateElement(type = 'div', class_ = 'upcoming-date-title');
- titletext = CreateElement(type = 'h5', class_ = 'upcoming-special-day', id = undefined, innerText = text);
- titledate = CreateElement(type = 'h5', class_ = undefined, id = undefined, innerText = date);
+ upcomingitemcontainer = document.querySelector("#upcoming-items");
+ container = CreateElement(
+ (type = "div"),
+ (class_ = "upcoming-date-container"),
+ );
+ datecontainer = CreateElement(
+ (type = "div"),
+ (class_ = "upcoming-date-title"),
+ );
+ titletext = CreateElement(
+ (type = "h5"),
+ (class_ = "upcoming-special-day"),
+ (id = undefined),
+ (innerText = text),
+ );
+ titledate = CreateElement(
+ (type = "h5"),
+ (class_ = undefined),
+ (id = undefined),
+ (innerText = date),
+ );
- textcontainer = CreateElement('div', 'upcoming-blank')
- textblank = CreateElement('p');
- textblank.innerText = 'No assessments due';
+ textcontainer = CreateElement("div", "upcoming-blank");
+ textblank = CreateElement("p");
+ textblank.innerText = "No assessments due";
- textcontainer.append(textblank)
+ textcontainer.append(textblank);
datecontainer.append(titletext);
datecontainer.append(titledate);
container.append(datecontainer);
- container.append(textcontainer)
+ container.append(textcontainer);
upcomingitemcontainer.append(container);
}
-
-
function CreateSubjectFilter(subjectcode, itemcolour, checked) {
- label = CreateElement('label', "upcoming-checkbox-container")
+ label = CreateElement("label", "upcoming-checkbox-container");
label.innerText = subjectcode;
- input = CreateElement('input');
+ input = CreateElement("input");
input.type = "checkbox";
input.checked = checked;
input.id = `filter-${subjectcode}`;
label.style = itemcolour;
- span = CreateElement('span', 'upcoming-checkmark')
+ span = CreateElement("span", "upcoming-checkmark");
label.append(input);
label.append(span);
- input.addEventListener('change', function (change) {
+ input.addEventListener("change", function (change) {
chrome.storage.local.get(null, function (storage) {
filters = storage.subjectfilters;
- id = change.target.id.split('-')[1]
- filters[id] = change.target.checked
+ id = change.target.id.split("-")[1];
+ filters[id] = change.target.checked;
- chrome.storage.local.set({ subjectfilters: filters })
- })
- })
+ chrome.storage.local.set({ subjectfilters: filters });
+ });
+ });
- return label
+ return label;
}
function CreateFilters(subjects) {
chrome.storage.local.get(null, function (result) {
- filteroptions = result.subjectfilters
+ filteroptions = result.subjectfilters;
- filterdiv = document.querySelector('#upcoming-filters')
+ filterdiv = document.querySelector("#upcoming-filters");
for (let i = 0; i < subjects.length; i++) {
const element = subjects[i];
if (!filteroptions.hasOwnProperty(element.code)) {
filteroptions[element.code] = true;
chrome.storage.local.set({ subjectfilters: filteroptions });
}
- elementdiv = CreateSubjectFilter(element.code, element.colour, filteroptions[element.code])
+ elementdiv = CreateSubjectFilter(
+ element.code,
+ element.colour,
+ filteroptions[element.code],
+ );
- filterdiv.append(elementdiv)
+ filterdiv.append(elementdiv);
}
- })
+ });
}
-
-
function CreateUpcomingSection(assessments) {
- upcomingitemcontainer = document.querySelector('#upcoming-items')
- homecontainer = document.querySelector('#home-container')
+ upcomingitemcontainer = document.querySelector("#upcoming-items");
+ homecontainer = document.querySelector("#home-container");
overdueDates = [];
upcomingDates = {};
TodayinUpcoming = false;
@@ -2597,7 +2740,7 @@ function CreateUpcomingSection(assessments) {
const element = assessments[i];
assessmentdue = new Date(element.due);
- CheckSpecialDay(Today, assessmentdue)
+ CheckSpecialDay(Today, assessmentdue);
if (assessmentdue < Today) {
if (!CheckSpecialDay(Today, assessmentdue)) {
overdueDates.push(element);
@@ -2606,7 +2749,7 @@ function CreateUpcomingSection(assessments) {
}
}
}
- var options = { weekday: 'long', month: 'long', day: 'numeric' };
+ var options = { weekday: "long", month: "long", day: "numeric" };
if (!TodayinUpcoming) {
text = Today.toLocaleDateString("en-AU", options);
CreateDateCheckedDiv("Today", text);
@@ -2615,7 +2758,7 @@ function CreateUpcomingSection(assessments) {
function addTomorrowinUpcoming() {
// var TomorrowDate = new Date(date);
var TomorrowDate = new Date();
- TomorrowDate.setDate((TomorrowDate.getDate() + 1))
+ TomorrowDate.setDate(TomorrowDate.getDate() + 1);
textDate = TomorrowDate.toLocaleDateString("en-AU", options);
CreateDateCheckedDiv("Tomorrow", textDate);
}
@@ -2627,46 +2770,42 @@ function CreateUpcomingSection(assessments) {
GetLessonColours().then((colours) => {
subjects = colours;
for (let i = 0; i < assessments.length; i++) {
+ subjectname = `timetable.subject.colour.${assessments[i].code}`;
- subjectname = `timetable.subject.colour.${assessments[i].code}`
-
- subject = subjects.find(element => element.name === subjectname)
+ subject = subjects.find((element) => element.name === subjectname);
if (!subject) {
- assessments[i].colour = `--item-colour: #8e8e8e;`
- }
- else {
- assessments[i].colour = `--item-colour: ${subject.value};`
+ assessments[i].colour = `--item-colour: #8e8e8e;`;
+ } else {
+ assessments[i].colour = `--item-colour: ${subject.value};`;
result = GetThresholdofHex(subject.value);
}
}
for (let i = 0; i < activeSubjects.length; i++) {
const element = activeSubjects[i];
- subjectname = `timetable.subject.colour.${element.code}`
- colour = colours.find(element => element.name === subjectname);
+ subjectname = `timetable.subject.colour.${element.code}`;
+ colour = colours.find((element) => element.name === subjectname);
if (!colour) {
- element.colour = `--item-colour: #8e8e8e;`
- }
- else {
- element.colour = `--item-colour: ${colour.value};`
+ element.colour = `--item-colour: #8e8e8e;`;
+ } else {
+ element.colour = `--item-colour: ${colour.value};`;
result = GetThresholdofHex(colour.value);
if (result > 300) {
element.invert = true;
}
}
-
}
-
CreateFilters(activeSubjects);
-
-
for (let i = 0; i < assessments.length; i++) {
const element = assessments[i];
if (!upcomingDates[element.due]) {
dateObj = new Object();
- dateObj.div = CreateElement(type = 'div', class_ = 'upcoming-date-container')
+ dateObj.div = CreateElement(
+ (type = "div"),
+ (class_ = "upcoming-date-container"),
+ );
dateObj.assessments = [];
upcomingDates[element.due] = dateObj;
@@ -2676,44 +2815,48 @@ function CreateUpcomingSection(assessments) {
}
for (var date in upcomingDates) {
-
assessmentdue = new Date(upcomingDates[date].assessments[0].due);
specialcase = CheckSpecialDay(Today, assessmentdue);
if (specialcase) {
- assessmentDate = createAssessmentDateDiv(date, upcomingDates[date], datecase = specialcase);
+ assessmentDate = createAssessmentDateDiv(
+ date,
+ upcomingDates[date],
+ (datecase = specialcase),
+ );
} else {
assessmentDate = createAssessmentDateDiv(date, upcomingDates[date]);
}
- if (specialcase === 'Yesterday') {
- upcomingitemcontainer.insertBefore(assessmentDate, upcomingitemcontainer.firstChild);
+ if (specialcase === "Yesterday") {
+ upcomingitemcontainer.insertBefore(
+ assessmentDate,
+ upcomingitemcontainer.firstChild,
+ );
} else {
- upcomingitemcontainer.append(assessmentDate)
+ upcomingitemcontainer.append(assessmentDate);
}
- if (specialcase === 'Today' && !TomorrowinUpcoming) {
+ if (specialcase === "Today" && !TomorrowinUpcoming) {
addTomorrowinUpcoming();
}
-
-
}
chrome.storage.local.get(null, function (result) {
FilterUpcomingAssessments(result.subjectfilters);
- })
- })
+ });
+ });
}
function AddPlaceHolderToParent(parent, numberofassessments) {
- textcontainer = CreateElement('div', 'upcoming-blank')
- textblank = CreateElement('p', 'upcoming-hiddenassessment');
+ textcontainer = CreateElement("div", "upcoming-blank");
+ textblank = CreateElement("p", "upcoming-hiddenassessment");
s = "";
if (numberofassessments > 1) {
s = "s";
}
textblank.innerText = `${numberofassessments} hidden assessment${s} due`;
textcontainer.append(textblank);
- textcontainer.setAttribute('data-hidden', true);
+ textcontainer.setAttribute("data-hidden", true);
parent.append(textcontainer);
}
@@ -2726,47 +2869,47 @@ function FilterUpcomingAssessments(subjectoptions) {
const element = subjectdivs[i];
if (!subjectoptions[item]) {
- element.classList.add('hidden');
+ element.classList.add("hidden");
}
if (subjectoptions[item]) {
- element.classList.remove('hidden');
+ element.classList.remove("hidden");
}
- element.parentNode.classList.remove('hidden');
+ element.parentNode.classList.remove("hidden");
- children = element.parentNode.parentNode.children
+ children = element.parentNode.parentNode.children;
for (let i = 0; i < children.length; i++) {
const element = children[i];
- if (element.hasAttribute('data-hidden')) {
+ if (element.hasAttribute("data-hidden")) {
element.remove();
}
}
- if (element.parentNode.children.length == element.parentNode.querySelectorAll(".hidden").length) {
+ if (
+ element.parentNode.children.length ==
+ element.parentNode.querySelectorAll(".hidden").length
+ ) {
if (element.parentNode.querySelectorAll(".hidden").length > 0) {
- if (!element.parentNode.parentNode.hasAttribute('data-day')) {
- element.parentNode.parentNode.classList.add('hidden');
+ if (!element.parentNode.parentNode.hasAttribute("data-day")) {
+ element.parentNode.parentNode.classList.add("hidden");
} else {
- AddPlaceHolderToParent(element.parentNode.parentNode, element.parentNode.querySelectorAll(".hidden").length)
+ AddPlaceHolderToParent(
+ element.parentNode.parentNode,
+ element.parentNode.querySelectorAll(".hidden").length,
+ );
}
}
-
-
- }
- else {
- element.parentNode.parentNode.classList.remove('hidden');
+ } else {
+ element.parentNode.parentNode.classList.remove("hidden");
}
}
-
-
}
-
}
chrome.storage.onChanged.addListener(function (changes) {
if (changes.subjectfilters) {
FilterUpcomingAssessments(changes.subjectfilters.newValue);
}
-})
+});
function GetLessonColours() {
func = fetch(`${location.origin}/seqta/student/load/prefs?`, {
@@ -2774,11 +2917,11 @@ function GetLessonColours() {
headers: {
"Content-Type": "application/json; charset=utf-8",
},
- body: JSON.stringify({ "request": "userPrefs", "asArray": true, "user": 69 })
- })
+ body: JSON.stringify({ request: "userPrefs", asArray: true, user: 69 }),
+ });
return func
.then((result) => result.json())
- .then(response => (response.payload))
+ .then((response) => response.payload);
}
function CreateCustomShortcutDiv(element) {
@@ -2790,7 +2933,9 @@ function CreateCustomShortcutDiv(element) {
shortcutdiv.classList.add("shortcut");
shortcutdiv.classList.add("customshortcut");
- image = stringToHTML(`${element.icon}`).firstChild
+ image = stringToHTML(
+ `${element.icon}`,
+ ).firstChild;
image.classList.add("shortcuticondiv");
var text = document.createElement("p");
text.textContent = element.name;
@@ -2805,7 +2950,8 @@ function AddCustomShortcutsToPage() {
chrome.storage.local.get(["customshortcuts"], function (result) {
var customshortcuts = Object.values(result)[0];
if (customshortcuts.length > 0) {
- document.getElementsByClassName("shortcut-container")[0].style.display = "block";
+ document.getElementsByClassName("shortcut-container")[0].style.display =
+ "block";
for (let i = 0; i < customshortcuts.length; i++) {
const element = customshortcuts[i];
CreateCustomShortcutDiv(element);
@@ -2828,15 +2974,15 @@ function SendHomePage() {
var main = document.getElementById("main");
main.innerHTML = "";
- const titlediv = document.getElementById('title').firstChild;
+ const titlediv = document.getElementById("title").firstChild;
titlediv.innerText = "Home";
- document.querySelector('link[rel*="icon"]').href = chrome.runtime.getURL("icons/icon-48.png");
+ document.querySelector('link[rel*="icon"]').href =
+ chrome.runtime.getURL("icons/icon-48.png");
currentSelectedDate = new Date();
// Creates the root of the home page added to the main div
- var htmlStr =
- `
`;
+ var htmlStr = `
`;
var html = stringToHTML(htmlStr);
// Appends the html file to main div
@@ -2853,7 +2999,6 @@ function SendHomePage() {
// Replaces actual date with a selected date. Used for testing.
// TodayFormatted = "2020-08-31";
-
// Creates the shortcut container into the home container
var ShortcutStr = `
`;
var Shortcut = stringToHTML(ShortcutStr);
@@ -2866,49 +3011,64 @@ function SendHomePage() {
// Appends the timetable container into the home container
document.getElementById("home-container").append(Timetable.firstChild);
- var timetablearrowback = document.getElementById('home-timetable-back')
- var timetablearrowforward = document.getElementById('home-timetable-forward')
+ var timetablearrowback = document.getElementById("home-timetable-back");
+ var timetablearrowforward = document.getElementById(
+ "home-timetable-forward",
+ );
function SetTimetableSubtitle() {
- var homelessonsubtitle = document.getElementById('home-lesson-subtitle');
+ var homelessonsubtitle = document.getElementById("home-lesson-subtitle");
const date = new Date();
- if (date.getYear() == currentSelectedDate.getYear() && date.getMonth() == currentSelectedDate.getMonth()) {
+ if (
+ date.getYear() == currentSelectedDate.getYear() &&
+ date.getMonth() == currentSelectedDate.getMonth()
+ ) {
if (date.getDate() == currentSelectedDate.getDate()) {
// Change text to Today's Lessons
homelessonsubtitle.innerText = "Today's Lessons";
- }
- else if ((date.getDate() - 1) == currentSelectedDate.getDate()) {
+ } else if (date.getDate() - 1 == currentSelectedDate.getDate()) {
// Change text to Yesterday's Lessons
homelessonsubtitle.innerText = "Yesterday's Lessons";
- }
- else if ((date.getDate() + 1) == currentSelectedDate.getDate()) {
+ } else if (date.getDate() + 1 == currentSelectedDate.getDate()) {
// Change text to Tomorrow's Lessons
homelessonsubtitle.innerText = "Tomorrow's Lessons";
- }
- else {
+ } else {
// Change text to date of the day
- homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString('en-us', { weekday: 'short' })} ${currentSelectedDate.toLocaleDateString('en-au')}`;
+ homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString(
+ "en-us",
+ { weekday: "short" },
+ )} ${currentSelectedDate.toLocaleDateString("en-au")}`;
}
- }
- else {
+ } else {
// Change text to date of the day
- homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString('en-us', { weekday: 'short' })} ${currentSelectedDate.toLocaleDateString('en-au')}`;
+ homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString(
+ "en-us",
+ { weekday: "short" },
+ )} ${currentSelectedDate.toLocaleDateString("en-au")}`;
}
}
function changeTimetable(value) {
currentSelectedDate.setDate(currentSelectedDate.getDate() + value);
- FormattedDate = currentSelectedDate.getFullYear() + "-" + (currentSelectedDate.getMonth() + 1) + "-" + currentSelectedDate.getDate();
+ FormattedDate =
+ currentSelectedDate.getFullYear() +
+ "-" +
+ (currentSelectedDate.getMonth() + 1) +
+ "-" +
+ currentSelectedDate.getDate();
callHomeTimetable(FormattedDate, true);
SetTimetableSubtitle();
}
- timetablearrowback.addEventListener('click', function () { changeTimetable(-1) })
- timetablearrowforward.addEventListener('click', function () { changeTimetable(1) })
+ timetablearrowback.addEventListener("click", function () {
+ changeTimetable(-1);
+ });
+ timetablearrowforward.addEventListener("click", function () {
+ changeTimetable(1);
+ });
-
- assessmentsicon = ``
- coursesicon = ``
+ assessmentsicon = ``;
+ coursesicon = ``;
function createNewShortcut(link, icon, viewBox, title) {
// Creates the stucture and element information for each seperate shortcut
@@ -2918,7 +3078,9 @@ function SendHomePage() {
var shortcutdiv = document.createElement("div");
shortcutdiv.classList.add("shortcut");
- image = stringToHTML(``).firstChild
+ image = stringToHTML(
+ ``,
+ ).firstChild;
image.classList.add("shortcuticondiv");
var text = document.createElement("p");
text.textContent = title;
@@ -2933,12 +3095,12 @@ function SendHomePage() {
var shortcuts = Object.values(result)[0];
for (let i = 0; i < shortcuts.length; i++) {
if (shortcuts[i].enabled) {
- Itemname = (shortcuts[i].name).replace(/ /g, '')
+ Itemname = shortcuts[i].name.replace(/ /g, "");
createNewShortcut(
ShortcutLinks[Itemname].link,
ShortcutLinks[Itemname].icon,
ShortcutLinks[Itemname].viewBox,
- shortcuts[i].name
+ shortcuts[i].name,
);
}
}
@@ -2947,39 +3109,39 @@ function SendHomePage() {
// Checks if shortcut container is empty
if (document.getElementById("shortcuts").childElementCount == 0) {
// If there are no shortcuts, hide the container
- document.getElementsByClassName("shortcut-container")[0].style.display = "none";
+ document.getElementsByClassName("shortcut-container")[0].style.display =
+ "none";
}
});
-
// Creates the upcoming container and appends to the home container
- var upcomingcontainer = document.createElement('div');
- upcomingcontainer.classList.add('upcoming-container');
- upcomingcontainer.classList.add('border');
+ var upcomingcontainer = document.createElement("div");
+ upcomingcontainer.classList.add("upcoming-container");
+ upcomingcontainer.classList.add("border");
-
- upcomingtitlediv = CreateElement('div', 'upcoming-title');
- upcomingtitle = document.createElement('h2');
- upcomingtitle.classList.add('home-subtitle');
- upcomingtitle.innerText = 'Upcoming Assessments';
+ upcomingtitlediv = CreateElement("div", "upcoming-title");
+ upcomingtitle = document.createElement("h2");
+ upcomingtitle.classList.add("home-subtitle");
+ upcomingtitle.innerText = "Upcoming Assessments";
upcomingtitlediv.append(upcomingtitle);
- upcomingfilterdiv = CreateElement('div', 'upcoming-filters', 'upcoming-filters');
- upcomingtitlediv.append(upcomingfilterdiv)
+ upcomingfilterdiv = CreateElement(
+ "div",
+ "upcoming-filters",
+ "upcoming-filters",
+ );
+ upcomingtitlediv.append(upcomingfilterdiv);
upcomingcontainer.append(upcomingtitlediv);
-
-
- upcomingitems = document.createElement('div');
- upcomingitems.id = 'upcoming-items';
- upcomingitems.classList.add('upcoming-items');
+ upcomingitems = document.createElement("div");
+ upcomingitems.id = "upcoming-items";
+ upcomingitems.classList.add("upcoming-items");
upcomingcontainer.append(upcomingitems);
document.getElementById("home-container").append(upcomingcontainer);
-
// Creates the notices container into the home container
var NoticesStr = `
Notices
`;
var Notices = stringToHTML(NoticesStr);
@@ -2988,14 +3150,9 @@ function SendHomePage() {
callHomeTimetable(TodayFormatted);
-
// Sends similar HTTP Post Request for the notices
var xhr2 = new XMLHttpRequest();
- xhr2.open(
- "POST",
- `${location.origin}/seqta/student/load/notices?`,
- true
- );
+ xhr2.open("POST", `${location.origin}/seqta/student/load/notices?`, true);
xhr2.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr2.onreadystatechange = function () {
@@ -3010,7 +3167,6 @@ function SendHomePage() {
dummyNotice.classList.add("dummynotice");
NoticeContainer.append(dummyNotice);
}
-
} else {
if (!NoticeContainer.innerText) {
// For each element in the response json:
@@ -3020,33 +3176,41 @@ function SendHomePage() {
var NewNotice = document.createElement("div");
NewNotice.classList.add("notice");
var title = stringToHTML(
- `
` + NoticesPayload.payload[i].title + `
`
+ `
` +
+ NoticesPayload.payload[i].title +
+ `
`,
);
NewNotice.append(title.firstChild);
if (NoticesPayload.payload[i].label_title != undefined) {
var label = stringToHTML(
- `
` + NoticesPayload.payload[i].label_title + `
`
+ `
` +
+ NoticesPayload.payload[i].label_title +
+ `
`,
);
NewNotice.append(label.firstChild);
}
var staff = stringToHTML(
- `
` + NoticesPayload.payload[i].staff + `
`
+ `
` +
+ NoticesPayload.payload[i].staff +
+ `
`,
);
NewNotice.append(staff.firstChild);
// Converts the string into HTML
- var content = stringToHTML(NoticesPayload.payload[i].contents, styles=true);
+ var content = stringToHTML(
+ NoticesPayload.payload[i].contents,
+ (styles = true),
+ );
for (let i = 0; i < content.childNodes.length; i++) {
NewNotice.append(content.childNodes[i]);
}
// Gets the colour for the top section of each notice
-
var colour = NoticesPayload.payload[i].colour;
- if (typeof (colour) == "string") {
+ if (typeof colour == "string") {
rgb = GetThresholdofHex(colour);
- DarkModeResult = result.DarkMode
+ DarkModeResult = result.DarkMode;
if (rgb < 100 && DarkModeResult) {
colour = undefined;
}
@@ -3060,7 +3224,6 @@ function SendHomePage() {
NewNotice.append(colourbar);
// Appends the new notice into the notice container
NoticeContainer.append(NewNotice);
-
}
});
}
@@ -3074,26 +3237,20 @@ function SendHomePage() {
chrome.storage.local.get(null, function (result) {
if (result.notificationcollector) {
var xhr3 = new XMLHttpRequest();
- xhr3.open(
- "POST",
- `${location.origin}/seqta/student/heartbeat?`,
- true
- );
+ xhr3.open("POST", `${location.origin}/seqta/student/heartbeat?`, true);
xhr3.setRequestHeader(
"Content-Type",
- "application/json; charset=utf-8"
+ "application/json; charset=utf-8",
);
xhr3.onreadystatechange = function () {
if (xhr3.readyState === 4) {
var Notifications = JSON.parse(xhr3.response);
var alertdiv = document.getElementsByClassName(
- "notifications__bubble___1EkSQ"
+ "notifications__bubble___1EkSQ",
)[0];
- if (typeof alertdiv == 'undefined') {
- console.log("[BetterSEQTA] No notifications currently")
-
- }
- else {
+ if (typeof alertdiv == "undefined") {
+ console.log("[BetterSEQTA] No notifications currently");
+ } else {
alertdiv.textContent = Notifications.payload.notifications.length;
}
}
@@ -3102,54 +3259,45 @@ function SendHomePage() {
JSON.stringify({
timestamp: "1970-01-01 00:00:00.0",
hash: "#?page=/home",
- })
+ }),
);
}
});
- GetUpcomingAssessments()
- .then((assessments) => {
- GetActiveClasses().then((classes) => {
-
- // Gets all subjects for the student
- for (let i = 0; i < classes.length; i++) {
- const element = classes[i];
- if (element.hasOwnProperty('active')) {
- // Finds the active class list with the current subjects
- activeClassList = classes[i]
- }
+ GetUpcomingAssessments().then((assessments) => {
+ GetActiveClasses().then((classes) => {
+ // Gets all subjects for the student
+ for (let i = 0; i < classes.length; i++) {
+ const element = classes[i];
+ if (element.hasOwnProperty("active")) {
+ // Finds the active class list with the current subjects
+ activeClassList = classes[i];
}
- activeSubjects = activeClassList.subjects
+ }
+ activeSubjects = activeClassList.subjects;
- activeSubjectCodes = []
- // Gets the code for each of the subjects and puts them in an array
- for (let i = 0; i < activeSubjects.length; i++) {
- const element = activeSubjects[i];
- activeSubjectCodes.push(element.code)
+ activeSubjectCodes = [];
+ // Gets the code for each of the subjects and puts them in an array
+ for (let i = 0; i < activeSubjects.length; i++) {
+ const element = activeSubjects[i];
+ activeSubjectCodes.push(element.code);
+ }
+
+ CurrentAssessments = [];
+ for (let i = 0; i < assessments.length; i++) {
+ const element = assessments[i];
+ if (activeSubjectCodes.includes(element.code)) {
+ CurrentAssessments.push(element);
}
+ }
- CurrentAssessments = []
- for (let i = 0; i < assessments.length; i++) {
- const element = assessments[i];
- if (activeSubjectCodes.includes(element.code)) {
- CurrentAssessments.push(element)
- }
- }
+ CurrentAssessments.sort(comparedate);
+ CreateUpcomingSection(CurrentAssessments, activeSubjects);
-
- CurrentAssessments.sort(comparedate);
-
-
- CreateUpcomingSection(CurrentAssessments, activeSubjects);
-
-
- // Run function to check if gap between assessments > 7 days?
-
- })
-
+ // Run function to check if gap between assessments > 7 days?
});
-
+ });
}, 8);
}
@@ -3168,50 +3316,48 @@ function SendNewsPage() {
main.innerHTML = "";
// Creates the root of the home page added to the main div
- var htmlStr =
- `