Skip to content

Commit 7fbcdc7

Browse files
add populated search box to docs 404 page
reference #18498
1 parent 0547a40 commit 7fbcdc7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/doc/not_found.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,33 @@ Looks like you've taken a wrong turn.
1111

1212
Some things that might be helpful to you though:
1313

14+
## Search
15+
* <form action="https://duckduckgo.com/">
16+
<input type="text" id="code.search" name="q" size="80"></input>
17+
<input type="submit" value="Search DuckDuckGo">
18+
</form>
19+
1420
## Reference
1521
* [The Rust official site](http://rust-lang.org)
1622
* [The Rust reference](http://doc.rust-lang.org/reference.html) (* [PDF](http://doc.rust-lang.org/reference.pdf))
1723

1824
## Docs
1925
* [The standard library](http://doc.rust-lang.org/std/)
26+
27+
<script>
28+
function populate_search_box() {
29+
30+
var last = document.URL.split("/").pop();
31+
var tokens = last.split(".");
32+
var op = [];
33+
for (var i=0; i < tokens.length; i++) {
34+
if (tokens[i].indexOf("#") == -1)
35+
op.push(tokens[i]);
36+
}
37+
38+
var search = document.getElementById('code.search');
39+
search.value = op.join(' ') + " site:doc.rust-lang.org";
40+
}
41+
populate_search_box();
42+
</script>
43+

0 commit comments

Comments
 (0)