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

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: more 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..f1c38fd29a1dbf1defb927f423f34621033bc553
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/static/js/samples.js
@@ -0,0 +1,29 @@
+// 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 samples = document.getElementsByClassName('sample');
+
+ function filterSamples() {
+ var search_text = search_box.value.toLowerCase();
+ for (var i = 0; i < samples.length; ++i) {
+ var sample = samples[i]
+ if (sample.getAttribute('tags').indexOf(search_text) < 0)
+ sample.style.display = 'none';
+ else
+ sample.style.display = '';
+ }
+ }
+ search_box.addEventListener('search', filterSamples);
+ search_box.addEventListener('keyup', filterSamples);
+
+ var api_filter_items = document.getElementById('api_filter_items');
+ api_filter_items.addEventListener('click', function(event) {
+ if (event.target instanceof HTMLAnchorElement) {
+ search_box.value = 'chrome.' + event.target.innerText;
+ filterSamples();
+ }
+ });
+})();

Powered by Google App Engine
This is Rietveld 408576698