1 // Activate the search box:
3 var form = document.getElementById('chrome-docs-cse-search-form');
4 var searchInput = document.getElementById('chrome-docs-cse-input');
6 var cx = '010997258251033819707:7owyldxmpkc';
8 var gcse = document.createElement('script');
9 gcse.type = 'text/javascript';
11 gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
12 '//www.google.com/cse/cse.js?cx=' + cx;
13 var s = document.getElementsByTagName('script')[0];
14 s.parentNode.insertBefore(gcse, s);
16 var executeQuery = function(e) {
17 var element = google.search.cse.element.getElement('results');
18 if (searchInput.value == '') {
19 element.clearAllResults();
21 element.execute(searchInput.value);
27 form.addEventListener('submit', executeQuery);
29 // Attach autocomplete to the search box
30 var enableAutoComplete = function() {
31 console.log("running enableAutoComplete");
32 google.search.CustomSearchControl.attachAutoCompletionWithOptions(
33 cx, searchInput, form,
34 // set to true to prevent the search box form from being submitted, since
35 // the search control displaying the results is on the same page.
36 {'preferOnSubmitToSubmit': true}
40 var myAutocompleteCallback = function() {
41 // Search module is loaded.
42 if (document.readyState == 'complete') {
45 google.setOnLoadCallback(enableAutoComplete, true);
50 callback: myAutocompleteCallback
55 // End of autocomplete