1jQuery(document).ready(function($) { 2 3 function loadAllProgramsOnPageLoad() { 4 $('#programs-results').html('<p>Loading programs...</p>'); 5 6 $.ajax({ 7 url: programs_ajax.ajax_url, 8 type: 'GET', 9 data: { action: 'fetch_all_programs' }, 10 success: function(response) { 11 $('#programs-results').html(response || '<p>No programs available.</p>'); 12 }, 13 error: function() { 14 $('#programs-results').html('<p>Failed to load programs.</p>'); 15 } 16 }); 17 } 18 19 function applyFilters(params) { 20 params = params || {}; 21 params.action = 'filter_programs'; 22 23 $('#programs-results').html('<p>Loading results...</p>'); 24 25 $.ajax({ 26 url: programs_ajax.ajax_url, 27 type: 'GET', 28 data: params, 29 success: function(response) { 30 $('#programs-results').html(response || '<p>No programs found matching your criteria.</p>'); 31 }, 32 error: function() { 33 $('#programs-results').html('<p>Error while filtering programs. Please try again later.</p>'); 34 } 35 }); 36 } 37 38 function getFilterParams() { 39 const params = {}; 40 41 $('#programs-filter-form').find('input, select, textarea').each(function() { 42 const name = $(this).attr('name'); 43 const value = $(this).val(); 44 45 if (name && value) { 46 params[name] = value; 47 } 48 }); 49 50 return params; 51 } 52 53 function updateUrl(params) { 54 const queryString = $.param(params); 55 const newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + (queryString ? '?' + queryString : ''); 56 57 window.history.pushState({ path: newUrl }, '', newUrl); 58 } 59 60 function prefillFormFromUrl() { 61 const urlParams = new URLSearchParams(window.location.search); 62 63 if (urlParams.toString()) { 64 urlParams.forEach(function(value, key) { 65 const field = $('[name="' + key + '"]'); 66 67 if (field.length) { 68 field.val(value); 69 } 70 }); 71 72 applyFilters(Object.fromEntries(urlParams.entries())); 73 } else { 74 loadAllProgramsOnPageLoad(); 75 } 76 } 77 78 $('#programs-filter-form').on('submit', function(e) { 79 e.preventDefault(); 80 81 const params = getFilterParams(); 82 83 console.log('Filter params:', params); 84 console.log('State value:', $('#state').val()); 85 86 updateUrl(params); 87 applyFilters(params); 88 }); 89 90 $('#apply-filters').on('click', function(e) { 91 e.preventDefault(); 92 93 $('#programs-filter-form').trigger('submit'); 94 }); 95 96 $('#list-all-programs').on('click', function(e) { 97 e.preventDefault(); 98 99 $('#programs-filter-form')[0].reset(); 100 101 const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; 102 window.history.pushState({ path: cleanUrl }, '', cleanUrl); 103 104 loadAllProgramsOnPageLoad(); 105 }); 106 107 prefillFormFromUrl(); 108 109});
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.