diff options
-rw-r--r-- | frontend/main.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/frontend/main.ts b/frontend/main.ts index ad77f6f..b74f539 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -8,7 +8,7 @@ globalThis.addEventListener("hashchange", () => process_url()) globalThis.addEventListener("load", async () => { status_el = document.createElement("p") document.body.append(status_el) - + const bangs_res = await fetch("/bangs.json") if (!bangs_res.ok) document.writeln("error: could not download bangs.json") bangs = await bangs_res.json() @@ -16,10 +16,22 @@ globalThis.addEventListener("load", async () => { }) function setup_page(engine?: string) { + document.getElementById("content")?.remove() const section = document.createElement("section") + section.id = "content" if (engine) { - document.head.innerHTML += `<link rel="search" type="application/opensearchdescription+xml" title="laufente" href="todo" />` + if (document.getElementById("search-link")) { + // <link /> is already present, we need reload because browser wont notice otherwise + window.location.reload() + } + const link = document.createElement("link") + link.rel = "search" + link.id = "search-link" + link.type = "application/opensearchdescription+xml" + link.href = `/search.xml?default=${encodeURIComponent(engine)}` + link.title = `Laufente (defaults engine: ${engine})` + document.head.append(link) const heading = document.createElement("h1") heading.textContent = engine |