From 165bf2df95d42d3ff029ade606e38308e93eacc8 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 26 Jul 2023 17:29:26 +0200 Subject: front page and lots of stuff --- frontend/main.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'frontend/main.ts') diff --git a/frontend/main.ts b/frontend/main.ts index c9cd654..a5c18e7 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -1,6 +1,6 @@ /// -import { load_bangs, process_query } from "./query.ts"; -import { add_page_content } from "./ui.ts" +import { bangs, load_bangs, process_query } from "./query.ts"; +import { add_page_content, status } from "./ui.ts" globalThis.addEventListener("hashchange", () => process_url()) @@ -12,13 +12,21 @@ globalThis.addEventListener("load", () => { function process_url() { if (document.location.hash.length != 0) { const input = document.location.hash.substring(1) - const [default_engine, query_encoded] = input.split("#") + const [engine, query_encoded] = input.split("#") if (query_encoded) { const query = decodeURIComponent(query_encoded.replaceAll("+", " ")) - process_query(default_engine, query) + process_query(engine, query) } else { - return add_page_content(default_engine) + add_page_content(engine) } + bangs.then(bangs => { + console.log("bop"); + + if (!bangs[engine]) { + status("error", "Engine does not exist") + window.location.hash = "#" + } + }) } else { add_page_content() } -- cgit v1.2.3-70-g09d2