1jQuery(document).ready(function($) { 2 var resourceOffset = 12; // Initial offset for events 3 var limit = 12; // Number of events to load each time 4 5 // Handle the search form submission 6 $('#resource-location-search-form').on('submit', function(e) { 7 e.preventDefault(); 8 9 // Reset offset when a new search is performed 10 resourceOffset = limit; 11 12 // var locationSearch = $('#location_search').val(); 13 var resourceIndustryCat = $('#resource_industry_cat_search').val(); 14 var resourceTypeSearch = $('#resource_type_search').val(); // Get the selected resource type 15 // Show a loading indicator 16 $('#resource-results').html('<p>Loading resources...</p>'); 17 $('#resource-load-more-container').hide(); 18 $('#resource-load-more-button').prop('disabled', false).text('Load More'); 19 20 $.ajax({ 21 url: resources_search_ajax_obj.ajax_url, 22 type: 'POST', 23 data: { 24 action: 'resource_location_search', 25 // location_search: locationSearch, 26 resource_industry_cat_search: resourceIndustryCat, 27 resource_type_search: resourceTypeSearch, // Include resource type in the request 28 offset: 0, // Start from the beginning 29 limit: limit, 30 nonce: resources_search_ajax_obj.nonce, 31 }, 32 success: function(response) { 33 if (response.success) { 34 $('#resource-results').html(response.data.resources_html); 35 if (response.data.has_more) { 36 $('#resource-load-more-container').show(); 37 } else { 38 $('#resource-load-more-container').hide(); 39 } 40 // Update offset for the next batch 41 resourceOffset = limit; 42 } else { 43 $('#resource-results').html('<p>' + response.data + '</p>'); 44 $('#resource-load-more-container').hide(); 45 } 46 }, 47 error: function(xhr, status, error) { 48 console.log('AJAX Error:', error); 49 console.log('Response:', xhr.responseText); 50 $('#resource-results').html('<p>An error occurred while fetching events.</p><p>' + xhr.responseText + '</p>'); 51 $('#resource-load-more-container').hide(); 52 } 53 }); 54 }); 55 56 // Handle the Load More button click 57 $('#resource-load-more-button').on('click', function(e) { 58 e.preventDefault(); 59 60 // var locationSearch = $('#location_search').val(); 61 var resourceIndustryCat = $('#resource_industry_cat_search').val();// Get the selected resource industry category 62 var resourceTypeSearch = $('#resource_type_search').val(); // Get the selected resource type 63 64 // Show a loading indicator on the button 65 var $button = $(this); 66 $button.prop('disabled', true).text('Loading...'); 67 68 $.ajax({ 69 url: resources_search_ajax_obj.ajax_url, 70 type: 'POST', 71 data: { 72 action: 'resource_location_search_load_more', 73 // location_search: locationSearch, 74 resource_industry_cat_search: resourceIndustryCat, 75 resource_type_search: resourceTypeSearch, // Include resource type in the request 76 offset: resourceOffset, 77 limit: limit, 78 nonce: resources_search_ajax_obj.nonce, 79 }, 80 success: function(response) { 81 if (response.success) { 82 // Append the new events 83 $('#resource-results .resource-list').append(response.data.resources_html); 84 if (response.data.has_more) { 85 // Update offset for the next batch 86 resourceOffset += limit; 87 $button.prop('disabled', false).text('Load More'); 88 } else { 89 // No more events to load 90 $('#resource-load-more-container').hide(); 91 } 92 } else { 93 $('#resource-results').append('<p>' + response.data + '</p>'); 94 $button.prop('disabled', false).text('Load More'); 95 } 96 }, 97 error: function(xhr, status, error) { 98 console.log('AJAX Error:', error); 99 console.log('Response:', xhr.responseText); 100 $('#resource-results').append('<p>An error occurred while loading more events.</p><p>' + xhr.responseText + '</p>'); 101 $button.prop('disabled', false).text('Load More'); 102 } 103 }); 104 }); 105});
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.