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

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

Issue 10821073: Extensions Docs Server: Filter APIs UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unmove reference section 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/filter.js
diff --git a/chrome/common/extensions/docs/server2/static/js/filter.js b/chrome/common/extensions/docs/server2/static/js/filter.js
new file mode 100644
index 0000000000000000000000000000000000000000..02b5aa3dc1e0f9d8c8af8c7108f1b466fb86a235
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/static/js/filter.js
@@ -0,0 +1,35 @@
+// 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.
+
+// This is used for the search box on the left navigation bar. The APIs are
+// filtered and displayed based on what the user is typing in the box.
+(function() {
+ var search_box = document.getElementById('api_search');
+ var filtered_apis = document.getElementById('filtered_apis');
+
+ function filterAPIs() {
+ var search_text = search_box.value.toLowerCase();
+ var apis = window.bootstrap.api_names;
+ if (!search_text) {
+ filtered_apis.style.display = 'none';
+ return;
+ }
+ var api_list = ''
+ for (var i = 0; i < apis.length; ++i) {
+ if (apis[i].name.toLowerCase().indexOf(search_text) != -1)
+ api_list += '<li class="filtered_item"><a href="' + apis[i].name +
+ '.html">' + apis[i].name + '</a></li>'
+ }
+ if (api_list != filtered_apis.innerHtml)
+ filtered_apis.innerHTML = api_list;
+ if (!api_list)
+ filtered_apis.style.display = 'none';
+ else
+ filtered_apis.style.display = '';
+ }
+
+ filtered_apis.style.display = 'none';
+ search_box.addEventListener('search', filterAPIs);
+ search_box.addEventListener('keyup', filterAPIs);
+})();

Powered by Google App Engine
This is Rietveld 408576698