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