diff --git a/resources/views/index.php b/resources/views/index.php index 856f2b1f..c778a9f2 100644 --- a/resources/views/index.php +++ b/resources/views/index.php @@ -50,12 +50,26 @@ } }); + var rowsById = {}; + $('.table tbody tr').each(function() { + var id = $(this).attr('id').toLowerCase(); + rowsById[id] = $(this); + }); + + $('#search-field').keyup(function() { + var searchKey = $(this).val().toLowerCase(); + Object.keys(rowsById).forEach(function(key) { + rowsById[key].toggle(!searchKey || key.includes(searchKey)); + }); + }); + $("a.delete-key").click(function(event){ event.preventDefault(); var row = $(this).closest('tr'); var url = $(this).attr('href'); var id = row.attr('id'); $.post( url, {id: id}, function(){ + delete rowsById[id.toLowerCase()]; row.remove(); } ); }); @@ -227,7 +241,10 @@