fix search
Anirudh Oppiliappan x@icyphox.sh
Sun, 11 Aug 2024 22:57:41 +0300
2 files changed,
20 insertions(+),
2 deletions(-)
M
views/header.html
→
views/header.html
@@ -83,8 +83,6 @@ </details>
{{ else }} <div id="topmenu"> <span><a id="homelink" href="/">home</a></span> - <span><a href="/o">tags</a></span> - <span><a href="/events">events</a></span> <span><a href="/about">about</a></span> {{ if .ShowRSS }} <span><a href="/rss">rss</a></span>
M
views/honkpage.html
→
views/honkpage.html
@@ -2,6 +2,26 @@ {{ template "header.html" . }}
<main> <div class="info" id="infobox"> <div id="srvmsg"> +<form action="/q" method="GET" id="searchform"> +<input type="text" name="q" autocomplete=off size=10 id="searchbox" placeholder="search"> + {{ if .Name }} + <script> + const searchBox = document.getElementById('searchbox'); + const searchForm = document.getElementById('searchform'); + + searchForm.addEventListener('submit', function(event) { + event.preventDefault(); + + let query = searchBox.value; + let newQuery = query + ' @self'; + + searchBox.value = newQuery; + + searchForm.submit(); + }); + </script> + {{ end }} +</form> <div> {{ if .Name }} <p>{{ .Name }} <span class="left1em"><a href="/u/{{ .Name }}/rss">rss</a></span>