Skip to content

Commit 3917430

Browse files
committed
Allow users to prefix searches with _.
1 parent 817bcee commit 3917430

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
var sections = document.querySelectorAll('.searchable_section');
44
var searchInput = document.getElementById('function_filter');
55

6+
function searchValue() {
7+
return searchInput.value.trim().replace(/^_\./, '');
8+
}
9+
610
function strIn(a, b) {
711
a = a.toLowerCase();
812
b = b.toLowerCase();
@@ -12,7 +16,8 @@
1216
function doesMatch(element) {
1317
var name = element.getAttribute('data-name');
1418
var aliases = element.getAttribute('data-aliases') || '';
15-
return strIn(searchInput.value, name) || strIn(searchInput.value, aliases);
19+
var value = searchValue();
20+
return strIn(value, name) || strIn(value, aliases);
1621
}
1722

1823
function filterElement(element) {
@@ -22,7 +27,7 @@
2227
function filterToc() {
2328
_.each(functions, filterElement);
2429

25-
var emptySearch = searchInput.value === '';
30+
var emptySearch = searchValue() === '';
2631

2732
// Hide the titles of empty sections
2833
_.each(sections, function(section) {
@@ -34,7 +39,7 @@
3439

3540
function gotoFirst() {
3641
var firstFunction = _.find(functions, doesMatch);
37-
if(firstFunction) {
42+
if (firstFunction) {
3843
window.location.hash = firstFunction.getAttribute('data-name');
3944
searchInput.focus();
4045
}

0 commit comments

Comments
 (0)