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

Unified Diff: chrome/common/extensions/docs/server2/static/js/samples.js

Issue 10809062: Extensions Docs Server: Samples search and icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 5 months 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/server2/static/js/samples.js
diff --git a/chrome/common/extensions/docs/server2/static/js/samples.js b/chrome/common/extensions/docs/server2/static/js/samples.js
new file mode 100644
index 0000000000000000000000000000000000000000..7a9efca053a8cc9c852f013d99ef71688f8f7c75
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/static/js/samples.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+(function() {
+ var search_box = document.getElementById('search_input');
+ var apis = document.getElementsByClassName('sample');
+ for (var i = 0; i < apis.length; ++i)
+ apis[i].tags = apis[i].getAttribute('tags').toUpperCase();
+
+ function filterSamples() {
+ var search_text = search_box.value.toUpperCase();
+ for (var i = 0; i < apis.length; ++i) {
+ if (apis[i].tags.indexOf(search_text) < 0)
+ apis[i].style.display = 'none';
+ else
+ apis[i].style.display = '';
+ }
+ }
+
+ function setFilter() {
+ search_box.value = 'chrome.' + this.innerHTML;
+ filterSamples();
+ }
+
+ var api_filter_items = document.getElementsByClassName('api_filter_item');
+ for (var i = 0; i < api_filter_items.length; ++i)
+ api_filter_items[i].addEventListener('click', setFilter, true);
+
+ search_box.onsearch = filterSamples;
+ search_box.onkeyup = filterSamples;
+})();

Powered by Google App Engine
This is Rietveld 408576698