diff options
Diffstat (limited to 'docs/html/search.jd')
-rw-r--r--[-rwxr-xr-x] | docs/html/search.jd | 92 |
1 files changed, 36 insertions, 56 deletions
diff --git a/docs/html/search.jd b/docs/html/search.jd index 9269d2c..979964b 100755..100644 --- a/docs/html/search.jd +++ b/docs/html/search.jd @@ -5,73 +5,53 @@ page.title=Search Results <script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
-
- // the cse class encapsulates a left and right search control
- // both controls are driven by a shared search form
- function cse() {
- var sFormDiv = document.getElementById("searchForm");
- var leftScDiv = document.getElementById("leftSearchControl");
- // create a left, right search control
- // create a custom search form
- this.leftControl = new google.search.SearchControl();
- this.searchForm = new google.search.SearchForm(true, sFormDiv);
+ function OnLoad() {
+ document.getElementById("search_autocomplete").style.color = "#000";
- // bind clear and submit functions
- this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
- this.searchForm.setOnClearCallback(this, cse.prototype.onClear);
+ // create search control
+ searchControl = new google.search.SearchControl();
- // set up for small result sets
- this.leftControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
+ // use our existing search form and use tabs when multiple searchers are used
+ drawOptions = new google.search.DrawOptions();
+ drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
+ drawOptions.setInput(document.getElementById("search_autocomplete"));
- var searcher;
- var options;
+ // configure search result options
+ searchOptions = new google.search.SearcherOptions();
+ searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
+ searchOptions.setRoot(document.getElementById("leftSearchControl"));
- // configure left control
- // Site Restrict to CSE ID for reviews
+ // configure searcher options
searcher = new google.search.WebSearch();
- options = new google.search.SearcherOptions();
- //searcher.setSiteRestriction("000455696194071821846:reviews");
- //searcher.setUserDefinedLabel("Product Reviews");
- options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
- this.leftControl.addSearcher(searcher, options);
-
- // draw the left and right controls
- this.leftControl.draw(leftScDiv);
-
- // execute a starter search
- urlquery=location.href.split("?");
- urlterms=urlquery[1].split(",");
- document.getElementById("searchTitle").innerHTML = urlterms[0];
- this.searchForm.execute(urlterms[0]);
-
- }
-
- // when the form fires a submit, grab its
- // value and call the left and right control
- cse.prototype.onSubmit = function(form) {
- var q = form.input.value;
- if (q && q!= "") {
- this.leftControl.execute(q);
-
- document.getElementById("searchTitle").innerHTML = "search results for \"" + q + "\"";
+ searcher.setUserDefinedLabel("Android Developers");
+ searcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
+
+ searchControl.addSearcher(searcher, searchOptions);
+ searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
+ searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
+ 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>"
+ });
+
+ searchControl.draw(null, 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]));
}
- return false;
}
- // when the form fires a clear, call the left and right control
- cse.prototype.onClear = function(form) {
- //this.leftControl.clearAllResults();
- //form.input.value = "";
- document.getElementById("searchTitle").innerHTML = form.input.value;
- return false;
- }
-
- function OnLoad() {
- new cse();
- }
google.setOnLoadCallback(OnLoad, true);
</script>
+
<div id="mainBodyFixed" style="width:auto; margin:20px">
<h2 id="searchTitle">search results</h2>
<img src="{@docRoot}assets/images/hr_gray_main.jpg" />
|