1jQuery(document).ready(function(){ 2 3 4 let filterTitles = jQuery(".sg_get_posts_filter_title"); 5 filterTitles.keyup(function(e) { 6 if (e.keyCode === 13) { 7 jQuery(this).click(); 8 } 9 }); 10 filterTitles.click(function(){ 11 //-->console.log("Toggle"); 12 let thisTitleBtn = jQuery(this); 13 let thisFilterItems = thisTitleBtn.parent().find(".sg_get_posts_filter_items"); 14 15 if(thisTitleBtn.hasClass("sg_get_posts_filter_closed")){ 16 thisFilterItems.slideDown(); 17 thisTitleBtn.addClass("active"); 18 thisTitleBtn.addClass("sg_get_posts_filter_open"); 19 thisTitleBtn.removeClass("sg_get_posts_filter_closed"); 20 } else { 21 thisFilterItems.slideUp(); 22 thisTitleBtn.removeClass("active"); 23 thisTitleBtn.addClass("sg_get_posts_filter_closed"); 24 thisTitleBtn.removeClass("sg_get_posts_filter_open"); 25 } 26 get_posts_refresh_datepicker(); 27 loadMoreGenerate(); 28 }) 29 30 31 let filterSelectBtns = jQuery(".sg_get_posts_filter_item"); 32 33 filterSelectBtns.keyup(function(e) { 34 if (e.keyCode === 13) { 35 jQuery(this).click(); 36 } 37 }); 38 let allPostblocks = jQuery(".sg-get-posts").find('.sg-content-postblock'); 39 filterSelectBtns.click(function(){ 40 jQuery(".no_posts_text").hide(); 41 //-->console.log("select"); 42 allPostblocks.show(); 43 let thisSelectBtn = jQuery(this); 44 let thisFilter = thisSelectBtn.attr("data-filter"); 45 let thisFilterId = thisSelectBtn.attr("data-filterid"); 46 //-->console.log("FILER:"+thisFilter+" FilterID"+thisFilterId) 47 allPostblocks.each(function(){ 48 let thisPostblock = jQuery(this); 49 let hideBlock = 1; 50 let thisDataAttr = thisPostblock.attr(thisFilter); 51 //-->console.log("POSTBLOCK DATA ATTR"+thisDataAttr); 52 if(thisDataAttr){ 53 if(thisDataAttr.includes(thisFilterId)){ 54 hideBlock = 0; 55 } 56 } 57 if(hideBlock){ 58 thisPostblock.hide(); 59 } 60 }); 61 get_posts_refresh_datepicker(); 62 loadMoreGenerate(); 63 64 }) 65 let resetButton = jQuery(".sg_get_posts_reset"); 66 resetButton.keyup(function(e) { 67 if (e.keyCode === 13) { 68 jQuery(this).click(); 69 } 70 }); 71 72 resetButton.click(function(){ 73 allPostblocks.show(); 74 get_posts_refresh_datepicker(); 75 loadMoreGenerate(); 76 jQuery(".no_posts_text").hide(); 77 }) 78 79 let keywordSearchInput = jQuery(".sg_get_posts_keyword_search"); 80 81 keywordSearchInput.bind("keyup change", function(e) { 82 let text_input = jQuery(e.target).val().replace(/\s+/g, '').toUpperCase() 83 allPostblocks.hide(); 84 allPostblocks.filter(function() { 85 return (jQuery(this).attr("data-tags").includes(text_input)) 86 87 }).css("display", "block"); 88 89 let anyVisible = allPostblocks.is(':visible'); 90 91 if (anyVisible) { 92 //-->console.log("At least one post block is visible"); 93 jQuery(".no_posts_text").hide(); 94 } else { 95 //-->console.log("No post blocks are visible"); 96 jQuery(".no_posts_text").show(); 97 } 98 99 get_posts_setup_datepicker(); 100 loadMoreGenerate(); 101 })
102 loadMoreGenerate(); 103 get_posts_setup_datepicker(); 104}) 105//when the blocks are more than 12 to a page, show the load more button and hide the rest 106function loadMoreGenerate() { 107 //-->console.log("loadMoreGenerate FIRE"); 108 109 // Loop through each .sg-get-posts section 110 jQuery('.sg-get-posts').each(function () { 111 const section = jQuery(this); 112 113 // Check for .hide-load-more inside this section 114 const blocksContainer = section.find('.sg-get-posts-blocks'); 115 if (blocksContainer.hasClass('hide-load-more')) { 116 //-->console.log("Skipping section due to hide-load-more"); 117 return; // Skip to next iteration 118 } 119 120 // Get the button and all post blocks inside this section 121 let loadMoreButton = section.find("#sg-get-posts-load-more"); 122 let loadMoreHidden = section.find(".load-more-hidden"); 123 loadMoreHidden.removeClass("load-more-hidden"); 124 125 // Select visible blocks only 126 const blocks = section.find('.sg-content-postblock').filter(function () { 127 return jQuery(this).css('display') !== 'none'; 128 }); 129 130 if (blocks.length <= 15) { 131 if (loadMoreButton.length) { 132 loadMoreButton.hide(); 133 } 134 return; // Stop here for this section 135 } 136 137 // Hide all blocks after the first 15 138 blocks.slice(15).addClass('load-more-hidden'); 139 140 if (loadMoreButton.length) { 141 loadMoreButton.show(); 142 } else { 143 addLoadMoreButton(); 144 } 145 }); 146} 147 148 149function loadMoreBlocks(){ 150 //-->console.log("loadMoreBlocks FIRE"); 151 // Select all blocks that are hidden by load more 152 const hiddenBlocks = Array.from(document.querySelectorAll('.sg-content-postblock.load-more-hidden')) 153 .filter(el => el.style.display !== 'none'); 154 155 // We'll show up to 12 more 156 for (let i = 0; i < 12 && i < hiddenBlocks.length; i++) { 157 hiddenBlocks[i].classList.remove('load-more-hidden'); 158 } 159 160 // If there are no more hidden blocks, hide the load more button 161 if (document.querySelectorAll('.sg-content-postblock.load-more-hidden').length === 0) {
162 const loadMoreBtn = document.getElementById('sg-get-posts-load-more'); 163 if (loadMoreBtn) { 164 loadMoreBtn.style.display = 'none'; 165 } 166 } 167} 168 169 170function addLoadMoreButton() { 171 //-->console.log("addLoadMoreButton FIRE"); 172 // Select the container 173 const container = document.querySelector('.sg-get-posts'); 174 if (container) { 175 // Create a wrapper for centering 176 const wrapper = document.createElement('div'); 177 wrapper.className = 'load-more-wrapper w-100 d-flex justify-content-center align-items-center'; 178 179 // Create the button 180 const button = document.createElement('button'); 181 button.textContent = 'Load more'; 182 button.id = 'sg-get-posts-load-more'; 183 button.className = 'btn sg-secondary btn-lg'; 184 button.onclick = loadMoreBlocks; 185 186 // Append the button to the wrapper and then to the container 187 wrapper.appendChild(button); 188 container.appendChild(wrapper); 189 } else { 190 console.warn('Container .sg-get-posts not found.'); 191 } 192} 193 194function get_posts_setup_datepicker() { 195 //---sglog("Setup Datepicker") 196 197 let datepicker_cont = jQuery("#datepicker"); 198 199 if(!datepicker_cont.length){ 200 return; 201 } 202 203 datepicker_cont.html='<div>Date filter loading <i className="fas fa-spinner fa-pulse"></i></div>'; 204 205 let dates = []; 206 jQuery('.whatson_show').each(function () { 207 if(jQuery(this).css('display') !== 'none') 208 { 209 // //---sglog("adding this to datepicker"+jQuery(this).data("tags")); 210 jQuery(this).data("dates").forEach(function (data) { 211 212 dates.push(data); 213 }) 214 } 215 216 }); 217 218 let datesInText = ""; 219 let datecount = 1; 220 dates.forEach(function(individualdate){ 221 datesInText += individualdate; 222 if(datecount !== dates.length){ 223 datesInText += ","; 224 } 225 datecount++; 226 }); 227 //---sglog("DATESSS::"); 228 //---sglog(datesInText); 229 //---sglog("DATA::"); 230 231 232 //---sglog("Running ajax") 233 let datepicker_row_id = datepicker_cont.attr("data-rowid"); 234 jQuery.ajax({ 235 type: "POST", 236 url:"/wp-admin/admin-ajax.php", 237 dataType: 'json', 238 data: { 239 action: 'allydatepickershortcode', 240 theid: "whatson-ally-datepicker", 241 dates: datesInText, 242 therowid: datepicker_row_id, 243 }, 244 error: function (xhr, ajaxOptions, thrownError) { 245 //---sglog(xhr.status); 246 //---sglog(thrownError); 247 } 248 }).done(function (json) { 249 //---sglog("COMPLETE") 250 //---sglog(json) 251 jQuery("#datepicker").html(jQuery.parseJSON(json["data"])); 252 get_posts_refresh_datepicker(); 253 // setTimeout(refresh_datepicker,1500); 254 }); 255 256 257 258} 259 260function get_posts_refresh_datepicker(){ 261 //---sglog("Refresh Ally DP") 262 var datePickers = document.querySelectorAll('.datepicker'); 263 264 if(!datePickers.length){ 265 return; 266 } 267 268 datePickers.forEach(function (dp) { 269 new DatePickerDialog(dp); 270 }); 271} 272
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.