mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 11:44:40 +00:00
dev
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { addExtensionSettings } from "@/seqta/utils/Adders/AddExtensionSettings";
|
||||
import { enableAnimatedBackground } from "@/seqta/utils/CreateEnable/EnableAnimatedBackground";
|
||||
import { loadHomePage } from "@/seqta/utils/Loaders/LoadHomePage";
|
||||
import { SendNewsPage } from "@/seqta/utils/SendNewsPage";
|
||||
import { setupSettingsButton } from "@/seqta/utils/setupSettingsButton";
|
||||
|
||||
|
||||
import { GetThresholdOfColor } from "@/seqta/ui/colors/getThresholdColour";
|
||||
import { updateBgDurations } from "./Animation";
|
||||
import { appendBackgroundToUI } from "./ImageBackgrounds";
|
||||
import stringToHTML from "@/seqta/utils/stringToHTML";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
@@ -42,7 +40,6 @@ async function getUserInfo() {
|
||||
|
||||
export async function AddBetterSEQTAElements() {
|
||||
if (settingsState.onoff) {
|
||||
initializeSettings();
|
||||
if (settingsState.DarkMode) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
@@ -76,11 +73,6 @@ export async function AddBetterSEQTAElements() {
|
||||
setupSettingsButton();
|
||||
}
|
||||
|
||||
function initializeSettings() {
|
||||
enableAnimatedBackground();
|
||||
updateBgDurations();
|
||||
}
|
||||
|
||||
function createHomeButton(fragment: DocumentFragment, menuList: HTMLElement) {
|
||||
const container = document.getElementById('content')!;
|
||||
const div = document.createElement('div');
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
/**
|
||||
* Update the background animation durations based on the slider input.
|
||||
* @param {Object} item - The object containing the bksliderinput property.
|
||||
* @param {number} [minDuration=1] - The minimum animation duration in seconds.
|
||||
* @param {number} [maxDuration=10] - The maximum animation duration in seconds.
|
||||
*/
|
||||
export function updateBgDurations() {
|
||||
// Class names to look for
|
||||
const bgClasses = ['bg', 'bg2', 'bg3'];
|
||||
|
||||
// Function to calculate animation duration
|
||||
const calcDuration = (
|
||||
baseValue: number,
|
||||
offset = 0,
|
||||
minBase = 50,
|
||||
maxBase = 150,
|
||||
) => {
|
||||
const scaledValue = 2 + ((maxBase - baseValue) / (maxBase - minBase)) ** 4;
|
||||
return scaledValue + offset;
|
||||
};
|
||||
|
||||
// Iterate through each class name to update its animation duration
|
||||
bgClasses.forEach((className, index) => {
|
||||
const elements = document.getElementsByClassName(className);
|
||||
|
||||
if (elements.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const offset = index * 0.05;
|
||||
const duration = calcDuration(parseInt(settingsState.bksliderinput), offset);
|
||||
(elements[0] as HTMLElement).style.animationDuration = `${duration}s`;
|
||||
(elements[0] as HTMLElement).style.animationDelay = `${offset * 5}s`;
|
||||
});
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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)"
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
export function RemoveBackground() {
|
||||
var bk = document.getElementsByClassName("bg")
|
||||
var bk2 = document.getElementsByClassName("bg2")
|
||||
var bk3 = document.getElementsByClassName("bg3")
|
||||
|
||||
if (bk.length == 0 || bk2.length == 0 || bk3.length == 0) return
|
||||
bk[0].remove()
|
||||
bk2[0].remove()
|
||||
bk3[0].remove()
|
||||
}
|
||||
@@ -3,14 +3,11 @@ import { updateAllColors } from '@/seqta/ui/colors/Manager';
|
||||
|
||||
|
||||
import { addShortcuts } from "@/seqta/utils/Adders/AddShortcuts";
|
||||
import { CreateBackground } from "@/seqta/utils/CreateEnable/CreateBackground";
|
||||
import { CreateCustomShortcutDiv } from "@/seqta/utils/CreateEnable/CreateCustomShortcutDiv";
|
||||
import { FilterUpcomingAssessments } from "@/seqta/utils/FilterUpcomingAssessments";
|
||||
import { RemoveBackground } from "@/seqta/utils/DisableRemove/RemoveBackground";
|
||||
import { RemoveShortcutDiv } from "@/seqta/utils/DisableRemove/RemoveShortcutDiv";
|
||||
|
||||
|
||||
import { updateBgDurations } from '@/seqta/ui/Animation';
|
||||
import browser from 'webextension-polyfill';
|
||||
import type { CustomShortcut } from '@/types/storage';
|
||||
|
||||
@@ -25,8 +22,6 @@ export class StorageChangeHandler {
|
||||
settingsState.register('onoff', this.handleOnOffChange.bind(this));
|
||||
settingsState.register('shortcuts', this.handleShortcutsChange.bind(this));
|
||||
settingsState.register('customshortcuts', this.handleCustomShortcutsChange.bind(this));
|
||||
settingsState.register('bksliderinput', updateBgDurations.bind(this));
|
||||
settingsState.register('animatedbk', this.handleAnimatedBkChange.bind(this));
|
||||
settingsState.register('transparencyEffects', this.handleTransparencyEffectsChange.bind(this));
|
||||
settingsState.register('subjectfilters', FilterUpcomingAssessments.bind(this));
|
||||
}
|
||||
@@ -83,15 +78,6 @@ export class StorageChangeHandler {
|
||||
RemoveShortcutDiv(removedShortcuts);
|
||||
}
|
||||
|
||||
private handleAnimatedBkChange(newValue: boolean) {
|
||||
if (newValue) {
|
||||
CreateBackground();
|
||||
} else {
|
||||
RemoveBackground();
|
||||
document.getElementById('container')!.style.background = 'var(--background-secondary)';
|
||||
}
|
||||
}
|
||||
|
||||
private handleTransparencyEffectsChange(newValue: boolean) {
|
||||
if (newValue) {
|
||||
document.documentElement.classList.add('transparencyEffects');
|
||||
|
||||
Reference in New Issue
Block a user