skip redirect when searching (if javascript is available)
This commit is contained in:
parent
35b9973a4a
commit
d1007bb645
@ -317,7 +317,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="area-search">
|
<span class="area-search">
|
||||||
<form method="GET">
|
<form method="GET" id="search-form">
|
||||||
<input type="hidden" name="h" value="` + html.EscapeString(this.logBestSlug) + `">
|
<input type="hidden" name="h" value="` + html.EscapeString(this.logBestSlug) + `">
|
||||||
<input type="text" id="searchbox" name="q" value="` + html.EscapeString(this.query) + `" placeholder="Search..." accesskey="m" title="Search (Alt+M)">
|
<input type="text" id="searchbox" name="q" value="` + html.EscapeString(this.query) + `" placeholder="Search..." accesskey="m" title="Search (Alt+M)">
|
||||||
<input type="submit" value="»">
|
<input type="submit" value="»">
|
||||||
|
@ -101,6 +101,25 @@ function onLoad() {
|
|||||||
|
|
||||||
fontSize(0);
|
fontSize(0);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
var $form = document.getElementById("search-form");
|
||||||
|
$form.addEventListener("submit", function(ev) {
|
||||||
|
var query = $form.elements["q"].value;
|
||||||
|
if (query.length === 0) {
|
||||||
|
alert("No search text entered");
|
||||||
|
ev.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prefix = ($form.elements["rx"].checked ? "/rx/" : "/search/");
|
||||||
|
window.location.hash = "";
|
||||||
|
window.location.pathname = "/" + $form.elements["h"].value + prefix + encodeURIComponent(query);
|
||||||
|
|
||||||
|
ev.preventDefault();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', onLoad);
|
window.addEventListener('load', onLoad);
|
||||||
|
Loading…
Reference in New Issue
Block a user