The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | page.title=Search Results
|
| 2 | @jd:body
|
| 3 |
|
| 4 |
|
| 5 | <script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 6 | <script type="text/javascript">
|
| 7 | google.load('search', '1');
|
| 8 |
|
| 9 | // the cse class encapsulates a left and right search control
|
| 10 | // both controls are driven by a shared search form
|
| 11 | function cse() {
|
| 12 | var sFormDiv = document.getElementById("searchForm");
|
| 13 | var leftScDiv = document.getElementById("leftSearchControl");
|
| 14 |
|
| 15 | // create a left, right search control
|
| 16 | // create a custom search form
|
| 17 | this.leftControl = new google.search.SearchControl();
|
| 18 | this.searchForm = new google.search.SearchForm(true, sFormDiv);
|
| 19 |
|
| 20 | // bind clear and submit functions
|
| 21 | this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
|
| 22 | this.searchForm.setOnClearCallback(this, cse.prototype.onClear);
|
| 23 |
|
| 24 | // set up for small result sets
|
| 25 | this.leftControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
|
| 26 |
|
| 27 | var searcher;
|
| 28 | var options;
|
| 29 |
|
| 30 | // configure left control
|
| 31 | // Site Restrict to CSE ID for reviews
|
| 32 | searcher = new google.search.WebSearch();
|
| 33 | options = new google.search.SearcherOptions();
|
| 34 | //searcher.setSiteRestriction("000455696194071821846:reviews");
|
| 35 | //searcher.setUserDefinedLabel("Product Reviews");
|
| 36 | options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
|
| 37 | this.leftControl.addSearcher(searcher, options);
|
| 38 |
|
| 39 | // draw the left and right controls
|
| 40 | this.leftControl.draw(leftScDiv);
|
| 41 |
|
| 42 | // execute a starter search
|
| 43 | urlquery=location.href.split("?");
|
| 44 | urlterms=urlquery[1].split(",");
|
| 45 | document.getElementById("searchTitle").innerHTML = urlterms[0];
|
| 46 | this.searchForm.execute(urlterms[0]);
|
| 47 |
|
| 48 | }
|
| 49 |
|
| 50 | // when the form fires a submit, grab its
|
| 51 | // value and call the left and right control
|
| 52 | cse.prototype.onSubmit = function(form) {
|
| 53 | var q = form.input.value;
|
| 54 | if (q && q!= "") {
|
| 55 | this.leftControl.execute(q);
|
| 56 |
|
| 57 | document.getElementById("searchTitle").innerHTML = "search results for " + q;
|
| 58 | }
|
| 59 | return false;
|
| 60 | }
|
| 61 |
|
| 62 | // when the form fires a clear, call the left and right control
|
| 63 | cse.prototype.onClear = function(form) {
|
| 64 | //this.leftControl.clearAllResults();
|
| 65 | //form.input.value = "";
|
| 66 | document.getElementById("searchTitle").innerHTML = form.input.value;
|
| 67 | return false;
|
| 68 | }
|
| 69 |
|
| 70 | function OnLoad() {
|
| 71 | new cse();
|
| 72 | }
|
| 73 | google.setOnLoadCallback(OnLoad, true);
|
| 74 | </script>
|
| 75 |
|
| 76 | <div id="mainBodyFixed">
|
| 77 | <h2 id="searchTitle">search results</h2>
|
| 78 | <img src="{@docRoot}assets/images/hr_gray_main.jpg" />
|
| 79 | <div><br /></div>
|
| 80 | <div id="leftSearchControl" class="search-control">Loading...</div>
|
| 81 | </div>
|