Skip to content

Commit

Permalink
refactor matching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
afeld committed Jun 25, 2018
1 parent e133bc0 commit 3086fc7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ $(function() {

function isElementMatching(element, needle) {
var name = $(element).text().toLowerCase();
var alternatives = element.attr("data-alternative-names");
return (
// name match
name.indexOf(needle) >= 0 ||
// class match
('em-' + name).indexOf(needle) >= 0 ||
// alt match
(alternatives != null && alternatives.toLowerCase().indexOf(needle) >= 0)
);
var alternatives = element.attr("data-alternative-names") || '';
var possibilities = [name, 'em-' + name, alternatives];
return possibilities.some(function(e) {
return e.indexOf(needle) >= 0;
});
}

function highlightElements(needle) {
Expand Down

0 comments on commit 3086fc7

Please sign in to comment.