diff options
Diffstat (limited to 'frontend/main.ts')
-rw-r--r-- | frontend/main.ts | 18 |
1 files changed, 13 insertions, 5 deletions
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 @@ /// <reference lib="dom" /> -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() } |