diff options
Diffstat (limited to 'docs/html/search.jd')
-rw-r--r-- | docs/html/search.jd | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/docs/html/search.jd b/docs/html/search.jd index 979964b..0a802a6 100644 --- a/docs/html/search.jd +++ b/docs/html/search.jd @@ -1,8 +1,8 @@ page.title=Search Results
@jd:body
-
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
+<script src="/assets/jquery-history.js" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
@@ -20,36 +20,80 @@ page.title=Search Results // configure search result options
searchOptions = new google.search.SearcherOptions();
searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
- searchOptions.setRoot(document.getElementById("leftSearchControl"));
- // configure searcher options
- searcher = new google.search.WebSearch();
- searcher.setUserDefinedLabel("Android Developers");
- searcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
+ // configure each of the searchers, for each tab
+ devSiteSearcher = new google.search.WebSearch();
+ devSiteSearcher.setUserDefinedLabel("All Developers Site");
+ devSiteSearcher.setSiteRestriction("http://developer.android.com/");
+
+ devGuideSearcher = new google.search.WebSearch();
+ devGuideSearcher.setUserDefinedLabel("Dev Guide");
+ devGuideSearcher.setSiteRestriction("http://developer.android.com/guide/");
+
+ referenceSearcher = new google.search.WebSearch();
+ referenceSearcher.setUserDefinedLabel("Reference");
+ referenceSearcher.setSiteRestriction("http://developer.android.com/reference/");
+
+ blogSearcher = new google.search.WebSearch();
+ blogSearcher.setUserDefinedLabel("Blog");
+ blogSearcher.setSiteRestriction("http://android-developers.blogspot.com");
+
+ groupsSearcher = new google.search.WebSearch();
+ groupsSearcher.setUserDefinedLabel("Developer Groups");
+ groupsSearcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
+
+ sourceSiteSearcher = new google.search.WebSearch();
+ sourceSiteSearcher.setUserDefinedLabel("Android Source");
+ sourceSiteSearcher.setSiteRestriction("http://source.android.com");
+
+ homeSiteSearcher = new google.search.WebSearch();
+ homeSiteSearcher.setUserDefinedLabel("Android Home");
+ homeSiteSearcher.setSiteRestriction("http://www.android.com");
- searchControl.addSearcher(searcher, searchOptions);
+ // add each searcher to the search control
+ searchControl.addSearcher(devSiteSearcher, searchOptions);
+ searchControl.addSearcher(devGuideSearcher, searchOptions);
+ searchControl.addSearcher(referenceSearcher, searchOptions);
+ searchControl.addSearcher(groupsSearcher, searchOptions);
+ searchControl.addSearcher(sourceSiteSearcher, searchOptions);
+ searchControl.addSearcher(blogSearcher, searchOptions);
+
+ // configure result options
searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
+ searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_LONG);
searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);
// upon ajax search, refresh the url and search title
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
- temp = location.href.split('#');
- url = temp ? temp[0] : location.href;
- location.href = url + '#q=' + query;
- document.getElementById("searchTitle").innerHTML = "search results for <em>" + query + "</em>"
+ $("#searchTitle").html("search results for <em>" + query + "</em>");
+ $.history.add('q=' + query); // add the current query to the browser history
});
- searchControl.draw(null, drawOptions);
+ // draw the search results box
+ searchControl.draw(document.getElementById("leftSearchControl"), drawOptions);
// execute a search upon page load, from url hash query
if (location.href.indexOf("#q=") != -1) {
url = location.href.split("#q=");
searchControl.execute(decodeURI(url[1]));
}
+ document.getElementById("search_autocomplete").focus();
}
google.setOnLoadCallback(OnLoad, true);
+
+ // when an event on the browser history occurs (back, forward, load) perform a search
+ $(window).history(function(e, hash) {
+ hashParts = hash.split('=');
+ searchControl.execute(decodeURI(hashParts[1]));
+ $("#searchTitle").html("search results for <em>" + decodeURI(hashParts[1]) + "</em>");
+ });
+
+ // forcefully regain key-up event control (previously jacked by search api)
+ $("#search_autocomplete").keyup(function(event) {
+ return search_changed(event, false, '/');
+ });
</script>
<div id="mainBodyFixed" style="width:auto; margin:20px">
|