Skip to content

Commit

Permalink
0.2.1. Remove unused feature. Use a faster function
Browse files Browse the repository at this point in the history
  • Loading branch information
glebkema committed Oct 2, 2021
1 parent 9b7d3ce commit 524427a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jquery-search-among.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* jQuery Search Among Plugin
* https://github.com/glebkema/jquery-search-among
*
* Version: 0.2.0
* Version: 0.2.1
*
* Copyright Gleb Kemarsky
* Released under the MIT license.
Expand All @@ -14,17 +14,17 @@
let oldSearch = '';

$(this).on('input', function() {
let newSearch = this.value.replace(/[_-]+/g, ' ').trim(); // separate words with a space, minus or underscore
let newSearch = this.value.trim().toLowerCase();
if (newSearch !== oldSearch) {
oldSearch = newSearch;
if (newSearch) {
let words = newSearch.toLowerCase().split(/\s+/);
let words = newSearch.split(/\s+/);
let count = words.length;
for (let item of $items) {
let text = $(item).text().toLowerCase();
let is_visible = true;
for (let i = 0; i < count; i++) {
if (! text.includes(words[i])) {
if (-1 === text.indexOf(words[i])) {
is_visible = false;
break;
}
Expand Down

0 comments on commit 524427a

Please sign in to comment.