mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 12:00:01 -04:00
Allow the user to reset their instance if they are having troubles
This commit is contained in:
parent
72b0d4bbac
commit
c1b1a9de4c
1 changed files with 25 additions and 5 deletions
|
@ -35,9 +35,15 @@ import { VERSION } from "astro:env/client";
|
||||||
src="/loading"></iframe>
|
src="/loading"></iframe>
|
||||||
<div
|
<div
|
||||||
id="version"
|
id="version"
|
||||||
class="flex flex-row w-full absolute bottom-4 pr-4 pl-4 text-text-color h-6 justify-between font-roboto"
|
class="flex flex-row w-full absolute bottom-4 pr-4 pl-4 text-text-color h-6 justify-between items-center font-roboto"
|
||||||
>
|
>
|
||||||
<p>Version: {VERSION}</p>
|
<p>Version: {VERSION}</p>
|
||||||
|
<p class="hidden md:block">
|
||||||
|
Having problems?
|
||||||
|
<button id="reset" class="underline underline-offset-4 hover:decoration-input-border-color active:decoration-input-text">
|
||||||
|
Click here to reset your instance
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
<p>© Nebula Services 2024</p>
|
<p>© Nebula Services 2024</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,6 +56,7 @@ import { VERSION } from "astro:env/client";
|
||||||
import { defaultStore } from "@utils/storage";
|
import { defaultStore } from "@utils/storage";
|
||||||
import { Settings } from "@utils/settings";
|
import { Settings } from "@utils/settings";
|
||||||
import { setTransport, SW } from "@utils/serviceWorker";
|
import { setTransport, SW } from "@utils/serviceWorker";
|
||||||
|
import { navigate } from "astro:transitions/client";
|
||||||
|
|
||||||
type Suggestion = {
|
type Suggestion = {
|
||||||
phrase: string;
|
phrase: string;
|
||||||
|
@ -58,19 +65,29 @@ import { VERSION } from "astro:env/client";
|
||||||
const init = async (): Promise<void> => {
|
const init = async (): Promise<void> => {
|
||||||
const bc = new BareClient();
|
const bc = new BareClient();
|
||||||
const se = Elements.select([
|
const se = Elements.select([
|
||||||
|
{ type: 'id', val: 'reset' },
|
||||||
{ type: 'id', val: 'nebula-input' },
|
{ type: 'id', val: 'nebula-input' },
|
||||||
{ type: 'id', val: 'omnibox' },
|
{ type: 'id', val: 'omnibox' },
|
||||||
{ type: 'id', val: 'version' },
|
{ type: 'id', val: 'version' },
|
||||||
{ type: 'id', val: 'neb-iframe' }
|
{ type: 'id', val: 'neb-iframe' }
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const reset = Elements.exists<HTMLButtonElement>(await se.next());
|
||||||
|
Elements.attachEvent(reset, "click", async () => {
|
||||||
|
const t = await navigator.serviceWorker.getRegistrations();
|
||||||
|
t.map(async (reg) => {
|
||||||
|
await reg.unregister();
|
||||||
|
});
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = "/";
|
||||||
|
});
|
||||||
|
|
||||||
const input = Elements.exists<HTMLInputElement>(await se.next());
|
const input = Elements.exists<HTMLInputElement>(await se.next());
|
||||||
const omnibox = Elements.exists<HTMLDivElement>(await se.next());
|
const omnibox = Elements.exists<HTMLDivElement>(await se.next());
|
||||||
const copyright = Elements.exists<HTMLDivElement>(await se.next());
|
const copyright = Elements.exists<HTMLDivElement>(await se.next());
|
||||||
const iframe = Elements.exists<HTMLIFrameElement>(await se.next());
|
const iframe = Elements.exists<HTMLIFrameElement>(await se.next());
|
||||||
const prox = async (input: string, prox: "uv" | "sj") => {
|
const prox = async (input: string, prox: "uv" | "sj") => {
|
||||||
const sw = SW.getInstances().next().value as SW;
|
const sw = SW.getInstances().next().value as SW;
|
||||||
const { sj } = await sw.getSWInfo();
|
|
||||||
iframe.classList.remove("hidden");
|
iframe.classList.remove("hidden");
|
||||||
const val = search(
|
const val = search(
|
||||||
input,
|
input,
|
||||||
|
@ -79,12 +96,15 @@ import { VERSION } from "astro:env/client";
|
||||||
: SearchEngines.ddg
|
: SearchEngines.ddg
|
||||||
);
|
);
|
||||||
switch(prox) {
|
switch(prox) {
|
||||||
case "uv":
|
case "uv": {
|
||||||
iframe.src = `${__uv$config.prefix}${__uv$config.encodeUrl!(val)}`;
|
iframe.src = `${__uv$config.prefix}${__uv$config.encodeUrl!(val)}`;
|
||||||
break;
|
break;
|
||||||
case "sj":
|
}
|
||||||
|
case "sj": {
|
||||||
|
const { sj } = await sw.getSWInfo();
|
||||||
iframe.src = sj.encodeUrl(val);
|
iframe.src = sj.encodeUrl(val);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input.addEventListener("keypress", async (event: any) => {
|
input.addEventListener("keypress", async (event: any) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue