Guest User

tabbed search

a guest
Mar 11th, 2010
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  2.     <script type="text/javascript">
  3.       google.load('search', '1');
  4.  
  5.       /**
  6.        * Extracts the users query from the URL.
  7.        */
  8.       function getQuery() {
  9.         var url = '' + window.location;
  10.         var queryStart = url.indexOf('?') + 1;
  11.         if (queryStart > 0) {
  12.           var parts = url.substr(queryStart).split('&');
  13.           for (var i = 0; i < parts.length; i++) {
  14.             if (parts[i][0] == 'q') {
  15.               return unescape(parts[i].split('=')[1]);
  16.             }
  17.           }
  18.         }
  19.         return '';
  20.       }
  21.  
  22.       function onLoad() {
  23.         // Create a custom search control that uses a CSE restricted to
  24.         // code.google.com
  25. //        var customSearchControl = new google.search.CustomSearchControl(            '012157912978810372049:-cv6ao3zqua');
  26.  
  27.         // REMOVED, TRYING TO REPLACE WITH TABS
  28.  
  29.         // Set drawing options to use our hidden input box.
  30.         // var drawOptions = new google.search.DrawOptions();
  31.         //drawOptions.setInput(document.getElementById('hidden-input'));
  32.  
  33.         // Draw the control in content div
  34.         //customSearchControl.draw('results', drawOptions);
  35.  
  36. //ADDED from http://www.google.com/uds/samples/apidocs/tabbed.html
  37.         // create a tabbed mode search control
  38.         var tabbed = new google.search.SearchControl();
  39.  
  40.         tabbed.addSearcher(new google.search.LocalSearch());
  41.         tabbed.addSearcher(new google.search.WebSearch());
  42.         tabbed.addSearcher(new google.search.BlogSearch());
  43.         tabbed.addSearcher(new google.search.NewsSearch());
  44.         tabbed.addSearcher(new google.search.BookSearch());
  45.         tabbed.addSearcher(new google.search.PatentSearch());
  46.  
  47.         // draw in tabbed layout mode
  48.         var drawOptions = new google.search.DrawOptions();
  49.         drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
  50.         tabbed.draw(document.getElementById("search_control_tabbed"), drawOptions);
  51.  
  52.  
  53. // RESUME original script
  54.         // Run a query
  55. //      alert(getQuery())
  56.         tabbed.execute(getQuery());
  57.       }
  58.  
  59.       google.setOnLoadCallback(onLoad);
  60.     </script>
Advertisement
Add Comment
Please, Sign In to add comment