mirror of
https://github.com/hkalexling/Mango.git
synced 2026-01-25 00:00:36 -05:00
- basic search functionality
This commit is contained in:
@@ -23,3 +23,6 @@
|
||||
.uk-logo > img {
|
||||
max-height: 90px;
|
||||
}
|
||||
.uk-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
30
public/js/search.js
Normal file
30
public/js/search.js
Normal file
@@ -0,0 +1,30 @@
|
||||
$(function(){
|
||||
var filter = [];
|
||||
var result = [];
|
||||
$('.uk-card-title').each(function(){
|
||||
filter.push($(this).text());
|
||||
});
|
||||
$('.uk-search-input').keyup(function(){
|
||||
var input = $('.uk-search-input').val();
|
||||
var regex = new RegExp(input, 'i');
|
||||
|
||||
if (input === '') {
|
||||
$('.item').each(function(){
|
||||
$(this).removeAttr('hidden');
|
||||
});
|
||||
}
|
||||
else {
|
||||
filter.forEach(function(text, i){
|
||||
result[i] = text.match(regex);
|
||||
});
|
||||
$('.item').each(function(i){
|
||||
if (result[i]) {
|
||||
$(this).removeAttr('hidden');
|
||||
}
|
||||
else {
|
||||
$(this).attr('hidden', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user