mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-12-04 20:25:57 +03:00
docs: add advanced search capabilities
Allow targetting the search scope to the website, wiki or mailing lists only. When javascript is disabled this should gracefully fallback to only searching the website. Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
@@ -22,4 +22,56 @@ function pageload() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Setting this class makes the advanced search options visible */
|
||||
advancedSearch = document.getElementById("advancedsearch")
|
||||
advancedSearch.className = "advancedsearch"
|
||||
|
||||
simpleSearch = document.getElementById("simplesearch")
|
||||
simplesearch.addEventListener("submit", advancedsearch)
|
||||
}
|
||||
|
||||
function advancedsearch(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
form = document.createElement("form");
|
||||
form.setAttribute("method", "get");
|
||||
|
||||
newq = document.createElement("input");
|
||||
newq.setAttribute("type", "hidden");
|
||||
form.appendChild(newq);
|
||||
|
||||
q = document.getElementById("searchq");
|
||||
whats = document.getElementsByName("what");
|
||||
what = "website";
|
||||
for (var i = 0; i < whats.length; i++) {
|
||||
if (whats[i].checked) {
|
||||
what = whats[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (what == "website") {
|
||||
form.setAttribute("action", "https://google.com/search");
|
||||
newq.setAttribute("name", "q");
|
||||
newq.value = "site:libvirt.org " + q.value;
|
||||
} else if (what == "wiki") {
|
||||
form.setAttribute("action", "https://wiki.libvirt.org/index.php");
|
||||
newq.setAttribute("name", "search");
|
||||
newq.value = q.value;
|
||||
} else if (what == "devs") {
|
||||
form.setAttribute("action", "https://google.com/search");
|
||||
newq.setAttribute("name", "q");
|
||||
newq.value = "site:redhat.com/archives/libvir-list " + q.value;
|
||||
} else if (what == "users") {
|
||||
form.setAttribute("action", "https://google.com/search");
|
||||
newq.setAttribute("name", "q");
|
||||
newq.value = "site:redhat.com/archives/libvirt-users " + q.value;
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user