X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fdoc%2Fnot_found.md;h=d26fcfc0168d7676138a74ac2ef336b115268b30;hb=787c458eeb20e447989124e2900e02e8e03b1c51;hp=f404aa046c1aecf52bb34b3e4d14d2eae7c9a8ce;hpb=3a0b65284686a5d984994708596d029267e7bf7b;p=rust.git diff --git a/src/doc/not_found.md b/src/doc/not_found.md index f404aa046c1..d26fcfc0168 100644 --- a/src/doc/not_found.md +++ b/src/doc/not_found.md @@ -5,6 +5,28 @@ #TOC { display: none; } .header-section-number { display: none; } li {list-style-type: none; } +#search-input { + width: calc(100% - 100px); +} +#search-but { + cursor: pointer; +} +#search-but, #search-input { + padding: 4px; + border: 1px solid #ccc; + border-radius: 3px; + outline: none; + font-size: 0.7em; + background-color: #fff; +} +#search-but:hover, #search-input:focus { + border-color: #55a9ff; +} +#search-from { + border: none; + padding: 0; + font-size: 0.7em; +} Looks like you've taken a wrong turn. @@ -13,11 +35,20 @@ Some things that might be helpful to you though: # Search -
- -
- -Rust doc search: +
+
+ + + + +
+
# Reference @@ -44,26 +75,28 @@ function get_url_fragments() { return op; } -function populate_site_search() { - var op = get_url_fragments(); +function on_submit(event) { + var form = event.target; + var q = form['q'].value; + + event.preventDefault(); - var search = document.getElementById('site-search'); - search.value = op.join(' ') + " site:doc.rust-lang.org"; + if (form['from'].value === 'duckduckgo') { + document.location.href = form.action + '?q=' + encodeURIComponent(q + ' site:doc.rust-lang.org'); + } else if (form['from'].value === 'library') { + document.location.href = 'std/index.html?search=' + encodeURIComponent(q); + } } -function populate_rust_search() { - var op = get_url_fragments(); - var lt = op.pop(); +function populate_search() { + var form = document.getElementById('search-form'); + form.addEventListener('submit', on_submit); + document.getElementById('search-from').style.display = ''; - // #18540, use a single token + form['from'].value = 'library'; - var a = document.createElement("a"); - a.href = "https://doc.rust-lang.org/core/?search=" + encodeURIComponent(lt); - a.textContent = lt; - var search = document.getElementById('core-search'); - search.innerHTML = ""; - search.appendChild(a); + var op = get_url_fragments(); + document.getElementById('search-input').value = op.join(' '); } -populate_site_search(); -populate_rust_search(); +populate_search();