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

Side by Side Diff: chrome/common/extensions/docs/static/js/samples.js

Issue 23526077: [DocServer] Fixed Sample Links (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed all feedback Created 7 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 var search_box = document.getElementById('search_input'); 6 var searchBox = document.getElementById('search_input');
7 var samples = document.getElementsByClassName('sample'); 7 var samples = document.getElementsByClassName('sample');
8 8
9 function filterSamples() { 9 function filterSamples() {
10 var search_text = search_box.value.toLowerCase(); 10 var searchText = searchBox.value.toLowerCase();
11 for (var i = 0; i < samples.length; ++i) { 11 for (var i = 0; i < samples.length; ++i) {
12 var sample = samples[i] 12 var sample = samples[i];
13 if (sample.getAttribute('tags').toLowerCase().indexOf(search_text) < 0) 13 var sampleTitle = sample.getElementsByTagName('h2')[0].textContent;
not at google - send to devlin 2013/09/25 17:33:08 I sure hope that sample.getElementsByTagName('h2')
François Beaufort 2013/09/26 10:27:28 You're right. I should check it's not empty. On 2
14 if (sample.getAttribute('tags').toLowerCase().indexOf(searchText) < 0 &&
15 sampleTitle.toLowerCase().indexOf(searchText) < 0)
14 sample.style.display = 'none'; 16 sample.style.display = 'none';
15 else 17 else
16 sample.style.display = ''; 18 sample.style.display = '';
17 } 19 }
18 } 20 }
19 search_box.addEventListener('search', filterSamples); 21 searchBox.addEventListener('search', filterSamples);
20 search_box.addEventListener('keyup', filterSamples); 22 searchBox.addEventListener('keyup', filterSamples);
21 23
22 var api_filter_items = document.getElementById('api_filter_items'); 24 var apiFilterItems = document.getElementById('api_filter_items');
23 api_filter_items.addEventListener('click', function(event) { 25 apiFilterItems.addEventListener('click', function(event) {
24 if (event.target instanceof HTMLAnchorElement) { 26 if (event.target instanceof HTMLAnchorElement) {
25 search_box.value = event.target.innerText; 27 searchBox.value = event.target.innerText;
26 filterSamples(); 28 filterSamples();
27 } 29 }
28 }); 30 });
29 })(); 31 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698