1let total_images = 0, 2carDetailSwiper = null, 3limit = 0, 4offset = 0, 5offset1 = 0, 6listing_tags = [ 7 { name: 'og:title', value: ''}, 8 { name: 'og:description', value: ''}, 9 { name: 'og:image', value: ''}, 10 { name: 'og:image:type', value: ''}, 11 { name: 'og:url', value: ''}, 12], 13listing_title_tag = '', 14 15getDetailed = (e, id) => { 16 if (e) 17 e.preventDefault(); 18 19 vid = id.match(/-c-(\d*)\//)[1]; 20 21 $('#header').addClass('sticky'); 22 23 // Create a loading indicator 24 const loadingHTML = '<div class="loading-spinner" style="text-align:center;padding:100px 0;"><i class="fa fa-spinner fa-spin fa-3x"></i><p>Loading vehicle details...</p></div>'; 25 26 // Reset detailed page to loading state and ensure wrapper is ready 27 $('#detailed_page').html(loadingHTML); 28 $('#detailed_page_wrapper').css({ 29 'display': 'block', 30 'opacity': '0' 31 }); 32 33 // Fetch the data 34 $.get("/api/cars/" + vid).done(function(text) { 35 let detailed_title_tags = text.split("\n")[0], 36 tags = JSON.parse(detailed_title_tags); 37 38 text = text.replace(detailed_title_tags, ''); 39 40 // Analytics: trigger pageview for VDP open via AJAX navigation 41 try { 42 if (typeof sd === 'function') { 43 var payload = { 44 pageType: 'Vehicle Details', 45 websiteTier: 'Tier 3', 46 pageBrand: 'Ferrari', 47 sessionId: (window.sdSessionId || ''), 48 language: 'en', 49 dealerBrand: (window.sdDealerBrand || ''), 50 dealerZipCode: (window.sdDealerZipCode || ''), 51 dealerState: (window.sdDealerState || ''), 52 dealerCity: (window.sdDealerCity || ''), 53 dealerName: (window.sdDealerName || ''), 54 dealerTda: (window.sdDealerTda || ''), 55 dealerBac: (window.sdDealerBac || ''), 56 siteTechnologyVersion: '2.0031', 57 userZipCode: (window.sdUserZipCode || ''), 58 userCity: (window.sdUserCity || ''), 59 userState: (window.sdUserState || ''), 60 vehicleDetails: {} 61 }; 62 // Try to derive year/make/model/trim from og:title if present 63 var title = (tags && tags['og:title']) ? tags['og:title'] : ''; 64 var m = title && title.match(/(\d{4})\s+([^\s]+)\s+([^\s]+)\s*(.*)?/); 65 if (m) { 66 payload.vehicleDetails.year = m[1] || ''; 67 payload.vehicleDetails.make = m[2] || ''; 68 payload.vehicleDetails.model = m[3] || ''; 69 if (m[4]) { 70 payload.vehicleDetails.trim = m[4].split('|')[0].trim(); 71 } 72 } 73 sd('dataLayer', payload); 74 sd('send', 'pageview'); 75 } 76 } catch(e) {} 77 78 // Now that we have the content, do the transition 79 $('#detailed_page').html(text); 80 81 // Force layout calculation before animation 82 $('#detailed_page')[0].offsetHeight; 83 84 // Now fade out the main page and fade in the detailed page 85 $('#page').fadeTo('slow', 0, function() { 86 $(this).css('display', 'none'); 87 88 // Fade in the detailed page 89 $('#detailed_page_wrapper').fadeTo('slow', 1, function() { 90 // Ensure footer is displayed 91 $('#footer').css('display', 'block'); 92 // Scroll to top when transition completes 93 window.scrollTo(0, 0); 94 }); 95 96 // Update browser history and meta 97 is_listing_page = false; 98 let new_hash = id; 99 loc_tion = current_listing; 100 loc_tion = loc_tion.split('/'); 101 url = "https://" + loc_tion[2] + new_hash; 102 103 if (new_hash.match(/^xxx/) == null) { 104 window.history.pushState({}, null, url); 105 } 106 listing_tags.map((val, k) => { 107 let tag_value = val.name == 'og:url' ? url : tags[val.name]; 108 listing_tags[k].value = $('meta[property="' + val.name + '"]').attr('content'); 109 $('meta[property="' + val.name + '"]').attr('content', tag_value); 110 if (val.name == 'og:description') { 111 $('meta[name="description"]').attr('content', tag_value); 112 } 113 }); 114 $('link[rel="canonical"]').attr('href', url); 115 document.title = tags['og:title']; 116 117 // Initialize the detailed view 118 datailedInit(); 119 }); 120 }).fail(function(jqXHR, textStatus, errorThrown) { 121 console.error("Request failed: " + textStatus); 122 console.error("Error thrown: " + errorThrown); 123 124 // Restore main page if loading fails 125 $('#detailed_page_wrapper').css('display', 'none'); 126 $('#page').css({ 127 'opacity': '1', 128 'display': 'block' 129 }); 130 }); 131}, 132mainSliderHeightAdjust = () => { 133 var smallest = 4000; 134 $('.car-detail-slider').find('img').each((img, obj) => { 135// console.log(obj.height, obj.clientHeight); 136 if (obj.clientHeight > 0 && obj.clientHeight < smallest) 137 smallest = obj.clientHeight; 138 }); 139 $('.car-detail-slider').find('img').each((img, obj) => { 140 if (obj.clientHeight > 0) { 141 if (obj.clientHeight <= 1100) 142 $('.car-detail-slider').css('height', smallest); 143 else if (obj.height / obj.width > 0.8) { 144 // $('.car-detail-slider').css('height', '750px'); 145 $(obj).attr('style', 'width: auto !important').css('height', smallest); 146 } 147 } 148 }) 149}, 150adjustTilesImages = (container_id) => { 151 let im_height = 0, 152 maxHeight = 0, 153 frames = $('#'+ container_id); 154 frames.each(function (i, frame) { 155 var img = $(frame).find('img')[0]; 156 if (img.height / img.width < 0.8 && img.clientHeight > im_height && $(frame).height() > maxHeight) 157 maxHeight = $(frame).height(); 158 159 if (img.height / img.width < 0.8 && img.clientHeight > im_height) 160 im_height = img.clientHeight 161 }); 162 163 $('#'+ container_id).find('img').each((k, img) => { 164 if (img.height / img.width > 0.8) { 165 $(img).attr('style', 'width: auto !important').height(im_height); 166 } 167 }); 168 $('#'+ container_id).height(maxHeight); 169}, 170datailedInit = () => { 171 // $('.tab-list button').on('click', function(e){ 172 // if (e.target.id == 'vd_video' || e.target.id == 'vd_descript') 173 // $('#video > div > iframe').attr('src', videourl ); 174 // else 175 // $('#video > div > iframe').attr('src', ''); 176 // }); 177 $('#video > div > iframe').attr('src', videourl ); 178 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 179 $('#detailed_page').animate({ 180 scrollTop: document.getElementById("scroll_to").offsetTop - 120 181 }, 1000) 182 }); 183 if (typeof carfaxInit == 'function') 184 carfaxInit(); 185 186 let set_accordable = () => { 187 $('#option-list').accordable({ 188 openPanel: [1] 189 }); 190 } 191 if ($.isFunction($.fn.accordable) == false) { 192 ((callback) => { 193 let js = document.createElement("script"); 194 js.type = "text/javascript"; 195 js.src = '/wp-content/themes/aanWordpress/assets/js/jquery.accordable.min.js'; 196 js.onload = () => { 197 callback(); 198 } 199 document.body.appendChild(js); 200 })(() => { 201 set_accordable(); 202 }) 203 } else 204 set_accordable(); 205 206 $('.element.questions input').on('click', function(){ 207 $('#inquery_extra').slideDown(); 208 }); 209
210 $(".optionToggle").click(function(){ 211 $(this).next(".optionBlock").slideToggle("fast"); 212 }); 213 214 $(".contactUs").click(function(e){ 215 e.preventDefault(); 216 $(".ui-tabs-anchor[href='#contact']").click(); 217 }); 218 219 $("div.inventory-detailed-section .detail .btnBox a.view").on("click", function(e){ 220 e.preventDefault(); 221 $("a.contact").trigger("click"); 222 $('html, body').animate({ 223 scrollTop: $("#contact").offset().top 224 }, 500); 225 }); 226 227 $.fancybox.defaults.buttons = [ 228 'fullScreen', 229 'slideShow', 230 'thumbs', 231 'close' 232 ]; 233 234 $("[data-fancybox]").fancybox({ 235 fullScreen: { 236 autoStart: true 237 }, 238 afterShow: function( instance, slide ) { 239 $(".fancybox-is-zoomable .fancybox-slide--current").click(); 240 }, 241 }); 242 243/* full screen photo viewer */ 244 var fullscreen = false; 245 $( '.fullscreen-photos').on( 'click', function( e ){ 246 e.preventDefault(); 247 var elem = $( 'section.fullscreen-photos-container' ).get(0); 248 if (elem.requestFullscreen) { 249 elem.requestFullscreen(); 250 } else if (elem.msRequestFullscreen) { 251 elem.msRequestFullscreen(); 252 } else if (elem.mozRequestFullScreen) { 253 elem.mozRequestFullScreen(); 254 } else if (elem.webkitRequestFullscreen) { 255 elem.webkitRequestFullscreen(); 256 } 257 $( 'section.fullscreen-photos-container' ).show(); 258 259 fullscreen = true; 260 }); 261 $( 'section.fullscreen-photos-container .exit' ).on( 'click', function( e ){ 262 e.preventDefault(); 263 var elem = document; 264 if (elem.exitFullscreen) { 265 elem.exitFullscreen(); 266 } else if (elem.msExitFullscreen) { 267 elem.msExitFullscreen(); 268 } else if (elem.mozExitFullScreen) { 269 elem.mozExitFullScreen(); 270 } else if (document.mozCancelFullScreen) { 271 elem.mozCancelFullScreen(); 272 } else if (elem.webkitExitFullscreen) { 273 elem.webkitExitFullscreen(); 274 } 275 fullscreen = false; 276 $( 'section.fullscreen-photos-container' ).hide(); 277 }); 278 $( document ).bind('webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange', function(e) { 279 var IFS = 280 (typeof document.isFullScreen != "undefined") ? document.isFullScreen : 281 (typeof document.webkitIsFullScreen != "undefined") ? document.webkitIsFullScreen : 282 (typeof document.mozIsFullScreen != "undefined") ? document.mozIsFullScreen : 283 (typeof document.msIsFullScreen != "undefined") ? document.msIsFullScreen : 284 false; 285 if( !IFS && !fullscreen ) { 286 $( 'section.fullscreen-photos-container' ).hide(); 287 fullscreen = false; 288 } 289 if( fullscreen ) { 290 fullscreen = false; 291 } 292 }); 293 294 $(".featureItem b").click(function(){ 295 $(this).toggleClass("active").next("div").slideToggle(); 296 }); 297 $(".featureItem b").eq(0).click(); 298 299 //-----Lower set of images------------- 300 offset1 = parseInt(limit), 301 hasmoreimages = parseInt(total_images) > parseInt(limit) ? true : false; 302 303 //$('#detailed_page_wrapper').css('height', window.innerHeight - $('#header').innerHeight()); 304 305 306 $(window).scroll(function() { 307 308 if (hasmoreimages) { 309 hasmoreimages = false; 310 $.get( "/api/cars/"+ vid +"?action=getImages&limit="+ limit +"&offset="+ offset1 +"&size=f" ).done( function( text ) { 311 312 text = JSON.parse(text); 313 offset1 = parseInt(offset1) + parseInt(limit); 314 315 for (var i in text) { 316 317 $('#photos').append('\ 318 <div class="photo col-md-6 col-lg-4 mb-3" onclick="openFancybox('+ (parseInt(i) + parseInt(offset1) - parseInt(limit)) +')">\ 319 <img class="full img-fluid w-100" src="'+ text[i].url +'" alt="'+ text[i].alt +'" />\ 320 </div>'); 321 } 322 hasmoreimages = total_images > offset1 ? true : false; 323 }); 324 } 325 // adjustTilesImages('photos'); 326 }); 327 checkPinned(); 328 getImages(); 329}, 330openFancybox = (i) => { 331 $('#fancypic_'+ i).click(); 332}, 333loading = false, 334getImages = () => { 335 336 if (loading) return; 337 loading = true; 338 339 $.get("/api/cars/" + vid + "?action=getImages&limit=" + limit + "&offset=" + offset + "&size=l") 340 .done(function (text) { 341 342 text = JSON.parse(text); 343 if (!Array.isArray(text) || text.length === 0) { 344 loading = false; 345 return; 346 } 347 348 const slides = []; 349 for (var i = 0; i < text.length; i++) { 350 351 const globalIndex = offset + i; 352 //onclick="openFancybox(${globalIndex})" 353 slides.push(` 354 <div class="swiper-slide"> 355 <div class="photo"> 356 <img class="full" src="${text[i].url}" alt="${text[i].alt || ''}"> 357 </div> 358 </div> 359 `); 360 } 361 362 if (offset === 0) { 363 364 $('.car-detail-slider .swiper-wrapper').html(slides.join('')); 365
366 carDetailSwiper = new Swiper('.swiper.car-detail-slider', { 367 slidesPerView: 1, 368 autoHeight: true, 369 speed: 300, 370 loop: false, 371 pagination: { 372 el: ".swiper-pagination", 373 dynamicBullets: true, 374 clickable: true 375 }, 376 377 navigation: { 378 nextEl: '.swiper-custom-button-next', 379 prevEl: '.swiper-custom-button-prev', 380 }, 381 382 on: { 383 slideChange: function () { 384 if (this.activeIndex >= this.slides.length - 2) { 385 getImages(); 386 } 387 } 388 } 389 }); 390 391 } else { 392 slides.forEach(slide => { 393 carDetailSwiper.appendSlide(slide); 394 }); 395 } 396 397 offset = parseInt(offset) + parseInt(limit); 398 loading = false; 399 }) 400 .fail(function () { 401 loading = false; 402 }); 403}, 404moveToContcts = () => { 405 $('#detailed_page').animate({ 406 /*scroll*/Top: $('#tabs').offset().top - 100 407 }, 1000); 408 409 $('.contact').trigger('click'); 410}, 411count = 0, 412loadNext = () => { 413 count++; 414 415 if (!loading && count >= limit - 1) { 416 count = 0; 417 getImages(); 418 } 419}, 420backToListing = (id) => { 421 if ($('#container').text().trim().length < 50 && typeof getListingPage == 'function') 422 getListingPage(); 423 424 if (current_listing.length < 2) 425 location.href = 'inventory'; 426 427 // Smoothly transition back to the inventory page 428 $('#detailed_page_wrapper').fadeTo('fast', 0, function() { 429 // Hide without emptying content - just make it invisible 430 $(this).css('display', 'none'); 431 432 // Show the main page 433 $('#page').css({ 434 'display': 'block', 435 'opacity': '0' 436 }).fadeTo('fast', 1); 437 438 // Make sure footer is visible 439 $('#footer').css('display', 'block'); 440 441 // Re-enable scrolling 442 $('html').css({overflow: 'auto'}); 443 444 // Don't empty the detailed page - just hide it 445 // This preserves structure for future use 446 // We'll replace content on next view instead 447 }); 448 449 is_listing_page = true; 450 451 window.history.pushState({}, null, current_listing); 452 453 listing_tags.map((val, k) => { 454 if (val.name == 'og:url') 455 val.value = current_listing; 456 457 $('meta[property="'+ val.name +'"]').attr('content', val.value); 458 if (val.name == 'og:description') { 459 $('meta[name="description"]').attr('content', val.value); 460 } 461 }); 462 463 $('link[rel="canonical"]').attr('href', current_listing); 464 document.title = listing_title_tag; 465 466 // Scroll to the vehicle if needed 467 const element = document.getElementById(id); 468 if (element) { 469 // Temporarily disable smooth scrolling 470 const htmlStyles = window.getComputedStyle(document.querySelector("html")); 471 const smoothScroll = htmlStyles.getPropertyValue("scroll-behavior"); 472 document.querySelector("html").style["scroll-behavior"] = "auto"; 473 474 element.scrollIntoView(true); 475 window.scrollBy(0, -200); 476 477 // Re-enable smooth scrolling 478 document.querySelector("html").style["scroll-behavior"] = smoothScroll; 479 } 480}, 481toggleOptions = (obj) => { 482 483 if (obj.innerHTML == 'Open All') { 484 $('.featureItem').find('b').addClass('active'); 485 $('.featureItem > div:not(.clearfix)').show('slow'); 486 obj.innerHTML = 'Close All'; 487 } else { 488 $('.featureItem').find('b').removeClass('active'); 489 $('.featureItem > div:not(.clearfix)').hide('slow'); 490 obj.innerHTML = 'Open All'; 491 } 492}, 493showSticker = (vid) => { 494 $.post('https://reseller.aansupport.com/controlpanel/vms/build_sticker.php?cid='+ vid, 495 { 496 db: 'woodburyautosal', 497 dblogin: 'wdbrytsls' 498 499 }, function (data) { 500 var w = window.open('about:blank'); 501 w.document.open(); 502 w.document.write(data); 503 w.document.close(); 504 }); 505} 506 507$(document).ready(function(e) { 508 if (vid > 0) 509 getDetailed(false, 'xxx-c-'+ vid +'/', true); 510 511 else { 512 current_listing = window.location.href; 513 listing_title_tag = document.title; 514 } 515 516 $(".optionToggle").click(function(e){ 517 e.preventDefault(); 518 $("#tabs li a").eq(0).click(); 519 $(this).next(".optionBlock").slideToggle("fast"); 520 }); 521 522 $(".contactUs").click(function(e){ 523 e.preventDefault(); 524 $(".ui-tabs-anchor[href='#contact']").click(); 525 }); 526 527 $("div.inventory-detailed-section .detail .btnBox a.view").on("click", function(e){ 528 e.preventDefault(); 529 $("a.contact").trigger("click"); 530 $('html, body').animate({ 531 scrollTop: $("#contact").offset().top 532 }, 500); 533 }); 534 535}); 536window.onpopstate = function (event) { 537 var loc = document.location.href.match(/-c-(\d*)\//); 538 539 if (loc != null) { 540 getDetailed(document.location.href); 541 } else if (is_listing_page) { 542 readHash(); 543 getSearchResults(); 544 } else { 545 backToListing(vid); 546 } 547}; 548// Also add a history state change listener to see if that works better 549window.addEventListener('popstate', function(event) { 550 var loc = document.location.href.match(/-c-(\d*)\//); 551 552 if (loc != null) { 553 getDetailed(document.location.href); 554 } else if (is_listing_page) { 555 readHash(); 556 getSearchResults(); 557 } else { 558 backToListing(vid); 559 } 560}); 561
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.