Games are back!

This commit is contained in:
MotorTruck1221 2025-01-07 00:40:30 -07:00
parent f82c2de301
commit 920d9f198f
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
4 changed files with 30 additions and 18 deletions

View file

@ -57,10 +57,10 @@
const eventHandler = new EventHandler({
events: {
"DOMContentLoaded": (async () => {
"DOMContentLoaded": async () => {
await init();
await initSettings();
}),
},
"astro:after-swap": (async () => {
})
},

View file

@ -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>

View file

@ -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>

View file

@ -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.