The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame^] | 1 | page.title=Search Results
|
| 2 | @jd:body
|
| 3 |
|
| 4 | <script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 5 | <script src="/assets/jquery-history.js" type="text/javascript"></script>
|
| 6 | <script type="text/javascript">
|
| 7 | google.load('search', '1');
|
| 8 |
|
| 9 | function OnLoad() {
|
| 10 | document.getElementById("search_autocomplete").style.color = "#000";
|
| 11 |
|
| 12 | // create search control
|
| 13 | searchControl = new google.search.SearchControl();
|
| 14 |
|
| 15 | // use our existing search form and use tabs when multiple searchers are used
|
| 16 | drawOptions = new google.search.DrawOptions();
|
| 17 | drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
|
| 18 | drawOptions.setInput(document.getElementById("search_autocomplete"));
|
| 19 |
|
| 20 | // configure search result options
|
| 21 | searchOptions = new google.search.SearcherOptions();
|
| 22 | searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
|
| 23 |
|
| 24 | // configure each of the searchers, for each tab
|
| 25 | devSiteSearcher = new google.search.WebSearch();
|
| 26 | devSiteSearcher.setUserDefinedLabel("All Developers Site");
|
| 27 | devSiteSearcher.setSiteRestriction("http://developer.android.com/");
|
| 28 |
|
| 29 | devGuideSearcher = new google.search.WebSearch();
|
| 30 | devGuideSearcher.setUserDefinedLabel("Dev Guide");
|
| 31 | devGuideSearcher.setSiteRestriction("http://developer.android.com/guide/");
|
| 32 |
|
| 33 | referenceSearcher = new google.search.WebSearch();
|
| 34 | referenceSearcher.setUserDefinedLabel("Reference");
|
| 35 | referenceSearcher.setSiteRestriction("http://developer.android.com/reference/");
|
| 36 |
|
| 37 | blogSearcher = new google.search.WebSearch();
|
| 38 | blogSearcher.setUserDefinedLabel("Blog");
|
| 39 | blogSearcher.setSiteRestriction("http://android-developers.blogspot.com");
|
| 40 |
|
| 41 | groupsSearcher = new google.search.WebSearch();
|
| 42 | groupsSearcher.setUserDefinedLabel("Developer Groups");
|
| 43 | groupsSearcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
|
| 44 |
|
| 45 | sourceSiteSearcher = new google.search.WebSearch();
|
| 46 | sourceSiteSearcher.setUserDefinedLabel("Android Source");
|
| 47 | sourceSiteSearcher.setSiteRestriction("http://source.android.com");
|
| 48 |
|
| 49 | homeSiteSearcher = new google.search.WebSearch();
|
| 50 | homeSiteSearcher.setUserDefinedLabel("Android Home");
|
| 51 | homeSiteSearcher.setSiteRestriction("http://www.android.com");
|
| 52 |
|
| 53 | // add each searcher to the search control
|
| 54 | searchControl.addSearcher(devSiteSearcher, searchOptions);
|
| 55 | searchControl.addSearcher(devGuideSearcher, searchOptions);
|
| 56 | searchControl.addSearcher(referenceSearcher, searchOptions);
|
| 57 | searchControl.addSearcher(groupsSearcher, searchOptions);
|
| 58 | searchControl.addSearcher(sourceSiteSearcher, searchOptions);
|
| 59 | searchControl.addSearcher(blogSearcher, searchOptions);
|
| 60 |
|
| 61 | // configure result options
|
| 62 | searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
|
| 63 | searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
|
| 64 | searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_LONG);
|
| 65 | searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);
|
| 66 |
|
| 67 | // upon ajax search, refresh the url and search title
|
| 68 | searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
|
| 69 | $("#searchTitle").html("search results for <em>" + query + "</em>");
|
| 70 | $.history.add('q=' + query); // add the current query to the browser history
|
| 71 | });
|
| 72 |
|
| 73 | // draw the search results box
|
| 74 | searchControl.draw(document.getElementById("leftSearchControl"), drawOptions);
|
| 75 |
|
| 76 | // execute a search upon page load, from url hash query
|
| 77 | if (location.href.indexOf("#q=") != -1) {
|
| 78 | url = location.href.split("#q=");
|
| 79 | searchControl.execute(decodeURI(url[1]));
|
| 80 | }
|
| 81 | document.getElementById("search_autocomplete").focus();
|
| 82 | }
|
| 83 |
|
| 84 | google.setOnLoadCallback(OnLoad, true);
|
| 85 |
|
| 86 | // when an event on the browser history occurs (back, forward, load) perform a search
|
| 87 | $(window).history(function(e, hash) {
|
| 88 | hashParts = hash.split('=');
|
| 89 | searchControl.execute(decodeURI(hashParts[1]));
|
| 90 | $("#searchTitle").html("search results for <em>" + decodeURI(hashParts[1]) + "</em>");
|
| 91 | });
|
| 92 |
|
| 93 | // forcefully regain key-up event control (previously jacked by search api)
|
| 94 | $("#search_autocomplete").keyup(function(event) {
|
| 95 | return search_changed(event, false, '/');
|
| 96 | });
|
| 97 | </script>
|
| 98 |
|
| 99 | <div id="mainBodyFixed" style="width:auto; margin:20px">
|
| 100 | <h2 id="searchTitle">search results</h2>
|
| 101 | <img src="{@docRoot}assets/images/hr_gray_main.jpg" />
|
| 102 | <div><br /></div>
|
| 103 | <div id="leftSearchControl" class="search-control">Loading...</div>
|
| 104 | </div>
|