@@ -13,9 +13,10 @@ Some things that might be helpful to you though:
13
13
14
14
## Search
15
15
* <form action =" https://duckduckgo.com/ " >
16
- <input type =" text " id =" code. search" name =" q " size =" 80 " ></input >
16
+ <input type =" text " id =" site- search" name =" q " size =" 80 " ></input >
17
17
<input type =" submit " value =" Search DuckDuckGo " >
18
18
</form >
19
+ * Rust doc search: <span id =" core-search " ></span >
19
20
20
21
## Reference
21
22
* [ The Rust official site] ( http://rust-lang.org )
@@ -25,19 +26,38 @@ Some things that might be helpful to you though:
25
26
* [ The standard library] ( http://doc.rust-lang.org/std/ )
26
27
27
28
<script >
28
- function populate_search_box () {
29
-
29
+ function get_url_fragments () {
30
30
var last = document .URL .split (" /" ).pop ();
31
31
var tokens = last .split (" ." );
32
32
var op = [];
33
33
for (var i= 0 ; i < tokens .length ; i++ ) {
34
- if (tokens[i].indexOf (" #" ) == - 1 )
35
- op .push (tokens[i]);
34
+ var t = tokens[i];
35
+ if (t == ' html' || t .indexOf (" #" ) != - 1 ) {
36
+ // no html or anchors
37
+ } else {
38
+ op .push (t);
39
+ }
36
40
}
41
+ return op;
42
+ }
37
43
38
- var search = document .getElementById (' code.search' );
44
+ function populate_site_search () {
45
+ var op = get_url_fragments ();
46
+
47
+ var search = document .getElementById (' site-search' );
39
48
search .value = op .join (' ' ) + " site:doc.rust-lang.org" ;
40
49
}
41
- populate_search_box ();
50
+
51
+ function populate_rust_search () {
52
+ var op = get_url_fragments ();
53
+ var lt = op .pop ();
54
+
55
+ // #18540, use a single token
56
+
57
+ var search = document .getElementById (' core-search' );
58
+ search .innerHTML = " <a href=\" http://doc.rust-lang.org/core/?search=" + lt + " \" >" + lt + " </a>" ;
59
+ }
60
+ populate_site_search ();
61
+ populate_rust_search ();
42
62
</script >
43
63
0 commit comments