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

Side by Side Diff: chrome/common/extensions/docs/js/sample_search.js

Issue 5989011: Add hotlinks to individual samples in extension samples directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/common/extensions/docs/build
Patch Set: Display tweaks Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/docs/samples.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this 2 * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
3 * source code is governed by a BSD-style license that can be found in the 3 * source code is governed by a BSD-style license that can be found in the
4 * LICENSE file. 4 * LICENSE file.
5 */ 5 */
6 6
7 function testSearchSupport() { 7 function testSearchSupport() {
8 var i = document.createElement("input"); 8 var i = document.createElement("input");
9 i.setAttribute("type", "search"); 9 i.setAttribute("type", "search");
10 return i.type !== "text"; 10 return i.type !== "text";
11 }; 11 };
12 12
13 function filterSamples() { 13 function filterSamples() {
14 var clearlink = document.getElementById('clearlink'); 14 var clearlink = document.getElementById('clearlink');
15 var searchinput = document.getElementById('searchinput'); 15 var searchinput = document.getElementById('searchinput');
16 var noresults = document.getElementById('noresults'); 16 var noresults = document.getElementById('noresults');
17 17
18 var searchtext = searchinput.value.toUpperCase(); 18 var searchtext = searchinput.value.toUpperCase();
19 if (!canclear && searchtext != "" ) { 19 if (!canclear && searchtext != "" ) {
20 clearlink.style.display = "inline"; 20 clearlink.style.display = "inline";
21 } else { 21 } else {
22 clearlink.style.display = "none"; 22 clearlink.style.display = "none";
23 } 23 }
24 if (searchtext == currentfilter) { 24 if (searchtext == currentfilter) {
25 return; 25 return;
26 } else { 26 } else {
27 currentfilter = searchtext; 27 currentfilter = searchtext;
28 window.location.hash = searchinput.value;
28 } 29 }
29 30
30 noresults.style.display = 'none'; 31 noresults.style.display = 'none';
31 var num_found = 0; 32 var num_found = 0;
32 for (var key in search_data) { 33 for (var key in search_data) {
33 if (search_data.hasOwnProperty(key)) { 34 if (search_data.hasOwnProperty(key)) {
34 var sampleentry = document.getElementById(key); 35 var sampleentry = document.getElementById(key);
35 if (search_data[key].indexOf(searchtext) == -1) { 36 if (search_data[key].indexOf(searchtext) == -1) {
36 sampleentry.style.display = "none"; 37 sampleentry.style.display = "none";
37 } else { 38 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 searchinput.focus(); 71 searchinput.focus();
71 }; 72 };
72 73
73 function initSearch() { 74 function initSearch() {
74 var searchinput = document.getElementById('searchinput'); 75 var searchinput = document.getElementById('searchinput');
75 if (canclear) { 76 if (canclear) {
76 searchinput.addEventListener('click', filterSamples, false); 77 searchinput.addEventListener('click', filterSamples, false);
77 } 78 }
78 79
79 if (window.location.hash.length > 1) { 80 if (window.location.hash.length > 1) {
80 setFilter(window.location.hash.substring(1)); 81 var hash = window.location.hash.substring(1);
82 var elem = document.getElementById(hash);
83 if (elem) {
84 elem.scrollIntoView();
85 } else {
86 setFilter(hash);
87 }
81 } 88 }
82 }; 89 };
83 90
84 var currentfilter = ""; 91 var currentfilter = "";
85 var canclear = testSearchSupport(); 92 var canclear = testSearchSupport();
86 window.addEventListener('load', initSearch, false); 93 window.addEventListener('load', initSearch, false);
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/samples.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698