@@ -21,6 +21,20 @@ var Index = {};
2121 }
2222} ) ( Index ) ;
2323
24+ /** Find query string from URL */
25+ var QueryString = function ( key ) {
26+ if ( QueryString . map === undefined ) { // only calc once
27+ QueryString . map = { } ;
28+ var keyVals = window . location . search . split ( "?" ) . pop ( ) . split ( "&" ) ;
29+ keyVals . forEach ( function ( elem ) {
30+ var pair = elem . split ( "=" ) ;
31+ if ( pair . length == 2 ) QueryString . map [ pair [ 0 ] ] = pair [ 1 ] ;
32+ } ) ;
33+ }
34+
35+ return QueryString . map [ key ] ;
36+ } ;
37+
2438$ ( document ) . ready ( function ( ) {
2539 // Clicking #doc-title returns the user to the root package
2640 $ ( "#doc-title" ) . click ( function ( ) { document . location = toRoot + "index.html" } ) ;
@@ -39,6 +53,11 @@ $(document).ready(function() {
3953 else
4054 $ ( "#textfilter > .input > .clear" ) . hide ( ) ;
4155 } ) ;
56+
57+ if ( QueryString ( "search" ) !== undefined ) {
58+ $ ( "#index-input" ) . val ( QueryString ( "search" ) ) ;
59+ searchAll ( ) ;
60+ }
4261} ) ;
4362
4463/* Handles all key presses while scrolling around with keyboard shortcuts in search results */
@@ -515,6 +534,11 @@ function searchAll() {
515534 return ;
516535 }
517536
537+ // Replace ?search=X with current search string if not hosted locally on Chrome
538+ try {
539+ window . history . replaceState ( { } , "" , "?search=" + searchStr ) ;
540+ } catch ( e ) { }
541+
518542 $ ( "div#results-content > span.search-text" ) . remove ( ) ;
519543
520544 var memberResults = document . getElementById ( "member-results" ) ;
0 commit comments