提交 ec59a95a 编写于 作者: D Daniel P. Berrangé

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: NAndrea Bolognani <abologna@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 97e743ac
...@@ -22,4 +22,56 @@ function pageload() { ...@@ -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;
} }
...@@ -542,3 +542,42 @@ dl.mail dt a:hover { ...@@ -542,3 +542,42 @@ dl.mail dt a:hover {
td.enumvalue { td.enumvalue {
white-space: nowrap; white-space: nowrap;
} }
#advancedsearch {
display: none;
vertical-align: bottom;
position: absolute;
padding: 1em;
padding-top: 0em;
margin-top: 0em;
top: 100px;
right: 0px;
width: 13em;
text-align: left;
color: white;
background: rgb(0, 95, 97);
border-left: 3px solid rgb(60, 133, 124);
border-bottom: 3px solid rgb(60, 133, 124);
}
/* Use div.advancedsearch, not #advancedsearch because the
* 'advancedsearch' class is set dynamically when javascript
* loads. This ensures that the advancedsearch options are
* not displayed when javascript is disabled.
*/
#search:hover div.advancedsearch {
display: table;
}
#advancedsearch span {
display: block;
}
#advancedsearch input[type=radio] {
height: inherit;
display: inline;
}
#advancedsearch label {
display: inline;
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
margin: 0px; margin: 0px;
background: white; background: white;
padding: 0px; padding: 0px;
height: 2em;
} }
#search form { #search form {
padding: 5px; padding: 5px;
...@@ -91,4 +92,10 @@ ...@@ -91,4 +92,10 @@
float: none; float: none;
margin-bottom: 2em; margin-bottom: 2em;
} }
#advancedsearch {
margin-top: 4em;
border: 0px;
background: white;
color: black;
}
} }
...@@ -126,11 +126,19 @@ ...@@ -126,11 +126,19 @@
</ul> </ul>
</div> </div>
<div id="search"> <div id="search">
<form action="https://www.google.com/search" enctype="application/x-www-form-urlencoded" method="get"> <form id="simplesearch" action="https://www.google.com/search" enctype="application/x-www-form-urlencoded" method="get">
<input name="sitesearch" type="hidden" value="libvirt.org"/> <div>
<input name="q" type="text" size="12" value=""/> <input id="searchsite" name="sitesearch" type="hidden" value="libvirt.org"/>
<input type="submit" value="Go"/> <input id="searchq" name="q" type="text" size="12" value=""/>
<input name="submit" type="submit" value="Go"/>
</div>
</form> </form>
<div id="advancedsearch">
<span><input type="radio" name="what" id="whatwebsite" checked="checked" value="website"/><label for="whatwebsite">Website</label></span>
<span><input type="radio" name="what" id="whatwiki" value="wiki"/><label for="whatwiki">Wiki</label></span>
<span><input type="radio" name="what" id="whatdevs" value="devs"/><label for="whatdevs">Developers list</label></span>
<span><input type="radio" name="what" id="whatusers" value="users"/><label for="whatusers">Users list</label></span>
</div>
</div> </div>
</div> </div>
<div id="footer"> <div id="footer">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册