search.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $(document).ready(function() {
  2. var activeSystemClass = $('.list-group-item.active');
  3. //something is entered in search form
  4. $('#system-search').keyup( function() {
  5. var that = this;
  6. // affect all table rows on in systems table
  7. var tableBody = $('.table-list-search tbody');
  8. var tableRowsClass = $('.table-list-search tbody tr');
  9. $('.search-sf').remove();
  10. tableRowsClass.each( function(i, val) {
  11. //Lower text for case insensitive
  12. var rowText = $(val).text().toLowerCase();
  13. var inputText = $(that).val().toLowerCase();
  14. if(inputText !== '')
  15. {
  16. $('.search-query-sf').remove();
  17. tableBody.prepend('<tr class="search-query-sf"><td colspan="6" <div class="ffms-alert">Einträge mit <strong>"'
  18. + $(that).val()
  19. + '"</strong></div></td></tr>');
  20. }
  21. else
  22. {
  23. $('.search-query-sf').remove();
  24. }
  25. if( rowText.indexOf( inputText ) == -1 )
  26. {
  27. //hide rows
  28. tableRowsClass.eq(i).hide();
  29. }
  30. else
  31. {
  32. $('.search-sf').remove();
  33. tableRowsClass.eq(i).show();
  34. }
  35. });
  36. //all tr elements are hidden
  37. if(tableRowsClass.children(':visible').length === 0)
  38. {
  39. tableBody.append('<tr class="search-sf"><td class="text-muted" colspan="6">Kein Eintrag gefunden.</td></tr>');
  40. }
  41. });
  42. });