mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 03:50:02 -04:00
Games are back!
This commit is contained in:
parent
f82c2de301
commit
920d9f198f
4 changed files with 30 additions and 18 deletions
|
@ -57,10 +57,10 @@
|
|||
|
||||
const eventHandler = new EventHandler({
|
||||
events: {
|
||||
"DOMContentLoaded": (async () => {
|
||||
"DOMContentLoaded": async () => {
|
||||
await init();
|
||||
await initSettings();
|
||||
}),
|
||||
},
|
||||
"astro:after-swap": (async () => {
|
||||
})
|
||||
},
|
||||
|
|
|
@ -3,16 +3,25 @@ import Layout from "@layouts/Layout.astro";
|
|||
---
|
||||
|
||||
<Layout title="Chango Games">
|
||||
<iframe id="chango" class="w-full h-full"></iframe>
|
||||
<iframe id="chango" class="w-full h-full" src="/loading"></iframe>
|
||||
</Layout>
|
||||
<script>
|
||||
import { setTransport, getSWStuff } from "@utils/registerSW.ts"; //../../utils/registerSW.ts
|
||||
import { Settings } from "@utils/settings/index";
|
||||
import { pageLoad } from "@utils/events";
|
||||
pageLoad(async () => {
|
||||
const { conn } = getSWStuff();
|
||||
const iframe = document.getElementById("chango") as HTMLIFrameElement;
|
||||
await setTransport(conn, localStorage.getItem(Settings.ProxySettings.transport) as string);
|
||||
if (iframe) return iframe.src = __uv$config!.prefix + __uv$config.encodeUrl!("https://radon.games");
|
||||
});
|
||||
import { EventHandler } from "@utils/events";
|
||||
import { Elements } from "@utils/index";
|
||||
|
||||
const init = async () => {
|
||||
const el = Elements.select([
|
||||
{ type: 'id', val: 'chango' }
|
||||
]);
|
||||
const chango = Elements.exists<HTMLIFrameElement>(await el.next());
|
||||
chango.src = `${__uv$config.prefix}${__uv$config.encodeUrl!("https://radon.games/games/")}`
|
||||
};
|
||||
|
||||
new EventHandler({
|
||||
events: {
|
||||
"astro:page-load": init
|
||||
},
|
||||
logging: false
|
||||
})
|
||||
.bind();
|
||||
</script>
|
||||
|
|
|
@ -169,11 +169,9 @@ import { VERSION } from "astro:env/client";
|
|||
|
||||
new EventHandler({
|
||||
events: {
|
||||
"astro:page-load": async () => {
|
||||
await init()
|
||||
}
|
||||
"astro:page-load": init
|
||||
},
|
||||
logging: true
|
||||
logging: false
|
||||
})
|
||||
.bind();
|
||||
</script>
|
||||
|
|
|
@ -31,8 +31,13 @@ class EventHandler {
|
|||
this.#eventItems = items;
|
||||
}
|
||||
#attachEvent(items: Events, eventType: Event, fn: () => unknown) {
|
||||
if (items.logging) return document.addEventListener(eventType, () => fn());
|
||||
try { document.addEventListener(eventType, () => fn()) } catch (_) {};
|
||||
if (items.logging) return document.addEventListener(eventType, async () => await fn());
|
||||
document.addEventListener(eventType, async () => {
|
||||
try {
|
||||
await fn();
|
||||
}
|
||||
catch (_) {}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Binds the events you passed when creating the class to the document. If none are passed, an error is thrown.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue