From: Joey Schulze Date: Tue, 11 Jul 2017 21:29:43 +0000 (+0200) Subject: Improve table filtering, use keyup, improve alternating row background X-Git-Url: https://git.infodrom.org/?p=infodrom.org%2Fservice.infodrom.org;a=commitdiff_plain;h=d8dfd81b89ffbe5c1cfb17ce09c6d8b7bb6c9040 Improve table filtering, use keyup, improve alternating row background --- diff --git a/src/InfoCon/stempel/status.wml b/src/InfoCon/stempel/status.wml index 4497d1c..af5233b 100644 --- a/src/InfoCon/stempel/status.wml +++ b/src/InfoCon/stempel/status.wml @@ -310,19 +310,22 @@ function filter_change(e) var form = $(this).attr('id').split('_')[1]; var filter = $('input#filter_'+form).val(); + var cnum = 0; $('table#table_'+form+' tbody tr').each(function(i,e){ if (filter.length) { var td = $(this).find('td:nth-child(4)'); - if (td.text().toLowerCase().indexOf(filter) > -1) - $(this).show(); - else { + if (td.text().toLowerCase().indexOf(filter) > -1) { + $(this).removeClass('t0').removeClass('t1').addClass('t'+cnum).show(); + cnum = cnum ? 0 : 1; + } else { if ($(this).find('input[type="checkbox"]').prop('checked')) { toggle_checkbox(form, td); } $(this).hide(); } } else { - $(this).show(); + $(this).removeClass('t0').removeClass('t1').addClass('t'+cnum).show(); + cnum = cnum ? 0 : 1; } }); } @@ -330,11 +333,11 @@ function filter_change(e) function filter_clear(e) { var form = $(this).attr('id').split('_')[1]; - $('div.jscode input.filter#filter_'+form).val('').change(); + $('div.jscode input.filter#filter_'+form).val('').keyup(); } $(function(){ - $('div.jscode input.filter').change(filter_change); + $('div.jscode input.filter').keyup(filter_change); $('div.jscode img.filter').click(filter_clear); });