start modularisation and breaking down the monofile

This commit is contained in:
Alphons Joseph
2025-03-12 21:45:23 +08:00
parent 3c65e6d6c5
commit c9f0f9cf16
25 changed files with 2284 additions and 2192 deletions
@@ -0,0 +1,23 @@
export function CreateBackground() {
var bkCheck = document.getElementsByClassName("bg")
if (bkCheck.length !== 0) {
return
}
// Creating and inserting 3 divs containing the background applied to the pages
var bklocation = document.getElementById("container")
var menu = document.getElementById("menu")
var bk = document.createElement("div")
bk.classList.add("bg")
bklocation!.insertBefore(bk, menu)
var bk2 = document.createElement("div")
bk2.classList.add("bg")
bk2.classList.add("bg2")
bklocation!.insertBefore(bk2, menu)
var bk3 = document.createElement("div")
bk3.classList.add("bg")
bk3.classList.add("bg3")
bklocation!.insertBefore(bk3, menu)
}
@@ -0,0 +1,37 @@
import stringToHTML from "../stringToHTML"
export function CreateCustomShortcutDiv(element: any) {
// Creates the stucture and element information for each seperate shortcut
var shortcut = document.createElement("a")
shortcut.setAttribute("href", element.url)
shortcut.setAttribute("target", "_blank")
var shortcutdiv = document.createElement("div")
shortcutdiv.classList.add("shortcut")
shortcutdiv.classList.add("customshortcut")
let image = stringToHTML(
`
<svg style="width:39px;height:39px" viewBox="0 0 40 40" class="shortcuticondiv">
<text
text-anchor="middle"
x="50%"
y="50%"
dy=".35em"
fill="var(--text-primary)"
font-weight="bold"
font-size="32"
dominant-baseline="middle">
${element.icon}
</text>
</svg>
`,
).firstChild
;(image as HTMLElement).classList.add("shortcuticondiv")
var text = document.createElement("p")
text.textContent = element.name
shortcutdiv.append(image!)
shortcutdiv.append(text)
shortcut.append(shortcutdiv)
document.getElementById("shortcuts")!.append(shortcut)
}
@@ -0,0 +1,26 @@
export function CreateElement(
type: string,
class_?: any,
id?: any,
innerText?: string,
innerHTML?: string,
style?: string,
) {
let element = document.createElement(type)
if (class_ !== undefined) {
element.classList.add(class_)
}
if (id !== undefined) {
element.id = id
}
if (innerText !== undefined) {
element.innerText = innerText
}
if (innerHTML !== undefined) {
element.innerHTML = innerHTML
}
if (style !== undefined) {
element.style.cssText = style
}
return element
}
@@ -0,0 +1,13 @@
import { settingsState } from "../listeners/SettingsState"
import { CreateBackground } from "./CreateBackground"
import { RemoveBackground } from "../DisableRemove/RemoveBackground"
export function enableAnimatedBackground() {
if (settingsState.animatedbk) {
CreateBackground()
} else {
RemoveBackground()
document.getElementById("container")!.style.background =
"var(--background-secondary)"
}
}
@@ -0,0 +1,24 @@
export function enableNotificationCollector() {
var xhr3 = new XMLHttpRequest()
xhr3.open("POST", `${location.origin}/seqta/student/heartbeat?`, true)
xhr3.setRequestHeader("Content-Type", "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",
)[0]
if (typeof alertdiv == "undefined") {
console.info("[BetterSEQTA+] No notifications currently")
} else {
alertdiv.textContent = Notifications.payload.notifications.length
}
}
}
xhr3.send(
JSON.stringify({
timestamp: "1970-01-01 00:00:00.0",
hash: "#?page=/home",
}),
)
}