@@ -1222,7 +1222,7 @@ function getSearchElement() {
1222
1222
}
1223
1223
dst = dst [ 0 ] ;
1224
1224
if ( window . location . pathname === dst . pathname ) {
1225
- addClass ( document . getElementById ( "search" ) , "hidden" ) ;
1225
+ addClass ( getSearchElement ( ) , "hidden" ) ;
1226
1226
removeClass ( main , "hidden" ) ;
1227
1227
document . location . href = dst . href ;
1228
1228
}
@@ -2458,7 +2458,7 @@ function getSearchElement() {
2458
2458
function putBackSearch ( search_input ) {
2459
2459
if ( search_input . value !== "" ) {
2460
2460
addClass ( main , "hidden" ) ;
2461
- removeClass ( document . getElementById ( "search" ) , "hidden" ) ;
2461
+ removeClass ( getSearchElement ( ) , "hidden" ) ;
2462
2462
if ( browserSupportsHistoryApi ( ) ) {
2463
2463
history . replaceState ( search_input . value ,
2464
2464
"" ,
@@ -2557,6 +2557,53 @@ function getSearchElement() {
2557
2557
}
2558
2558
2559
2559
window . addSearchOptions = addSearchOptions ;
2560
+
2561
+ function buildHelperPopup ( ) {
2562
+ var popup = document . createElement ( "aside" ) ;
2563
+ addClass ( popup , "hidden" ) ;
2564
+ popup . id = "help" ;
2565
+
2566
+ var container = document . createElement ( "div" ) ;
2567
+ var shortcuts = [
2568
+ [ "?" , "Show this help dialog" ] ,
2569
+ [ "S" , "Focus the search field" ] ,
2570
+ [ "↑" , "Move up in search results" ] ,
2571
+ [ "↓" , "Move down in search results" ] ,
2572
+ [ "↹" , "Switch tab" ] ,
2573
+ [ "⏎" , "Go to active search result" ] ,
2574
+ [ "+" , "Expand all sections" ] ,
2575
+ [ "-" , "Collapse all sections" ] ,
2576
+ ] . map ( x => "<dt><kbd>" + x [ 0 ] + "</kbd></dt><dd>" + x [ 1 ] + "</dd>" ) . join ( "" ) ;
2577
+ var div_shortcuts = document . createElement ( "div" ) ;
2578
+ addClass ( div_shortcuts , "shortcuts" ) ;
2579
+ div_shortcuts . innerHTML = "<h2>Keyboard Shortcuts</h2><dl>" + shortcuts + "</dl></div>" ;
2580
+
2581
+ var infos = [
2582
+ "Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to \
2583
+ restrict the search to a given type." ,
2584
+ "Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \
2585
+ <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, \
2586
+ and <code>const</code>." ,
2587
+ "Search functions by type signature (e.g., <code>vec -> usize</code> or \
2588
+ <code>* -> vec</code>)" ,
2589
+ "Search multiple things at once by splitting your query with comma (e.g., \
2590
+ <code>str,u8</code> or <code>String,struct:Vec,test</code>)" ,
2591
+ "You can look for items with an exact name by putting double quotes around \
2592
+ your request: <code>\"string\"</code>" ,
2593
+ "Look for items inside another one by searching for a path: <code>vec::Vec</code>" ,
2594
+ ] . map ( x => "<p>" + x + "</p>" ) . join ( "" ) ;
2595
+ var div_infos = document . createElement ( "div" ) ;
2596
+ addClass ( div_infos , "infos" ) ;
2597
+ div_infos . innerHTML = "<h2>Search Tricks</h2>" + infos ;
2598
+
2599
+ container . appendChild ( div_shortcuts ) ;
2600
+ container . appendChild ( div_infos ) ;
2601
+
2602
+ popup . appendChild ( container ) ;
2603
+ insertAfter ( popup , getSearchElement ( ) ) ;
2604
+ }
2605
+
2606
+ buildHelperPopup ( ) ;
2560
2607
} ( ) ) ;
2561
2608
2562
2609
// Sets the focus on the search bar at the top of the page
0 commit comments