From c1b1a9de4c1bfd0c8b3ea39cfd955c73330530cc Mon Sep 17 00:00:00 2001 From: MotorTruck1221 Date: Fri, 10 Jan 2025 04:55:37 -0700 Subject: [PATCH] Allow the user to reset their instance if they are having troubles --- src/pages/[lang]/index.astro | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index fb64c29..c98e5f8 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -35,9 +35,15 @@ import { VERSION } from "astro:env/client"; src="/loading">

Version: {VERSION}

+

© Nebula Services 2024

@@ -50,6 +56,7 @@ import { VERSION } from "astro:env/client"; import { defaultStore } from "@utils/storage"; import { Settings } from "@utils/settings"; import { setTransport, SW } from "@utils/serviceWorker"; +import { navigate } from "astro:transitions/client"; type Suggestion = { phrase: string; @@ -58,19 +65,29 @@ import { VERSION } from "astro:env/client"; const init = async (): Promise => { const bc = new BareClient(); const se = Elements.select([ + { type: 'id', val: 'reset' }, { type: 'id', val: 'nebula-input' }, { type: 'id', val: 'omnibox' }, { type: 'id', val: 'version' }, { type: 'id', val: 'neb-iframe' } ]); + + const reset = Elements.exists(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(await se.next()); const omnibox = Elements.exists(await se.next()); const copyright = Elements.exists(await se.next()); const iframe = Elements.exists(await se.next()); const prox = async (input: string, prox: "uv" | "sj") => { - const sw = SW.getInstances().next().value as SW; - const { sj } = await sw.getSWInfo(); + const sw = SW.getInstances().next().value as SW; iframe.classList.remove("hidden"); const val = search( input, @@ -79,12 +96,15 @@ import { VERSION } from "astro:env/client"; : SearchEngines.ddg ); switch(prox) { - case "uv": + case "uv": { iframe.src = `${__uv$config.prefix}${__uv$config.encodeUrl!(val)}`; break; - case "sj": + } + case "sj": { + const { sj } = await sw.getSWInfo(); iframe.src = sj.encodeUrl(val); break; + } } } input.addEventListener("keypress", async (event: any) => {