summaryrefslogtreecommitdiff
path: root/src/scaladoc
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2016-03-30 12:05:12 -0400
committerSeth Tisue <seth@tisue.net>2016-03-30 12:05:12 -0400
commitad35e02b2c13e6aff3fc4d263ccfacaf70d9ee4b (patch)
treedebb566b40f6aaf0dbd838df8d47632dd44a7842 /src/scaladoc
parent144979443dc7a5fbf3fede77a63e89725742cead (diff)
parent7822041205586ce909729a97f7bbcac8b871dffb (diff)
downloadscala-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
Diffstat (limited to 'src/scaladoc')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js24
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");