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 class="area-search">
|
||||
<form method="GET">
|
||||
<form method="GET" id="search-form">
|
||||
<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="submit" value="»">
|
||||
|
@ -97,10 +97,29 @@ function onLoad() {
|
||||
highlightLine( parseInt(document.location.hash.substr(6), 10) );
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user