Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions jquery.fastLiveFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jQuery.fn.fastLiveFilter = function(list, options) {
var input = this;
var timeout = options.timeout || 0;
var callback = options.callback || function() {};
var markFiltered = options.markFiltered || 0;

var keyTimeout;

Expand All @@ -25,7 +26,7 @@ jQuery.fn.fastLiveFilter = function(list, options) {
callback(len); // do a one-time callback on initialization to make sure everything's in sync

input.change(function() {
// var startTime = new Date().getTime();
//var startTime = new Date().getTime();
var filter = input.val().toLowerCase();
var li;
var numShown = 0;
Expand All @@ -35,16 +36,22 @@ jQuery.fn.fastLiveFilter = function(list, options) {
if (li.style.display == "none") {
li.style.display = oldDisplay;
}
if (markFiltered) {
jQuery(li).attr('data-fastlivefilter-shown', '1');
}
numShown++;
} else {
if (li.style.display != "none") {
li.style.display = "none";
}
if (markFiltered) {
jQuery(li).attr('data-fastlivefilter-shown', '0');
}
}
}
callback(numShown);
// var endTime = new Date().getTime();
// console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + ' (' + numShown + ' results)');
//var endTime = new Date().getTime();
//console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + ' (' + numShown + ' results)');
return false;
}).keydown(function() {
// TODO: one point of improvement could be in here: currently the change event is
Expand Down