Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: chrome/common/extensions/docs/static/js/search.js

Issue 102593005: Clean patch with DCC static content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bumped versions of cron and app, so running server won't update Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/static/js/search.js
diff --git a/chrome/common/extensions/docs/static/js/search.js b/chrome/common/extensions/docs/static/js/search.js
new file mode 100644
index 0000000000000000000000000000000000000000..9abcd07640cfd960b9fb4c7dc08b4acf232ba625
--- /dev/null
+++ b/chrome/common/extensions/docs/static/js/search.js
@@ -0,0 +1,55 @@
+ // Activate the search box:
+ (function() {
+ var form = document.getElementById('chrome-docs-cse-search-form');
+ var searchInput = document.getElementById('chrome-docs-cse-input');
+
+ var cx = '010997258251033819707:7owyldxmpkc';
+
+ var gcse = document.createElement('script');
+ gcse.type = 'text/javascript';
+ gcse.async = true;
+ gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
+ '//www.google.com/cse/cse.js?cx=' + cx;
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(gcse, s);
+
+ var executeQuery = function(e) {
+ var element = google.search.cse.element.getElement('results');
+ if (searchInput.value == '') {
+ element.clearAllResults();
+ } else {
+ element.execute(searchInput.value);
+ }
+ e.preventDefault();
+ return true;
+ }
+
+ form.addEventListener('submit', executeQuery);
+
+ // Attach autocomplete to the search box
+ var enableAutoComplete = function() {
+ console.log("running enableAutoComplete");
+ google.search.CustomSearchControl.attachAutoCompletionWithOptions(
+ cx, searchInput, form,
+ // set to true to prevent the search box form from being submitted, since
+ // the search control displaying the results is on the same page.
+ {'preferOnSubmitToSubmit': true}
+ );
+ };
+
+ var myAutocompleteCallback = function() {
+ // Search module is loaded.
+ if (document.readyState == 'complete') {
+ enableAutoComplete();
+ } else {
+ google.setOnLoadCallback(enableAutoComplete, true);
+ }
+ };
+
+ window.__gcse = {
+ callback: myAutocompleteCallback
+ };
+
+ })();
+
+ // End of autocomplete

Powered by Google App Engine
This is Rietveld 408576698