3 <!-- Completely hide the TOC and the section numbers -->
4 <style type="text/css">
5 #TOC { display: none; }
6 .header-section-number { display: none; }
7 li {list-style-type: none; }
9 width: calc(100% - 100px);
14 #search-but, #search-input {
16 border: 1px solid #ccc;
20 background-color: #fff;
22 #search-but:hover, #search-input:focus {
23 border-color: #55a9ff;
32 Looks like you've taken a wrong turn.
34 Some things that might be helpful to you though:
39 <form id="search-form" action="https://duckduckgo.com/">
40 <input id="search-input" type="search" name="q"></input>
41 <input type="submit" value="Search" id="search-but">
43 Don't show the options by default,
44 since "From the Standary Library" doesn't work without JavaScript
46 <fieldset id="search-from" style="display:none">
47 <label><input name="from" value="library" type="radio"> From the Standard Library</label>
48 <label><input name="from" value="duckduckgo" type="radio" checked> From DuckDuckGo</label>
55 * [The Rust official site](https://www.rust-lang.org)
56 * [The Rust reference](https://doc.rust-lang.org/reference/index.html)
60 [The standard library](https://doc.rust-lang.org/std/)
63 function get_url_fragments() {
64 var last = document.URL.split("/").pop();
65 var tokens = last.split(".");
67 for (var i=0; i < tokens.length; i++) {
69 if (t == 'html' || t.indexOf("#") != -1) {
78 function on_submit(event) {
79 var form = event.target;
80 var q = form['q'].value;
82 event.preventDefault();
84 if (form['from'].value === 'duckduckgo') {
85 document.location.href = form.action + '?q=' + encodeURIComponent(q + ' site:doc.rust-lang.org');
86 } else if (form['from'].value === 'library') {
87 document.location.href = 'std/index.html?search=' + encodeURIComponent(q);
91 function populate_search() {
92 var form = document.getElementById('search-form');
93 form.addEventListener('submit', on_submit);
94 document.getElementById('search-from').style.display = '';
96 form['from'].value = 'library';
98 var op = get_url_fragments();
99 document.getElementById('search-input').value = op.join(' ');