|
@ -21,9 +21,8 @@ var catalogSearch = function() { |
|
|
$controls.append($searchLabel) |
|
|
$controls.append($searchLabel) |
|
|
.append($searchBox); |
|
|
.append($searchBox); |
|
|
|
|
|
|
|
|
$searchBox.change(function() { |
|
|
$searchBox.keyup(function() { |
|
|
var query = new RegExp(this.value, 'm'), |
|
|
var $found = searchThreads($threads, this.value); |
|
|
$found = searchThreads($threads, query); |
|
|
|
|
|
$threads.hide(); |
|
|
$threads.hide(); |
|
|
$found.show(); |
|
|
$found.show(); |
|
|
}); |
|
|
}); |
|
@ -31,7 +30,8 @@ var catalogSearch = function() { |
|
|
|
|
|
|
|
|
// Filter threads by their content, given a regex. Can be extended later to load data
|
|
|
// Filter threads by their content, given a regex. Can be extended later to load data
|
|
|
// remotely and filter by multiple fields
|
|
|
// remotely and filter by multiple fields
|
|
|
var searchThreads = function($threads, re) { |
|
|
var searchThreads = function($threads, query) { |
|
|
|
|
|
var re = new RegExp(query, 'mi'); |
|
|
return $threads.filter(function() { |
|
|
return $threads.filter(function() { |
|
|
return re.test($('.replies', this).text()); |
|
|
return re.test($('.replies', this).text()); |
|
|
}); |
|
|
}); |
|
|