mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 19:54:39 +00:00
format: run prettify
This commit is contained in:
@@ -1,36 +1,40 @@
|
||||
import { changeSettingsClicked, closeExtensionPopup, SettingsClicked } from "../Closers/closeExtensionPopup"
|
||||
import renderSvelte from "@/interface/main"
|
||||
import { SettingsResizer } from "@/seqta/ui/SettingsResizer"
|
||||
import Settings from "@/interface/pages/settings.svelte"
|
||||
import {
|
||||
changeSettingsClicked,
|
||||
closeExtensionPopup,
|
||||
SettingsClicked,
|
||||
} from "../Closers/closeExtensionPopup";
|
||||
import renderSvelte from "@/interface/main";
|
||||
import { SettingsResizer } from "@/seqta/ui/SettingsResizer";
|
||||
import Settings from "@/interface/pages/settings.svelte";
|
||||
|
||||
export function addExtensionSettings() {
|
||||
const extensionPopup = document.createElement("div")
|
||||
extensionPopup.classList.add("outside-container", "hide")
|
||||
extensionPopup.id = "ExtensionPopup"
|
||||
|
||||
const extensionContainer = document.querySelector(
|
||||
"#container",
|
||||
) as HTMLDivElement
|
||||
if (extensionContainer) extensionContainer.appendChild(extensionPopup)
|
||||
|
||||
// create shadow dom and render svelte app
|
||||
try {
|
||||
const shadow = extensionPopup.attachShadow({ mode: "open" })
|
||||
requestIdleCallback(() => renderSvelte(Settings, shadow))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
const extensionPopup = document.createElement("div");
|
||||
extensionPopup.classList.add("outside-container", "hide");
|
||||
extensionPopup.id = "ExtensionPopup";
|
||||
|
||||
const extensionContainer = document.querySelector(
|
||||
"#container",
|
||||
) as HTMLDivElement;
|
||||
if (extensionContainer) extensionContainer.appendChild(extensionPopup);
|
||||
|
||||
// create shadow dom and render svelte app
|
||||
try {
|
||||
const shadow = extensionPopup.attachShadow({ mode: "open" });
|
||||
requestIdleCallback(() => renderSvelte(Settings, shadow));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
const container = document.getElementById("container");
|
||||
|
||||
new SettingsResizer();
|
||||
|
||||
container!.onclick = (event) => {
|
||||
if (!SettingsClicked) return;
|
||||
|
||||
if (!(event.target as HTMLElement).closest("#AddedSettings")) {
|
||||
if (event.target == extensionPopup) return;
|
||||
changeSettingsClicked(closeExtensionPopup());
|
||||
}
|
||||
|
||||
const container = document.getElementById("container")
|
||||
|
||||
new SettingsResizer()
|
||||
|
||||
container!.onclick = (event) => {
|
||||
if (!SettingsClicked) return
|
||||
|
||||
if (!(event.target as HTMLElement).closest("#AddedSettings")) {
|
||||
if (event.target == extensionPopup) return
|
||||
changeSettingsClicked(closeExtensionPopup())
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import ShortcutLinks from "@/seqta/content/links.json"
|
||||
import stringToHTML from "../stringToHTML"
|
||||
import ShortcutLinks from "@/seqta/content/links.json";
|
||||
import stringToHTML from "../stringToHTML";
|
||||
|
||||
export function addShortcuts(shortcuts: any) {
|
||||
for (let i = 0; i < shortcuts.length; i++) {
|
||||
const currentShortcut = shortcuts[i]
|
||||
const currentShortcut = shortcuts[i];
|
||||
|
||||
if (currentShortcut?.enabled) {
|
||||
const Itemname = (currentShortcut?.name ?? "").replace(/\s/g, "")
|
||||
const Itemname = (currentShortcut?.name ?? "").replace(/\s/g, "");
|
||||
|
||||
const linkDetails =
|
||||
ShortcutLinks?.[Itemname as keyof typeof ShortcutLinks]
|
||||
ShortcutLinks?.[Itemname as keyof typeof ShortcutLinks];
|
||||
if (linkDetails) {
|
||||
createNewShortcut(
|
||||
linkDetails.link,
|
||||
linkDetails.icon,
|
||||
linkDetails.viewBox,
|
||||
currentShortcut?.name,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
console.warn(`No link details found for '${Itemname}'`)
|
||||
console.warn(`No link details found for '${Itemname}'`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,21 +26,21 @@ export function addShortcuts(shortcuts: any) {
|
||||
|
||||
function createNewShortcut(link: any, icon: any, viewBox: any, title: any) {
|
||||
// Creates the stucture and element information for each seperate shortcut
|
||||
let shortcut = document.createElement("a")
|
||||
shortcut.setAttribute("href", link)
|
||||
shortcut.setAttribute("target", "_blank")
|
||||
let shortcutdiv = document.createElement("div")
|
||||
shortcutdiv.classList.add("shortcut")
|
||||
let shortcut = document.createElement("a");
|
||||
shortcut.setAttribute("href", link);
|
||||
shortcut.setAttribute("target", "_blank");
|
||||
let shortcutdiv = document.createElement("div");
|
||||
shortcutdiv.classList.add("shortcut");
|
||||
|
||||
let image = stringToHTML(
|
||||
`<svg style="width:39px;height:39px" viewBox="${viewBox}"><path fill="currentColor" d="${icon}" /></svg>`,
|
||||
).firstChild
|
||||
;(image! as HTMLElement).classList.add("shortcuticondiv")
|
||||
let text = document.createElement("p")
|
||||
text.textContent = title
|
||||
shortcutdiv.append(image as HTMLElement)
|
||||
shortcutdiv.append(text)
|
||||
shortcut.append(shortcutdiv)
|
||||
).firstChild;
|
||||
(image! as HTMLElement).classList.add("shortcuticondiv");
|
||||
let text = document.createElement("p");
|
||||
text.textContent = title;
|
||||
shortcutdiv.append(image as HTMLElement);
|
||||
shortcutdiv.append(text);
|
||||
shortcut.append(shortcutdiv);
|
||||
|
||||
document.getElementById("shortcuts")!.appendChild(shortcut)
|
||||
}
|
||||
document.getElementById("shortcuts")!.appendChild(shortcut);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user