1(function ($) { 2 3 $(document).ready(function () { 4 // Function to filter buses 5 function filterBuses_single() { 6 const selectedFilters = {}; 7 8 $('.filter-checkbox:checked').each(function () { 9 const filterKey = $(this).data('filter'); 10 const filterValue = $(this).val(); 11 selectedFilters[filterKey] = filterValue; 12 }); 13 14 // Iterate over each bus 15 $('.wbtm-bust-list').each(function () { 16 const $bus = $(this); 17 let showBus = true; 18 19 $.each(selectedFilters, function (key, value) { 20 if (key === "wbtm_start_route") { 21 const startRoute = $bus.find('input[name="wbtm_bus_start_route"]').val(); 22 if (startRoute !== value) { 23 showBus = false; 24 } 25 } 26 if (key === "wbtm_bus_name") { 27 const startName = $bus.find('input[name="wbtm_bus_name"]').val(); 28 if (startName !== value) { 29 showBus = false; 30 } 31 } 32 if (key === "wbtm_bus_type") { 33 const busType = $bus.find('input[name="wbtm_bus_type"]').val(); 34 if (busType !== value) { 35 showBus = false; 36 } 37 } 38 }); 39 40 if (showBus) { 41 $bus.fadeIn(1000); 42 } else { 43 $bus.fadeOut(500); 44 } 45 }); 46 } 47 48 function filterBuses( search_form, checkbox ) { 49 // alert( search_form ); 50 const selectedFilters = {}; 51 52 $('.' + checkbox + ':checked').each(function () { 53 // $('.filter-checkbox:checked').each(function () { 54 const filterKey = $(this).data('filter'); 55 const filterValue = $(this).val(); 56 57 if (!selectedFilters[filterKey]) { 58 selectedFilters[filterKey] = []; 59 } 60 selectedFilters[filterKey].push(filterValue); 61 }); 62 63 $('.'+search_form).each(function () { 64 const $bus = $(this); 65 let showBus = true; 66 67 $.each(selectedFilters, function (key, values) { 68 console.log( key ); 69 if (key === "wbtm_bus_start_route") { 70 let hasMatchingRoute = false; 71 $bus.find('input[name="wbtm_bus_start_route"]').each(function () { 72 const startRoute = $(this).val(); 73 if (values.includes(startRoute)) { 74 hasMatchingRoute = true; 75 return false; 76 } 77 }); 78 if (!hasMatchingRoute) { 79 showBus = false; 80 return false; 81 } 82 } 83 if (key === "wbtm_bus_name") { 84 const busName = $bus.find('input[name="wbtm_bus_name"]').val(); 85 if (!values.includes(busName)) { 86 showBus = false; 87 } 88 } 89 if (key === "wbtm_bus_type") { 90 const busType = $bus.find('input[name="wbtm_bus_type"]').val(); 91 if (!values.includes(busType)) { 92 showBus = false; 93 } 94 } 95 }); 96 97 // Show or hide the bus 98 if (showBus) { 99 $bus.fadeIn(600); 100 } else { 101 $bus.fadeOut(400); 102 } 103 }); 104 } 105 106 $(document).on('click', '.wbtm_reset_filter-checkbox', function() { 107 $('.filter-checkbox:checked').prop('checked', false); 108 $('.wbtm_bus_search_journey_start').fadeIn(600); 109 }); 110 111 $(document).on('click', '.wbtm_reset_return_filter-checkbox', function() { 112 $('.return_filter-checkbox:checked').prop('checked', false); 113 $('.wbtm_bus_search_journey_return').fadeIn(600); 114 }); 115 116 $(document).on('change', '.filter-checkbox', function() {
117 filterBuses( 'wbtm_bus_search_journey_start', 'filter-checkbox'); 118 // filterBuses_single(); 119 }); 120 $(document).on('change', '.return_filter-checkbox', function() { 121 filterBuses( 'wbtm_bus_search_journey_return', 'return_filter-checkbox'); 122 // filterBuses_single(); 123 }); 124 125 126 }); 127 128 129}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.