Skip to content

Commit

Permalink
make crate selector more explanatory
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbinarycat committed Aug 30, 2024
1 parent 6f9fde6 commit 8a7ccbb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ table,
}
/* pseudo-element for holding the dropdown-arrow image; needs to be a separate thing
so that we can apply CSS-filters to change the arrow color in themes */
#crate-search-div::after {
#crate-search::after {
/* lets clicks through! */
pointer-events: none;
/* completely covers the underlying div */
Expand Down
17 changes: 9 additions & 8 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
* @param {boolean} go_to_first
* @param {string} filterCrates
*/
async function showResults(results, go_to_first, filterCrates) {
async function showResults(results, go_to_first, _filterCrates) {
const search = searchState.outputElement();
if (go_to_first || (results.others.length === 1
&& getSettingValue("go-to-only-result") === "true")
Expand Down Expand Up @@ -2815,9 +2815,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
}
}

let crates = "";

let output = `<h1 class="search-results-title">Results${crates}</h1>`;
let output = `<h1 class="search-results-title">Results</h1>`;
if (results.query.error !== null) {
const error = results.query.error;
error.forEach((value, index) => {
Expand Down Expand Up @@ -3880,16 +3878,19 @@ ${item.displayPath}<span class="${type}">${name}</span>\


console.log(rawSearchIndex);
let crates = "";
let crates = "Searching in ";
if (rawSearchIndex.size > 1) {
crates = "<div id=\"crate-search-div\"><select id=\"crate-search\">" +
crates += "<select id=\"crate-search\">" +
"<option value=\"all crates\" selected>all crates</option>";
for (const c of rawSearchIndex.keys()) {
console.log(c);
crates += `<option value="${c}">${c}</option>`;
}
crates += "</select></div>";
crates += "</select>";
} else {
crates += rawSearchIndex.keys().next().value;
}
document.getElementById("search-focus-panel").innerHTML = crates;
document.getElementById("crate-search-div").innerHTML = crates;
}

if (typeof window !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class RustdocSearchElement extends HTMLElement {
</div>
</form>
</nav>
<div id="search-focus-panel">loading crate list...</div>`;
<div id="search-focus-panel"><div id="crate-search-div">loading crate list...</div></div>`;
}
}
window.customElements.define("rustdoc-search", RustdocSearchElement);

0 comments on commit 8a7ccbb

Please sign in to comment.