1jQuery(document).ready(function ($) { 2 // Datepicker 3 $(".datepicker-field").datepicker({ dateFormat: "yy-mm-dd" }); 4 $(".datepicker-icon").on("click", function () { 5 $(this).closest(".datepicker").find(".datepicker-field").focus(); 6 }); 7 8 // Show state with city in filters 9 function apflShowState() { 10 const show_state = $(".apfl-city-fltr").attr("data-show-state"); 11 12 if (show_state === "show") { 13 const cityStateMap = {}; 14 15 $(".listing-item .address").each(function () { 16 const address = $(this).text().trim(); 17 const match = address.match(/,\s*([\w\s]+),\s*([A-Z]{2})\s*\d{5}/); 18 19 if (match) { 20 const city = match[1].trim(); 21 const state = match[2].trim(); 22 cityStateMap[city] = state; 23 } 24 }); 25 26 const hiddenInput = $('input[name="orig_cities"]'); 27 const updatedOptions = []; 28 29 $(".apfl-city-fltr option").each(function () { 30 const city = $(this).text().trim(); 31 const value = $(this).val(); 32 const $option = $(this); 33 34 if (cityStateMap[city]) { 35 const state = cityStateMap[city]; 36 const displayText = `${city}, ${state}`; 37 $option.text(displayText); 38 $option.val(value); 39 updatedOptions.push( 40 $("<option>").val(value).text(displayText).prop("outerHTML") 41 ); 42 } else { 43 updatedOptions.push( 44 $("<option>").val(value).text(city).prop("outerHTML") 45 ); 46 } 47 }); 48 49 hiddenInput.val(updatedOptions.join("")); 50 } 51 } 52 53 apflShowState(); 54 55 $(".apfl-gallery .mySlides img").each(function () { 56 let str1 = $(this).attr("data-href"); 57 let data_id = $(this).attr("data-id"); 58 if (str1.indexOf("youtube") != -1) { 59 $(this) 60 .parent(".mySlides") 61 .append( 62 '<span class="gallery__video-label" data-href="' + 63 str1 + 64 '" data-id="' + 65 data_id + 66 '">►</span>' 67 ); 68 69 // const videoId = getId(str1); 70 // const iframeMarkup = '<iframe class="apfl-yt-frame" width="100%" height="100%" src="//www.youtube.com/embed/' + videoId + '?enablejsapi=1&version=3&playerapiid=ytplayer" frameborder="0" allowfullscreen></iframe>'; 71 // $(this).parent('.mySlides').append(iframeMarkup); 72 } 73 }); 74 75 // extract YT video ID 76 function getId(url) { 77 const regExp = 78 /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/; 79 const match = url.match(regExp); 80 81 return match && match[2].length === 11 ? match[2] : null; 82 } 83 84 // pause YT video on slide change 85 $(".apfl-gallery .next, .apfl-gallery .prev, .imgcolumn").on( 86 "click", 87 function () { 88 $(".apfl-yt-frame").each(function () { 89 $(this)[0].contentWindow.postMessage( 90 '{"event":"command","func":"' + "pauseVideo" + '","args":""}', 91 "*" 92 ); 93 }); 94 } 95 ); 96 97 // Gallery popup/lightbox 98 $( 99 ".apfl-gallery .mySlides img, .apfl-gallery .mySlides .gallery__video-label" 100 ).on("click", function () { 101 // let pp_html = '<div class="apfl_full_pp"><span class="close_apfl_pp">X</span>'; 102 let pp_html = 103 '<div class="apfl_full_pp"><span class="close_apfl_pp">' + 104 '<svg class="close-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">' + 105 '<path d="M16 16L12 12M12 12L8 8M12 12L16 8M12 12L8 16" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>' + 106 "</svg>" + 107 "</span>"; 108 109 let pp_slide = ""; 110 const pp_curr_slide_id = $(this).attr("data-id"); 111 112 $(".apfl-gallery .mySlides img").each(function () { 113 const full_src = $(this).attr("data-href"); 114 const pp_slide_id = $(this).attr("data-id"); 115 let current_slide = ""; 116 if (pp_curr_slide_id == pp_slide_id) { 117 current_slide = "current"; 118 } 119 if (full_src.indexOf("youtube") != -1) { 120 const videoId = getId(full_src); 121 pp_slide = 122 '<div id="' + 123 pp_slide_id + 124 '" class="afpl_pp_slide apfl_vid_container ' + 125 current_slide + 126 '"><iframe class="apfl-yt-frame" width="560" height="330" src="//www.youtube.com/embed/' + 127 videoId + 128 '?enablejsapi=1&version=3&playerapiid=ytplayer" frameborder="0" allowfullscreen></iframe></div>'; 129 } else { 130 pp_slide = 131 '<div id="' + 132 pp_slide_id + 133 '" class="afpl_pp_slide ' + 134 current_slide + 135 '"><img alt="slide-img" src="' + 136 full_src + 137 '"></div>'; 138 }
139 pp_html += pp_slide; 140 }); 141 // pp_html += '<span id="pp_prev">‹</span><span id="pp_next">›</span></div>'; 142 // $('body').append(pp_html); 143 pp_html += ` 144 <span id="pp_prev"> 145 <svg viewBox="0 0 24 24" fill="none" 146 xmlns="http://www.w3.org/2000/svg"> 147 <path d="M15 7L10 12L15 17" stroke="#ffffff" stroke-width="1.5" 148 stroke-linecap="round" stroke-linejoin="round"/> 149 </svg> 150 </span> 151 <span id="pp_next"> 152 <svg viewBox="0 0 24 24" fill="none" 153 xmlns="http://www.w3.org/2000/svg"> 154 <path d="M10 7L15 12L10 17" stroke="#ffffff" stroke-width="1.5" 155 stroke-linecap="round" stroke-linejoin="round"/> 156 </svg> 157 </span> 158</div>`; 159 160 $("body").append(pp_html); 161 }); 162 163 $("body").on("click", ".close_apfl_pp", function () { 164 $(".apfl_full_pp").remove(); 165 }); 166 167 $("body").on("click", "#pp_prev", function () { 168 pp_slideIndex = $(".afpl_pp_slide.current").attr("id"); 169 pp_slideIndex = parseInt(pp_slideIndex.replace("apfl_gal_img_", "")); 170 pp_showSlides((pp_slideIndex += -1)); 171 }); 172 $("body").on("click", "#pp_next", function () { 173 pp_slideIndex = $(".afpl_pp_slide.current").attr("id"); 174 pp_slideIndex = parseInt(pp_slideIndex.replace("apfl_gal_img_", "")); 175 pp_showSlides((pp_slideIndex += 1)); 176 }); 177 178 $(document).on("keydown", function (event) { 179 if ($(".apfl_full_pp").is(":visible")) { 180 switch (event.key) { 181 case "ArrowLeft": 182 pp_slideIndex = $(".afpl_pp_slide.current").attr("id"); 183 pp_slideIndex = parseInt(pp_slideIndex.replace("apfl_gal_img_", "")); 184 pp_showSlides((pp_slideIndex += -1)); 185 break; 186 case "ArrowRight": 187 pp_slideIndex = $(".afpl_pp_slide.current").attr("id"); 188 pp_slideIndex = parseInt(pp_slideIndex.replace("apfl_gal_img_", "")); 189 pp_showSlides((pp_slideIndex += 1)); 190 break; 191 } 192 } 193 }); 194 195 // Gallery popup slider 196 let pp_slideIndex = ""; 197 function pp_showSlides(n) { 198 var i; 199 var slides = document.getElementsByClassName("afpl_pp_slide"); 200 var dots = document.getElementsByClassName("demo"); 201 if (n > slides.length) { 202 pp_slideIndex = 1; 203 } 204 if (n < 1) { 205 pp_slideIndex = slides.length; 206 } 207 for (i = 0; i < slides.length; i++) { 208 // slides[i].style.display = "none"; 209 slides[i].className = slides[i].className.replace(" current", ""); 210 } 211 slides[pp_slideIndex - 1].className += " current"; 212 } 213 214 // Pagination 215 $(document).on("click", ".apfl-pagination a", function () { 216 var nextPage = parseInt($(this).attr("apfl-page")); 217 var total_pages = parseInt($(".apfl-pagination").attr("apfl-total-pages")); 218 219 $(".apfl-pagination a").removeClass("apfl-current-page"); 220 $('.apfl-pagination a[apfl-page="' + nextPage + '"]') 221 .not(".apfl-arrow") 222 .addClass("apfl-current-page"); 223 224 // Left arrow 225 if (nextPage > 1) { 226 $(".apfl-left-arrow") 227 .attr("apfl-page", nextPage - 1) 228 .removeClass("apfl-no-visibility"); 229 } else { 230 $(".apfl-left-arrow").addClass("apfl-no-visibility"); 231 } 232 233 // Left double arrow 234 if (nextPage > 5) { 235 $(".apfl-left-double-arrow").removeClass("apfl-no-visibility"); 236 } else { 237 $(".apfl-left-double-arrow").addClass("apfl-no-visibility"); 238 } 239 240 // Right arrow 241 if (nextPage < total_pages) { 242 $(".apfl-right-arrow") 243 .attr("apfl-page", nextPage + 1) 244 .removeClass("apfl-no-visibility"); 245 } else { 246 $(".apfl-right-arrow").addClass("apfl-no-visibility"); 247 } 248 249 // Right double arrow 250 if (nextPage < total_pages - 1) { 251 $(".apfl-right-double-arrow").removeClass("apfl-no-visibility"); 252 } else { 253 $(".apfl-right-double-arrow").addClass("apfl-no-visibility"); 254 } 255 256 // Update page numbers 257 258 // $('.apfl-pagination a').not('.apfl-arrow').addClass('apfl-hidden'); 259 260 for (i = 1; i <= total_pages; i++) { 261 if (nextPage <= 5) { 262 if (i <= 5) { 263 $('.apfl-pagination a[apfl-page="' + i + '"]') 264 .not(".apfl-arrow") 265 .removeClass("apfl-hidden"); 266 } else { 267 $('.apfl-pagination a[apfl-page="' + i + '"]') 268 .not(".apfl-arrow") 269 .addClass("apfl-hidden"); 270 } 271 } else { 272 $('.apfl-pagination a[apfl-page="' + nextPage + '"]') 273 .not(".apfl-arrow") 274 .removeClass("apfl-hidden"); 275 276 if (i <= nextPage - 5) { 277 $('.apfl-pagination a[apfl-page="' + i + '"]') 278 .not(".apfl-arrow") 279 .addClass("apfl-hidden"); 280 } else if (i > nextPage) { 281 $('.apfl-pagination a[apfl-page="' + i + '"]') 282 .not(".apfl-arrow") 283 .addClass("apfl-hidden"); 284 } else { 285 $('.apfl-pagination a[apfl-page="' + i + '"]') 286 .not(".apfl-arrow") 287 .removeClass("apfl-hidden"); 288 } 289 } 290 } 291 292 // if(nextPage < 5){ 293 // for (i = nextPage + 1; i <= total_pages - 5; i--) { 294 // $('.apfl-pagination a[apfl-page="' + i + '"]').not('.apfl-arrow').removeClass('apfl-hidden'); 295 // } 296 // } 297 298 // Load listings for the clicked page 299 loadListings(nextPage, "listings"); 300 }); 301 302 $(document).on("click", ".apfl-pagination-multiple a", function () { 303 var nextPage = $(this).attr("apfl-page"); 304 305 // Load listings for the clicked page 306 loadListings(nextPage, "multiple-listings"); 307 }); 308 309 function loadListings(page, type) { 310 var apfl_per_page = parseInt($(".apfl-pagination").attr("apfl-per-page")); 311 312 var previous_items = parseInt(apfl_per_page * (page - 1)); 313 314 $(".all-listings .listing-item").addClass("apfl-hidden"); 315 316 $(".all-listings .listing-item") 317 .slice(previous_items, previous_items + apfl_per_page) 318 .removeClass("apfl-hidden"); 319 } 320 321 // Share-buttons on single listing 322 $(".apfl-share-buttons").on("click", function (e) { 323 e.preventDefault(); 324 const site = $(this).attr("data-site"); 325 const url = encodeURIComponent(window.location.href); 326 const title = encodeURIComponent(document.title + "\n"); 327 let shareUrl = ""; 328 329 switch (site) { 330 case "twitter": 331 shareUrl = `https://twitter.com/share?url=${url}`; 332 window.open(shareUrl, "_blank", "width=600,height=400"); 333 break; 334 case "facebook": 335 shareUrl = `https://www.facebook.com/sharer/sharer.php?u=${url}`; 336 window.open(shareUrl, "_blank", "width=600,height=400"); 337 break; 338 case "pinterest": 339 shareUrl = `https://pinterest.com/pin/create/button/?url=${url}&description=${title}`; 340 window.open(shareUrl, "_blank", "width=600,height=400"); 341 break; 342 case "email": 343 shareUrl = `mailto:?subject=${title}&body=${url}`; 344 window.open(shareUrl, "_blank", "width=600,height=400"); 345 break; 346 case "copy": 347 navigator.clipboard 348 .writeText(window.location.href) 349 .then(() => { 350 alert("Link copied to clipboard!"); 351 }) 352 .catch((err) => { 353 console.error("Failed to copy text: ", err); 354 }); 355 } 356 }); 357});
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.