dropdown menu filter method modified

intermediate match & case insensitive not using regexp
This commit is contained in:
Yasuhiro Takagi
2017-04-28 21:05:44 +09:00
parent 46896da46e
commit e33e304644
3 changed files with 3 additions and 6 deletions

View File

@@ -49,10 +49,7 @@ $(function(){
$('#filter-box').keyup(function(){ $('#filter-box').keyup(function(){
var inputVal = $('#filter-box').val(); var inputVal = $('#filter-box').val();
$.each($('li.repo-link a'), function(index, elem) { $.each($('li.repo-link a'), function(index, elem) {
console.log(inputVal); if ( !inputVal || !elem.text.trim() || elem.text.trim().toLowerCase().indexOf(inputVal.toLowerCase()) >= 0 ) {
console.log(elem.text.trim());
console.log(elem.text.trim().lastIndexOf(inputVal, 0));
if (!inputVal || !elem.text.trim() || elem.text.trim().indexOf(inputVal) >= 0) {
$(elem).parent().show(); $(elem).parent().show();
} else { } else {
$(elem).parent().hide(); $(elem).parent().hide();

View File

@@ -31,7 +31,7 @@
$('#branch-control-input').keyup(function() { $('#branch-control-input').keyup(function() {
var inputVal = $('#branch-control-input').val(); var inputVal = $('#branch-control-input').val();
$.each($('#branch-control-input').parent().parent().find('a'), function(index, elem) { $.each($('#branch-control-input').parent().parent().find('a'), function(index, elem) {
if (!inputVal || !elem.text.trim() || elem.text.trim().match(new RegExp(inputVal,'i'))) { if (!inputVal || !elem.text.trim() || elem.text.trim().toLowerCase().indexOf(inputVal.toLowerCase()) >= 0) {
$(elem).parent().show(); $(elem).parent().show();
} else { } else {
$(elem).parent().hide(); $(elem).parent().hide();

View File

@@ -32,7 +32,7 @@ $(function(){
$('#@{filter}-input').keyup(function() { $('#@{filter}-input').keyup(function() {
var inputVal = $('#@{filter}-input').val(); var inputVal = $('#@{filter}-input').val();
$.each($('#@{filter}-input').parent().parent().find('a'), function(index, elem) { $.each($('#@{filter}-input').parent().parent().find('a'), function(index, elem) {
if (!inputVal || !elem.text.trim() || elem.text.trim().lastIndexOf(inputVal, 0) >= 0) { if ( !inputVal || !elem.text.trim() || elem.text.trim().toLowerCase().indexOf(inputVal.toLowerCase()) >=0 ) {
$(elem).parent().show(); $(elem).parent().show();
} else { } else {
$(elem).parent().hide(); $(elem).parent().hide();