search field autocomplete

This commit is contained in:
Timon Ringwald 2022-05-12 21:15:55 +02:00
parent 0ac7bfc985
commit bf79763eb2
3 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,9 @@
package main package main
import "sort" import (
"sort"
"strings"
)
var ( var (
Bookmarks = []Bookmark{ Bookmarks = []Bookmark{
@ -39,7 +42,7 @@ var (
{ {
Title: "Postbank", Title: "Postbank",
Image: "https://wintouch.de/wp-content/uploads/2014/06/Postbank-Icon.png", Image: "https://wintouch.de/wp-content/uploads/2014/06/Postbank-Icon.png",
Link: "https://meine.postbank.de/#/login", Link: "https://meine.postbank.de/",
Color: "#ffcc00", Color: "#ffcc00",
}, },
{ {
@ -194,3 +197,11 @@ func ParseBookmarks() {
return Bookmarks[i].Order < Bookmarks[j].Order return Bookmarks[i].Order < Bookmarks[j].Order
}) })
} }
func (b *Bookmark) SmallLink() string {
lnk := b.Link
lnk = strings.TrimPrefix(lnk, "https://")
lnk = strings.TrimPrefix(lnk, "http://")
lnk = strings.TrimSuffix(lnk, "/")
return lnk
}

View File

@ -1,3 +0,0 @@
<svg class="icon logo inline"><use xlink:href="#RegExr">
<symbol id="RegExr" viewBox="0 0 64 64"><path d="M0 0v64h64V0H0zm23.799 52.045H11.783V40.029h12.016v12.016zm29.957-22.401l-5.396 5.235-6.765-11.033L34.67 35.12l-5.396-5.235 9.744-7.328-13.046-4.188 3.785-6.604 10.711 8.617L37.65 7.739h7.57l-2.899 12.643 10.791-8.617 3.785 6.604-12.804 4.027 9.663 7.248z"></path></symbol>
</use></svg>

Before

Width:  |  Height:  |  Size: 393 B

View File

@ -13,7 +13,12 @@
<main> <main>
<section id="search"> <section id="search">
<form method="post" action="/search"> <form method="post" action="/search">
<input type="search" id="query" placeholder='{{ .Translate "Search" }}' name="query" autofocus><label title="search" for="submit"><span class="material-icons">search</span></label> <datalist id="bookmarks">
{{ range .Bookmarks }}
<option value="{{ .SmallLink }}">
{{ end }}
</datalist>
<input type="search" id="query" list="bookmarks" placeholder='{{ .Translate "Search" }}' name="query" autofocus><label title="search" for="submit"><span class="material-icons">search</span></label>
<input id="submit" type="submit" title="search"> <input id="submit" type="submit" title="search">
</form> </form>
</section> </section>