diff options
author | Seth Tisue <seth@tisue.net> | 2016-03-30 12:05:12 -0400 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2016-03-30 12:05:12 -0400 |
commit | ad35e02b2c13e6aff3fc4d263ccfacaf70d9ee4b (patch) | |
tree | debb566b40f6aaf0dbd838df8d47632dd44a7842 | |
parent | 144979443dc7a5fbf3fede77a63e89725742cead (diff) | |
parent | 7822041205586ce909729a97f7bbcac8b871dffb (diff) | |
download | scala-ad35e02b2c13e6aff3fc4d263ccfacaf70d9ee4b.tar.gz scala-ad35e02b2c13e6aff3fc4d263ccfacaf70d9ee4b.tar.bz2 scala-ad35e02b2c13e6aff3fc4d263ccfacaf70d9ee4b.zip |
Merge pull request #5062 from felixmulder/topic/scaladoc-search-history
Add back to search for Scaladoc
-rw-r--r-- | src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js index 56eb060ccf..5d72b9bf71 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js @@ -21,6 +21,20 @@ var Index = {}; } })(Index); +/** Find query string from URL */ +var QueryString = function(key) { + if (QueryString.map === undefined) { // only calc once + QueryString.map = {}; + var keyVals = window.location.search.split("?").pop().split("&"); + keyVals.forEach(function(elem) { + var pair = elem.split("="); + if (pair.length == 2) QueryString.map[pair[0]] = pair[1]; + }); + } + + return QueryString.map[key]; +}; + $(document).ready(function() { // Clicking #doc-title returns the user to the root package $("#doc-title").click(function() { document.location = toRoot + "index.html" }); @@ -39,6 +53,11 @@ $(document).ready(function() { else $("#textfilter > .input > .clear").hide(); }); + + if (QueryString("search") !== undefined) { + $("#index-input").val(QueryString("search")); + searchAll(); + } }); /* Handles all key presses while scrolling around with keyboard shortcuts in search results */ @@ -515,6 +534,11 @@ function searchAll() { return; } + // Replace ?search=X with current search string if not hosted locally on Chrome + try { + window.history.replaceState({}, "", "?search=" + searchStr); + } catch(e) {} + $("div#results-content > span.search-text").remove(); var memberResults = document.getElementById("member-results"); |