1jQuery(document).ready(function ($) { 2 let currentPage = 1; 3 let currentQuery = ""; 4 5 // ð Search button click 6 $('#articles_Search').on('click', function () { 7 currentQuery = $('#query_article').val(); 8 currentPage = 1; 9 10 // Reset page attr on button 11 $('#load-more-articles').attr('data-page', 1); 12 13 // Clear old results 14 $('#articles-container').html(''); 15 16 // Load search results 17 loadArticles(currentPage, currentQuery, true); 18 }); 19 20 // â¨ï¸ Trigger search on Enter key 21 $('#query_article').on('keypress', function (e) { 22 if (e.which === 13) { 23 $('#articles_Search').trigger('click'); 24 } 25 }); 26 27 // ð¥ Load More button 28 $('#load-more-articles').on('click', function () { 29 let button = $(this); 30 let page = parseInt(button.attr('data-page')) + 1; 31 currentPage = page; 32 33 loadArticles(page, currentQuery, false, button); 34 }); 35 36 // ð Reusable loader 37 function loadArticles(page, query, isSearch = false, button = null) { 38 $.ajax({ 39 url: load_more_params.ajaxurl, // â use localized var 40 type: 'POST', 41 data: { 42 action: 'load_more_articles', 43 page: page, 44 query: query, 45 nonce: load_more_params.nonce 46 }, 47 beforeSend: function () { 48 if (button) button.text('Loading...'); 49 }, 50 success: function (response) { 51 response = $.trim(response); 52 53 if (response !== '') { 54 if (page === 1) { 55 $('#articles-container').html(response); 56 } else { 57 $('#articles-container').append(response); 58 } 59 60 // â If returned posts < 6 â hide Load More 61 let postCount = (response.match(/class="col-md-6"/g) || []).length; 62 if (postCount < 6) { 63 $('#load-more-articles').hide(); 64 } else { 65 $('#load-more-articles').show(); 66 $('#load-more-articles').attr('data-page', page).text('Load More'); 67 } 68 } else { 69 if (isSearch) { 70 $('#articles-container').html('<p>No results found.</p>'); 71 } 72 $('#load-more-articles').hide(); 73 } 74 }, 75 error: function () { 76 if (button) button.text('Load More'); 77 } 78 }); 79 } 80});
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.