aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-07-26 21:48:06 +0200
committermetamuffin <metamuffin@disroot.org>2023-07-26 21:48:37 +0200
commit377e503555a9b5feb89e15275f26333545a6e414 (patch)
tree2e0d5907fee87a91799c9388ede8fa28c2c77579 /frontend
parent25699e2d089ab21072e6894c098efea98fc14fa9 (diff)
downloadfastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar
fastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar.bz2
fastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar.zst
rename project and add some more ui
Diffstat (limited to 'frontend')
-rw-r--r--frontend/index.html2
-rw-r--r--frontend/query.ts7
-rw-r--r--frontend/style.sass3
-rw-r--r--frontend/ui.ts16
4 files changed, 17 insertions, 11 deletions
diff --git a/frontend/index.html b/frontend/index.html
index f2c481f..52420db 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="./bundle.js"></script>
<link rel="stylesheet" href="./style.css" />
- <title>Projectname</title>
+ <title>Fastbangs</title>
</head>
<body>
<noscript>requires javascript</noscript>
diff --git a/frontend/query.ts b/frontend/query.ts
index 8a5ec2e..a608c57 100644
--- a/frontend/query.ts
+++ b/frontend/query.ts
@@ -25,18 +25,19 @@ export function load_bangs() {
export async function process_query(default_engine: string, query: string) {
const bang_prefix = "!"
- let url = ""
+ let url: string | undefined
if (query.startsWith(bang_prefix)) {
const [engine, ...query_parts] = query.substring(bang_prefix.length).split(" ")
url = await search_url(engine, query_parts.join(" "))
} else {
url = await search_url(default_engine, query)
}
+ if (!url) return status("error", "Invalid search engine.")
status("success", `Forwarding to ${url}`)
- setTimeout(() => document.location.href = url, 0)
+ setTimeout(() => document.location.href = url!, 0)
}
async function search_url(engine: string, query: string) {
- return (await bangs)[engine]!.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+"))
+ return (await bangs)[engine]?.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+"))
}
diff --git a/frontend/style.sass b/frontend/style.sass
index eeaa708..5199a22 100644
--- a/frontend/style.sass
+++ b/frontend/style.sass
@@ -8,6 +8,9 @@ body
p, h1, h2, h3, h4, h5, h6, input, button, label, li
color: white
+h1
+ font-size: xx-large
+
.status
background-color: black
padding: 1em
diff --git a/frontend/ui.ts b/frontend/ui.ts
index 6a254c7..22f9d71 100644
--- a/frontend/ui.ts
+++ b/frontend/ui.ts
@@ -23,7 +23,7 @@ function section_search(engine: string) {
link.id = "search-link"
link.type = "application/opensearchdescription+xml"
link.href = `/search.xml?default=${encodeURIComponent(engine)}`
- link.title = `Projectname (default engine: ${engine})`
+ link.title = `Fastbangs (default engine: ${engine})`
document.head.append(link)
const heading = document.createElement("h1")
@@ -94,11 +94,11 @@ function section_info_search() {
const section = document.createElement("section")
section.classList.add("info")
- const heading = document.createElement("h1")
- heading.textContent = "Heading"
+ const heading = document.createElement("h2")
+ heading.textContent = "Setup"
const info = document.createElement("p")
- info.textContent = `To install this as the default search engine, select "Add <name>" in the context-menu of the URL-bar.`
+ info.textContent = `To install this as the default search engine, select "Add Fastbangs" in the context-menu of the URL-bar.`
section.append(heading, info)
return section
@@ -109,11 +109,13 @@ function section_info_start() {
section.classList.add("info")
const heading = document.createElement("h1")
- heading.textContent = "Projectname"
+ heading.textContent = "Fastbangs"
const info = document.createElement("p")
- info.textContent = "This is where one would write what this application does..."
-
+ info.textContent = `
+ This application provides a way to (mostly) locally handle search bangs.
+ First select a default engine to use, then register this page as a search in your browser
+ `
section.append(heading, info)
return section
}