cleaned up ids, added direct rust doc search
Search functionality uses both duckduckgo for site wide doc search and the rust specific documentation search @ http://doc.rust-lang.org/core/?search=unwrap_or_else
This commit is contained in:
parent
f878a883e5
commit
eca7ab508d
1 changed files with 27 additions and 7 deletions
|
@ -13,9 +13,10 @@ Some things that might be helpful to you though:
|
||||||
|
|
||||||
## Search
|
## Search
|
||||||
* <form action="https://duckduckgo.com/">
|
* <form action="https://duckduckgo.com/">
|
||||||
<input type="text" id="code.search" name="q" size="80"></input>
|
<input type="text" id="site-search" name="q" size="80"></input>
|
||||||
<input type="submit" value="Search DuckDuckGo">
|
<input type="submit" value="Search DuckDuckGo">
|
||||||
</form>
|
</form>
|
||||||
|
* Rust doc search: <span id="core-search"></span>
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
* [The Rust official site](http://rust-lang.org)
|
* [The Rust official site](http://rust-lang.org)
|
||||||
|
@ -25,19 +26,38 @@ Some things that might be helpful to you though:
|
||||||
* [The standard library](http://doc.rust-lang.org/std/)
|
* [The standard library](http://doc.rust-lang.org/std/)
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function populate_search_box() {
|
function get_url_fragments() {
|
||||||
|
|
||||||
var last = document.URL.split("/").pop();
|
var last = document.URL.split("/").pop();
|
||||||
var tokens = last.split(".");
|
var tokens = last.split(".");
|
||||||
var op = [];
|
var op = [];
|
||||||
for (var i=0; i < tokens.length; i++) {
|
for (var i=0; i < tokens.length; i++) {
|
||||||
if (tokens[i].indexOf("#") == -1)
|
var t = tokens[i];
|
||||||
op.push(tokens[i]);
|
if (t == 'html' || t.indexOf("#") != -1) {
|
||||||
|
// no html or anchors
|
||||||
|
} else {
|
||||||
|
op.push(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
var search = document.getElementById('code.search');
|
function populate_site_search() {
|
||||||
|
var op = get_url_fragments();
|
||||||
|
|
||||||
|
var search = document.getElementById('site-search');
|
||||||
search.value = op.join(' ') + " site:doc.rust-lang.org";
|
search.value = op.join(' ') + " site:doc.rust-lang.org";
|
||||||
}
|
}
|
||||||
populate_search_box();
|
|
||||||
|
function populate_rust_search() {
|
||||||
|
var op = get_url_fragments();
|
||||||
|
var lt = op.pop();
|
||||||
|
|
||||||
|
// #18540, use a single token
|
||||||
|
|
||||||
|
var search = document.getElementById('core-search');
|
||||||
|
search.innerHTML = "<a href=\"http://doc.rust-lang.org/core/?search=" + lt + "\">" + lt + "</a>";
|
||||||
|
}
|
||||||
|
populate_site_search();
|
||||||
|
populate_rust_search();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue