mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-12 19:40:02 -04:00
Add loading to iFrame
This commit is contained in:
parent
d6ff02f284
commit
a2e67033c8
2 changed files with 32 additions and 1 deletions
|
@ -37,6 +37,8 @@ import { VERSION } from "astro:env/client";
|
|||
<iframe
|
||||
id="neb-iframe"
|
||||
class="hidden z-100 w-full h-full absolute top-0 bottom-0 bg-primary"
|
||||
src="/loading"
|
||||
preload="lazy"
|
||||
></iframe>
|
||||
<div id="version" class="flex flex-row w-full absolute bottom-4 pr-4 pl-4 text-text-color h-6 justify-between roboto">
|
||||
<p> Version: { VERSION } </p>
|
||||
|
@ -102,8 +104,10 @@ import { VERSION } from "astro:env/client";
|
|||
const input = document.getElementById("nebula-input") as HTMLInputElement;
|
||||
const iframe = document.getElementById("neb-iframe") as HTMLIFrameElement;
|
||||
const omnibox = document.getElementById("omnibox") as HTMLDivElement;
|
||||
const copyright = document.getElementById("version") as HTMLDivElement;
|
||||
input?.addEventListener("keypress", async function (event: any) {
|
||||
if (event.key === "Enter") {
|
||||
if (event.key === "Enter") {
|
||||
copyright.classList.add("hidden");
|
||||
if (localStorage.getItem(Settings.ProxySettings.proxy) === "automatic") {
|
||||
const key = SupportedSites[input?.value];
|
||||
switch(key) {
|
||||
|
|
27
src/pages/loading.astro
Normal file
27
src/pages/loading.astro
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
import Loading from "@components/Loading.astro";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
---
|
||||
|
||||
<Layout title="Loading page..." noHeader="true">
|
||||
<Loading />
|
||||
</Layout>
|
||||
<script>
|
||||
import { pageLoad } from "@utils/events";
|
||||
import { navigate } from "astro:transitions/client";
|
||||
function isComingFromIframe() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
}
|
||||
catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
pageLoad(() => {
|
||||
const isIframe = isComingFromIframe();
|
||||
if (!isIframe) {
|
||||
console.log("Assuming request isn't coming from iFrame. Redirecting...");
|
||||
navigate('/');
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue