1(function( $ ) { 2 'use strict'; 3 4 let queryString = {}; 5 6 let years = []; 7 let parts =[]; 8 9 function getYears($appendElement){ 10 $.ajax({ 11 url: '/wp-json/smtp/v1/years', 12 type: 'GET', 13 dataType: 'json', 14 success:function(data) { 15 years = data; 16 appendToDropdown($appendElement, years, 'id', 'id'); 17 showElements([$appendElement]); 18 }, 19 error: function(errorThrown){ 20 console.log(errorThrown); 21 } 22 }); 23 } 24 25 function getMakes($appendElement, currentYear){ 26 $.ajax({ 27 url: '/wp-json/smtp/v1/makes/' + currentYear, 28 type: 'GET', 29 dataType: 'json', 30 success:function(data) { 31 appendToDropdown($appendElement, data, 'id', 'data'); 32 showElements([$appendElement]); 33 }, 34 error: function(errorThrown){ 35 console.log(errorThrown); 36 } 37 }); 38 } 39 40 function getModels($appendElement, currentYear, currentMake){ 41 $.ajax({ 42 url: '/wp-json/smtp/v1/models/' + currentYear + '/' + currentMake, 43 type: 'GET', 44 dataType: 'json', 45 success:function(data) { 46 appendToDropdown($appendElement, data, 'id', 'data'); 47 showElements([$appendElement]); 48 }, 49 error: function(errorThrown){ 50 console.log(errorThrown); 51 } 52 }); 53 } 54 55 function getEngines($appendElement, currentYear, currentMake, currentModel){ 56 $.ajax({ 57 url: '/wp-json/smtp/v1/engines/' + currentYear + '/' + currentMake + '/' + currentModel, 58 type: 'GET', 59 dataType: 'json', 60 success:function(data) { 61 appendToDropdown($appendElement, data, 'id', 'data'); 62 showElements([$appendElement]); 63 64 // alert(document.getElementById('form-field-engine').value );//= 'All~~~'; 65 // alert(JSON.stringify(document.getElementById('form-field-engine')) ); 66 // $appendElement.selectedIndex = 1; 67 }, 68 error: function(errorThrown){ 69 console.log(errorThrown); 70 } 71 }); 72 } 73 74 function getProducts($appendElement, currentYear, currentMake, currentModel, currentEngine){ 75 $.ajax({ 76 url: '/wp-json/smtp/v1/products/' + currentYear + '/' + currentMake + '/' + currentModel + '/' + currentEngine, 77 type: 'GET', 78 dataType: 'json', 79 success:function(data) { 80 appendToDropdown($appendElement, data, 'id', 'data'); 81 showElements([$appendElement]); 82 }, 83 error: function(errorThrown){ 84 console.log(errorThrown); 85 } 86 }); 87 } 88 89 function getParts(){ 90 let url = '/wp-json/smtp/v1/parts/' + queryString.years + '/' + queryString.make + '/' + queryString.model + '/' + queryString.engine; 91 92 console.log(url); 93 if(queryString.hasOwnProperty('product')) { 94 url += '/' + queryString.product; 95 } 96 97 $.ajax({ 98 url: url, 99 type: 'GET', 100 dataType: 'json', 101 success:function(data) { 102 parts = data; 103 $('.lds-roller').css('display', 'none'); 104 displayParts(); 105 }, 106 error: function(errorThrown){ 107 console.log(errorThrown); 108 } 109 }); 110 } 111 112 function getPartsByVin(){ 113 $.ajax({ 114 url: '/wp-json/smtp/v1/vin/' + queryString.vin, 115 type: 'GET', 116 dataType: 'json', 117 success:function(data) { 118 parts = data.parts; 119 $('.lds-roller').css('display', 'none'); 120 displayParts(); 121 }, 122 error: function(errorThrown){ 123 console.log(errorThrown); 124 } 125 }); 126 } 127 128 function getPartsByLicensePlateAndState(){ 129 let url = '/wp-json/smtp/v1/license-and-state/' + queryString.plateno + '/' + queryString.state; 130 131 if(queryString.hasOwnProperty('product')) { 132 url += '/' + queryString.product; 133 } 134 135 $.ajax({ 136 url: url, 137 type: 'GET', 138 dataType: 'json', 139 success:function(data) { 140 parts = data.partsdata; 141 $('.lds-roller').css('display', 'none'); 142 displayParts(); 143 }, 144 error: function(errorThrown){ 145 console.log(errorThrown); 146 } 147 }); 148 } 149 150 151 /** 152 * This returns true if the product is sold at Walmart. As the site is supposed to centered around those 153 * locations for products not elsewhere they may be sold 154 * @param buyLinkTitle 155 * @returns {boolean} 156 */ 157 function matchWalmart(buyLinkTitle){ 158 return buyLinkTitle.toLowerCase().includes('walmart.com'); 159 } 160 161 /** 162 * This returns true if the product is sold at Amazon. As the site is supposed to centered around those 163 * locations for products not elsewhere they may be sold 164 * @param buyLinkTitle 165 * @returns {boolean} 166 */ 167 function matchAmazon(buyLinkTitle){ 168 return buyLinkTitle.toLowerCase().includes('amazon.com'); 169 } 170 171 172 173 /** 174 * Return the simplified brake object, this is seperated in order to not have duplicate code 175 * @param brake 176 * @returns {{part_no, image, buyLink: *[], part_type, comment, location}} 177 */ 178 function returnBrakeObject(brake){ 179 return { 180 part_no: brake.part_no, 181 part_type: brake.part_type, 182 image: brake.image, 183 comment: brake.comment, 184 location: brake.location,
185 buyLink: returnBuyLink(brake) 186 }; 187 } 188 189 /** 190 * This creates the object array of the buylinks where the product is available 191 * @param brake 192 * @returns {*[]} 193 */ 194 function returnBuyLink(brake){ 195 let brakeBuyLinks = []; 196 if(isEmptyOrSpaces(brake.buylinks)){ 197 brakeBuyLinks.push({ 198 seller: 'none', 199 url: '', 200 title: '', 201 icon: '' 202 }); 203 }else if(Array.isArray(brake.buylinks.buylink)) { 204 $.each(brake.buylinks.buylink, function (blKey, blValue) { 205 if(matchAmazon(blValue.title.toLowerCase()) || matchWalmart(blValue.title.toLowerCase()) ) { 206 if(matchAmazon(blValue.title.toLowerCase()) ){ 207 blValue.icon = "https://goodyearbrakes.com/wp-content/uploads/available-on-amazon.png"; 208 }else{ 209 blValue.icon = "https://goodyearbrakes.com/wp-content/uploads/at-wally-world.png"; 210 } 211 brakeBuyLinks.push({ 212 seller: blValue.seller, 213 url: blValue.url, 214 title: blValue.title, 215 icon: blValue.icon 216 }); 217 } 218 }); 219 } else if(matchAmazon(brake.buylinks.buylink.title.toLowerCase()) || matchWalmart(brake.buylinks.buylink.title.toLowerCase()) ) { 220 if(matchAmazon(brake.buylinks.buylink.title.toLowerCase()) ){ 221 brake.buylinks.buylink.icon = "https://goodyearbrakes.com/wp-content/uploads/available-on-amazon.png"; 222 }else{ 223 brake.buylinks.buylink.icon = "https://goodyearbrakes.com/wp-content/uploads/at-wally-world.png"; 224 } 225 226 brakeBuyLinks.push({ 227 seller: brake.buylinks.buylink.seller, 228 url: brake.buylinks.buylink.url, 229 title: brake.buylinks.buylink.title, 230 icon: brake.buylinks.buylink.icon 231 }); 232 console.log(brake.buylinks.buylink.title); 233 } 234 console.log(brakeBuyLinks); 235 return brakeBuyLinks; 236 } 237 238 239 /** 240 * This displays the available brakes on the screen or leaves a message to contact if none are available 241 */ 242 function displayParts() { 243 let hasResults = false; 244 245 let newParts = removeDuplicateValue(parts); 246 247 let newOrganizedParts = { 248 rear_prc_kits: [], 249 front_prc_kits: [], 250 front_rear_prc_kits: [], 251 rear_prk_kits: [], 252 front_prk_kits: [], 253 front_rear_prk_kits: [], 254 rear_calipers: [], 255 front_calipers: [], 256 front_rear_calipers: [], 257 rear_rotors: [], 258 front_rotors: [], 259 front_rear_rotors: [], 260 rear_shoes: [], 261 front_shoes: [], 262 front_rear_shoes: [], 263 rear_pads: [], 264 front_pads: [], 265 front_rear_pads: [] 266 }; 267 268 $.each(newParts, function(key, brake) { 269 console.log(brake); 270 console.log('-----\n\r'); 271 272 273 if(brake.buylinks == null || brake.buylinks.buylink == null || brake.buylinks.buylink.length === 0) { 274 return; 275 } 276 /* */ 277 278 hasResults = true; 279 280 let location = brake.location.toLowerCase(); 281 let part_type = brake.part_type.toLowerCase(); 282 let part_no = brake.part_no.toUpperCase(); 283 284 let prefix =''; 285 switch (true) { 286 case location.includes('front'): 287 prefix = 'Front'; 288 break; 289 case location.includes('rear'): 290 prefix = 'Rear'; 291 break; 292 default: 293 prefix = 'Front/Rear'; 294 break; 295 } 296 297 switch (true) { 298 case part_no.includes('GYD'): 299 brake.part_type = prefix + ' ' + 'Brake Pad Set'; 300 if(brake.image.includes('na-showme') || brake.image === 'https://www.showmethepartsdb.com/bin/images/na-showme.jpg'){ 301 brake.image = 'https://goodyearbrakes.com/wp-content/uploads/brake-pads.jpg'; 302 } 303 switch (prefix) { 304 case 'Front': 305 newOrganizedParts.front_pads.push(returnBrakeObject(brake)); 306 break; 307 case 'Rear': 308 newOrganizedParts.rear_pads.push(returnBrakeObject(brake)); 309 break; 310 default: 311 newOrganizedParts.front_rear_pads.push(returnBrakeObject(brake)); 312 break; 313 } 314 break; 315 316 case part_no.includes('GYS'): 317 brake.part_type = prefix + ' ' + 'Brake Shoe Set'; 318 switch (true) { 319 case 'Front': 320 newOrganizedParts.front_shoes.push(returnBrakeObject(brake)); 321 break; 322 case 'Rear': 323 newOrganizedParts.rear_shoes.push(returnBrakeObject(brake)); 324 break; 325 default: 326 newOrganizedParts.front_rear_shoes.push(returnBrakeObject(brake)); 327 break; 328 } 329 break; 330 case (part_no.includes('GY') && part_no.includes('
330C')) || (part_no.startsWith('GY')): 331 brake.part_type = prefix + ' ' + 'Disc Brake Calipers'; 332 if(brake.image.toString().includes('na-showme') || brake.image === 'https://www.showmethepartsdb.com/bin/images/na-showme.jpg') { 333 brake.image = 'https://goodyearbrakes.com/wp-content/uploads/GoodyearBrakes_Caliper_CalloutImage_970x600.jpg'; 334 } 335 336 switch (true) { 337 case 'Front': 338 newOrganizedParts.front_rotors.push(returnBrakeObject(brake)); 339 break; 340 case 'Rear': 341 newOrganizedParts.rear_rotors.push(returnBrakeObject(brake)); 342 break; 343 default: 344 newOrganizedParts.front_rear_rotors.push(returnBrakeObject(brake)); 345 break; 346 } 347 // console.log(part_no + ' Disc Brake Calipers'); 348 break; 349 case part_no.endsWith('GY'): 350 brake.part_type = prefix + ' ' + 'Disc Brake Rotors'; 351 if (part_no.startsWith('2X')) { 352 // console.log("2X|2X|2X"); 353 brake.part_type = 'A pair of ' + brake.part_type; 354 } 355 if(brake.image.toString().includes('na-showme') || brake.image === 'https://www.showmethepartsdb.com/bin/images/na-showme.jpg'){ 356 brake.image = 'https://goodyearbrakes.com/wp-content/uploads/GoodyearBrakes_Rotor_CalloutImage_970x600-copy.jpg'; 357 } 358 switch (true) { 359 case 'Front': 360 newOrganizedParts.front_rotors.push(returnBrakeObject(brake)); 361 break; 362 case 'Rear': 363 newOrganizedParts.rear_rotors.push(returnBrakeObject(brake)); 364 break; 365 default: 366 newOrganizedParts.front_rear_rotors.push(returnBrakeObject(brake)); 367 break; 368 } 369 // console.log(part_no + ' Disc Brake Rotors'); 370 break; 371 case part_no.includes('PRC'): 372 brake.part_type = prefix + ' ' + 'Disc Brake Pad, Rotor, and Caliper Kit'; 373 if(brake.image.toString().includes('na-showme') || brake.image === 'https://www.showmethepartsdb.com/bin/images/na-showme.jpg'){ 374 brake.image = 'https://goodyearbrakes.com/wp-content/uploads/pads-rotors-and-clipers.webp'; 375 } 376 switch (true) { 377 case 'Front': 378 newOrganizedParts.front_prc_kits.push(returnBrakeObject(brake)); 379 break; 380 case 'Rear': 381 newOrganizedParts.rear_prc_kits.push(returnBrakeObject(brake)); 382 break; 383 default: 384 newOrganizedParts.front_rear_prc_kits.push(returnBrakeObject(brake)); 385 break; 386 } 387 // console.log(part_no + ' Disc Brake Pad, Rotor, and Caliper Rotors'); 388 break; 389 case part_no.includes('PRK'): 390 brake.part_type =prefix + ' ' + 'Disc Brake Pad and Rotor Kit'; 391 if(brake.image.toString().includes('na-showme') || brake.image === 'https://www.showmethepartsdb.com/bin/images/na-showme.jpg'){ 392 brake.image = 'https://goodyearbrakes.com/wp-content/uploads/Pads-and-rotors.jpg'; 393 } 394 switch (true) { 395 case 'Front': 396 newOrganizedParts.front_prk_kits.push(returnBrakeObject(brake)); 397 break; 398 case 'Rear': 399 newOrganizedParts.rear_prk_kits.push(returnBrakeObject(brake)); 400 break; 401 default: 402 newOrganizedParts.front_rear_prk_kits.push(returnBrakeObject(brake)); 403 break; 404 } 405 // console.log(part_no + ' Disc Brake Pads and Rotors Rotors'); 406 break; 407 default: 408 409 // console.log(part_no + ' unknown'); 410 break; 411 } 412 413 414 }); 415 416 if(hasResults) { 417 $.each(newOrganizedParts, function (key, brakes) { 418 $.each(brakes, function (key, brake) { 419 appendResult(brake.part_no, brake.location, brake.part_type, brake.buyLink, brake.image, brake.comment); 420 }); 421 422 }); 423 }else{ 424 $('.result-parts').prepend('<h2>No Results Found.<br> Please <a href="/contact">contact us</a> with more information about your vehicle.</h2>'); 425 } 426 427 428 } 429 430 431 /** 432 * This returns the buyer links to display on the screen 433 * @param vendorLinks 434 * @param partNumber 435 * @returns {string} 436 */ 437 function createBuyLinksHTML(vendorLinks, partNumber){ 438 let html = ""; 439 if(Array.isArray(vendorLinks)) { 440 let vendorArray = vendorLinks; 441 vendorArray.sort(function(a, b) { 442 let sellerA = a.seller.replace('www.', '').toLowerCase(); 443 let sellerB = b.seller.replace('www.', '').toLowerCase(); 444 if(sellerA > sellerB) { 445 return 1 446 } 447 if(sellerA < sellerB) { 448 return -1 449 } 450 return 0; 451 }); 452 $.each(vendorArray, function(buylinkKey, buylinkValue) { 453 if(buylinkValue.icon === '') { 454 html += 'This Item is currently not in stock!' 455 }else { 456 html += '<a href="' + buylinkValue.url + '" target="_blank" data-sales-channel="' 457 + buylinkValue.seller + '" data-manufacturer-part-number="' + partNumber 458 + '" class="lookup-result elementor-button-link elementor-button elementor-size-sm buy-now-button" role="button">' + 459 '<img alt="Vendor Logo" class="buylink-icon" src="' + buylinkValue.icon + '">' + 460 461 '</a>'; 462 } 463 }); 464 } else if(buylinks.buylink.icon === ''){ 465 html += 'This Item is currently not in stock!' 466 } else { 467 html += '<a href="' + buylinks.buylink.url + '" target="_blank" data-sales-channel="' 468 + buylinks.buylink.seller + '" data-manufacturer-part-number="' + partNumber 469 + '" class="lookup-result elementor-button-link elementor-button elementor-size-sm buy-now-button" role="button">' + 470 '<img alt="Vendor Logo" class="buylink-icon" src="' + buylinks.buylink.icon + '">' + 471 '</a>'; 472 } 473 474 return html; 475 476 } 477 478 /** 479 * This Function removes accidentally duplicate products from showing 480 * @param myArray 481 * @returns {*[]} 482 */ 483 function removeDuplicateValue(myArray){ 484 var newArray = []; 485 486 $.each(myArray, function(key, value) { 487 var exists = false;
488 $.each(newArray, function(k, val2) { 489 if(value.part_no == val2.part_no){ exists = true }; 490 }); 491 if(exists == false && value.part_no != "") { 492 493 newArray.push(value); 494 } 495 }); 496 497 return newArray; 498 } 499 500 501 /** 502 * This is for testing only will be eventually removed 503 * @param data 504 */ 505 function appendResultArrayOfData(data){ 506 let html ='<div style="max-width: 1280px; margin: auto;">' + 507 '<div style="border-bottom: 2px #00000070 solid; padding: 20px 0px; margin: 10px 0px; display: flex; ">' + 508 509 '<div style="padding-right: 10px; width: 50%">'; 510 511 if(Array.isArray(data)){ 512 $.each(data, function(dataKey,dataValue){ 513 html += '<div><strong>' + dataKey + '</strong>: ' + dataValue + '</div>'; 514 }); 515 html += '<div>DATA AFTER EACH<br/>>' + data + '</div>'; 516 }else{ 517 html += '<div>DATA WHEN NOT ARRAY<br/>>' + data + '</div>'; 518 } 519 html += '</div> </div>' + 520 '</div> '; 521 $('.result-parts').prepend(html); 522 523 } 524 525 /** 526 * This is for testing only will eventually be removed 527 * @param partNumber 528 * @param location 529 * @param partType 530 * @param buylinks 531 */
532 function appendResultJustText(partNumber, location, partType, buylinks){ 533 let html ='<div style="max-width: 1280px; margin: auto;">' + 534 '<div style="border-bottom: 2px #00000070 solid; padding: 20px 0px; margin: 10px 0px; display: flex; ">' + 535 '<div style="padding-right: 10px; width: 25%">' + partNumber + '</div>' + 536 '<div style="padding-right: 10px; width: 25%">' + location + '</div>' + 537 '<div style="padding-right: 10px; width: 25%">' + partType + '</div>' + 538 '<div style="padding-right: 10px; width: 25%">'; 539 540 if(Array.isArray(buylinks.buylink)) { 541 let vendorArray = buylinks.buylink; 542 $.each(vendorArray, function(buylinkKey, buylinkValue) { 543 html += buylinkValue.url + ' - '; 544 }); 545 546 } 547 html += '</div> </div>' + 548 '</div> '; 549 $('.result-parts').prepend(html); 550 } 551 552function appendResultNew(partNumber, location, partType, buylinks, image) { 553 554 var title = 'Goodyear Brakes® ' + partNumber; 555 if(location !== null) { 556 title += ' - ' + location.substring(0,1).toUpperCase() + location.substring(1).toLowerCase(); 557 } 558 title += ' ' + partType; 559 560 let html = 561 '<div class="results-wrapper elementor-element elementor-element-2e3b832 elementor-section-boxed elementor-section-height-default elementor-section-height-default elementor-section elementor-inner-section" data-id="2e3b832" data-element_type="section">' + 562 '<div class="elementor-container elementor-column-gap-default">' + 563 '<div class="elementor-row result-row">' + 564 '<div class="elementor-element elementor-element-d4f14c7 elementor-column elementor-inner-column" data-id="d4f14c7" data-element_type="column">' + 565 '<div class="elementor-column-wrap elementor-element-populated">' + 566 '<div class="elementor-widget-wrap">' + 567 '<div class="elementor-element elementor-element-42c81d7 elementor-widget elementor-widget-image" data-id="42c81d7" data-element_type="widget" data-widget_type="image.default">' + 568 '<div class="elementor-widget-container">' + 569 ' <div class="elementor-image">' + 570 ' <img alt="' + title + '" style="max-width:200px;
570" width="1000" height="1000" alt="" src="' + image + '">' + 571 '</div>' + 572 '</div>' + 573 '</div>' + 574 '</div>' + 575 '</div>' + 576 '</div>' + 577 '<div class="elementor-element elementor-element-e5bc36e elementor-column elementor-inner-column" data-id="e5bc36e" data-element_type="column">' + 578 '<div class="elementor-column-wrap elementor-element-populated">' + 579 '<div class="elementor-widget-wrap" style="align-content: center; text-align: left;">' + 580 ' <div>' + title + '</div>' + 581 ' <div>Buy Here</div>'; 582 html += '<div>' + createBuyLinksHTML(buylinks, partNumber) + '</div>'; 583 html += '</div>' + 584 '</div>' + 585 '</div>' + 586 '</div>' + 587 '</div>' + 588 '</div>' + 589 '</div>' + 590 '</div>' + 591 '</div>' + 592 '<div class="elementor-element elementor-element-d94a45b elementor-widget elementor-widget-divider" data-id="d94a45b" data-element_type="widget" data-widget_type="divider.default">' + 593 '<div class="elementor-widget-container">' + 594 '<div class="elementor-divider results-divider">' + 595 '<span class="elementor-divider-separator">' + 596 '</span>' + 597 '</div>' + 598 '</div>' + 599 '</div>'; 600 601 $('.result-parts').prepend(html); 602} 603/** 604 * This is the creation of the html and css that displays a product located and in the product list 605 * @param partNumber 606 * @param location 607 * @param partType 608 * @param buylinks 609 * @param image 610 */
611function appendResult(partNumber, location, partType, buylinks, image, comment) { 612 if(location.toLowerCase().includes('and')){ 613 location = location.toLowerCase().replace('and', '/').replace(/\s+/g, '');; 614 }else{ 615 location = location.toLowerCase(); 616 } 617 if(partType.toLowerCase().includes('and')){ 618 partType = partType.toLowerCase().replace('and', '&').toLowerCase(); 619 } 620 let title = '';//'Goodyear Brakes®<br/>'; 621 title += ' ' + partType + ' — ' + partNumber; 622 comment = (comment !== null ) ? comment : ''; 623 624 let html = '<section class="results-wrapper elementor-element brake-result-background break-result-seciton' + 625 ' elementor-section-boxed elementor-section ">' + 626 '<div class="brake-results elementor-container elementor-column-gap-default">' + 627 ' <div class="brake-results-image"><img alt alt="" src="' + image + '"></div>' + 628 ' <div class="brake-results-details">' + 629 ' <h2 class="brake-results-details-title" style="padding-top: 30px;">' + title + '</h2>' + 630 /* ' <div class="brake-results-details-comment">' + comment + '</div>' +*/ 631 ' <div class="brake-results-details-buynow space_above">Buy Now:</div>' + 632 ' <div class="brake-results-details-links">' + createBuyLinksHTML(buylinks, partNumber) + '</div>' + 633 ' </div>' + 634 '</div>' + 635 '</section>'; 636 637 638 639 $('.result-parts').prepend(html); 640 } 641 642 643 function isEmptyOrSpaces(str){ 644 return str === null; 645 } 646 647 648 function appendToDropdown($object, data, valueId, textId) { 649 $object.find('option:not(:first)').remove(); 650 $.each(data, function(key, value) { 651 $object.append($("<option></option>") 652 .attr("value",value[valueId]) 653 .attr("data-object", JSON.stringify(value)) 654 .text(value[textId])); 655 }); 656 } 657 658 function resetSelectFields($elements) { 659 $.each($elements, function(key, element) { 660 $(element).prop('disabled', true); 661 $(element).find('option:not(:first)').remove(); 662 }); 663 } 664 665 function showElements($elements) { 666 $.each($elements, function(key, element) { 667 $(element).prop('disabled', false); 668 }); 669 } 670 671 function getQueryStringObject() { 672 location.search.substr(1).split("&").forEach(function (pair) { 673 if (pair === "") return; 674 var parts = pair.split("="); 675 queryString[parts[0]] = parts[1] && 676 decodeURIComponent(parts[1].replace(/\+/g, " ")); 677 }); 678 } 679 680 function updateResultsPage() { 681 682 if(queryString.hasOwnProperty('years')) { 683 let labels = JSON.parse(decodeURIComponent(escape(window.atob(queryString.labels)))); 684 let labelText = 'SHOWING RESULTS FOR: ' + labels.year + ' ' + labels.make + ' ' + labels.model + ' ' + labels.engine; 685 if(labels.hasOwnProperty('product')) { 686 labelText += ' - ' + labels.product; 687 } 688 689 $('.results-header h2').text(labelText) 690 getParts(); 691 } else if(queryString.hasOwnProperty('vin')) { 692 $('.results-header h2').text('SHOWING RESULTS FOR VIN: ' + queryString.vin) 693 getPartsByVin(); 694 } else if(queryString.hasOwnProperty('plateno')) { 695 $('.results-header h2').text('SHOWING RESULTS FOR PLATE #: ' + queryString.plateno) 696 getPartsByLicensePlateAndState(); 697 } 698 699 } 700 701 $(document).ready(function($) { 702 703 let $body = $('body'); 704 705 resetSelectFields([ 706 $('[name="form_fields[make]"]'), 707 $('[name="form_fields[model]"]'), 708 $('[name="form_fields[engine]"]'), 709 $('[name="form_fields[product]"]') 710 ]); 711 712 getYears($('[name="form_fields[year]"]')); 713 getQueryStringObject(); 714 715 if((queryString.hasOwnProperty('years') && queryString.hasOwnProperty('make') && queryString.hasOwnProperty('model') && queryString.hasOwnProperty('engine')) || queryString.hasOwnProperty('vin') || (queryString.hasOwnProperty('state') && queryString.hasOwnProperty('plateno'))) { 716 updateResultsPage(); 717 } 718 719 $( document ).on( 'elementor/popup/show', function() { 720 setTimeout(function() { 721 appendToDropdown($('[name="form_fields[year]"]'), years, 'id', 'id'); 722 }, 2000); 723 } ); 724 725 $body.on('change', '[name="form_fields[year]"]', function() { 726 let $form = $(this).closest('form'); 727 let currentYear = $form.find('[name="form_fields[year]"] option:selected').val(); 728 729 resetSelectFields([ 730 $form.find('[name="form_fields[make]"]'), 731 $form.find('[name="form_fields[model]"]'), 732 $form.find('[name="form_fields[engine]"]'), 733 $form.find('[name="form_fields[product]"]'), 734 ]); 735 736 getMakes($form.find('[name="form_fields[make]"]'), currentYear); 737 }); 738 739 $body.on('change', '[name="form_fields[make]"]', function() { 740 let $form = $(this).closest('form'); 741 let currentYear = $form.find('[name="form_fields[year]"] option:selected').val(); 742 let currentMake = $form.find('[name="form_fields[make]"] option:selected').val(); 743 744 resetSelectFields([ 745 $form.find('[name="form_fields[model]"]'), 746 $form.find('[name="form_fields[engine]"]'), 747 $form.find('[name="form_fields[product]"]'), 748 ]); 749 750 getModels($form.find('[name="form_fields[model]"]'), currentYear, currentMake); 751 }); 752 753 $body.on('change', '[name="form_fields[model]"]', function() { 754 let $form = $(this).closest('form'); 755 let currentYear = $form.find('[name="form_fields[year]"] option:selected').val(); 756 let currentMake = $form.find('[name="form_fields[make]"] option:selected').val(); 757 let currentModel = $form.find('[name="form_fields[model]"] option:selected').val(); 758 759 resetSelectFields([ 760 $form.find('[name="form_fields[engine]"]'), 761 $form.find('[name="form_fields[product]"]'), 762 ]); 763 764 getEngines($form.find('[name="form_fields[engine]"]'), currentYear, currentMake, currentModel); 765 766 window.setTimeout( function(){ 767 var headerValue = $('#header_brakes [name="form_fields[engine]"] option:eq(1)').html(); 768 var footerValue = $('#footer_brakes [name="form_fields[engine]"] option:eq(1)').html(); 769 if(typeof headerValue !== 'undefined' && headerValue.length > 0) { 770 $('#header_brakes [name="form_fields[engine]"] option:eq(1)').prop('selected',true); 771 $('#header_brakes [name="form_fields[engine]"] option:eq(1)').html("All Engines"); 772 enableFindMyBrakes($form); 773 }else if(typeof footerValue !== 'undefined' && footerValue.length > 0) { 774 $('#footer_brakes [name="form_fields[engine]"] option:eq(1)').prop('selected',true); 775 776 $('#footer_brakes [name="form_fields[engine]"] option:eq(1)').html("All Engines"); 777 enableFindMyBrakes($form); 778 } 779 }, 1000) 780 781 }); 782 783 function enableFindMyBrakes($form){ 784 // let $form = $(this).closest('form'); 785 let currentYear = $form.find('[name="form_fields[year]"] option:selected'); 786 let currentMake = $form.find('[name="form_fields[make]"] option:selected'); 787 let currentModel = $form.find('[name="form_fields[model]"] option:selected'); 788 let currentEngine = $form.find('[name="form_fields[engine]"] option:selected'); 789 790 let href = '/results/'; 791 792 let jsonLabels = JSON.stringify({ 793 'year': currentYear.text(), 794 'make': currentMake.text(), 795 'model': currentModel.text(), 796 'engine': currentEngine.text() 797 }); 798 799 href += '?years=' + currentYear.val(); 800 href += '&make=' + currentMake.val(); 801 href += '&model=' + currentModel.val(); 802 href += '&engine=' + currentEngine.val(); 803 href += '&labels=' + btoa(unescape(encodeURIComponent(jsonLabels))); 804 805 806 $form.closest('section').find('.result-anchor a').attr('href', href); 807 $form.closest('section').find('.result-anchor').css('opacity', '1.0'); 808 // getProducts($form.find('[name="form_fields[product]"]'), currentYear.val(), currentMake.val(), currentModel.val(), currentEngine.val()); 809 810 } 811 812 813 $body.on('change', '[name="form_fields[engine]"]', function() { 814 let $form = $(this).closest('form'); 815 let currentYear = $form.find('[name="form_fields[year]"] option:selected'); 816 let currentMake = $form.find('[name="form_fields[make]"] option:selected'); 817 let currentModel = $form.find('[name="form_fields[model]"] option:selected'); 818 let currentEngine = $form.find('[name="form_fields[engine]"] option:selected'); 819 820 let href = '/results/'; 821 822 let jsonLabels = JSON.stringify({ 823 'year': currentYear.text(), 824 'make': currentMake.text(), 825 'model': currentModel.text(), 826 'engine': currentEngine.text() 827 }); 828 829 href += '?years=' + currentYear.val(); 830 href += '&make=' + currentMake.val(); 831 href += '&model=' + currentModel.val(); 832 href += '&engine=' + currentEngine.val(); 833 href += '&labels=' + btoa(unescape(encodeURIComponent(jsonLabels))); 834 835 $form.closest('section').find('.result-anchor a').attr('href', href); 836 $form.closest('section').find('.result-anchor').css('opacity', '1.0'); 837 838 getProducts($form.find('[name="form_fields[product]"]'), currentYear.val(), currentMake.val(), currentModel.val(), currentEngine.val()); 839 }); 840 841 $body.on('change', '[name="form_fields[product]"]', function() { 842 let $form = $(this).closest('form'); 843 let currentYear = $form.find('[name="form_fields[year]"] option:selected'); 844 let currentMake = $form.find('[name="form_fields[make]"] option:selected'); 845 let currentModel = $form.find('[name="form_fields[model]"] option:selected'); 846 let currentEngine = $form.find('[name="form_fields[engine]"] option:selected'); 847 let currentProduct = $form.find('[name="form_fields[product]"] option:selected'); 848 849 let href = '/results/'; 850 851 let jsonLabels = JSON.stringify({ 852 'year': currentYear.text(), 853 'make': currentMake.text(), 854 'model': currentModel.text(), 855 'engine': currentEngine.text(), 856 'product': currentProduct.text() 857 }); 858 859 href += '?years=' + currentYear.val(); 860 href += '&make=' + currentMake.val(); 861 href += '&model=' + currentModel.val(); 862 href += '&engine=' + currentEngine.val(); 863 href += '&product=' + currentProduct.val(); 864 href += '&labels=' + btoa(unescape(encodeURIComponent(jsonLabels))); 865 866 $form.closest('section').find('.result-anchor a').attr('href', href); 867 }); 868 869 $body.on('click', '#modal-license-vin-brake-finder', function() { 870 871 let $form = $('form[name="License Plate VIN"]'); 872 let licensePlate = $form.find('#form-field-license_plate').val(); 873 let state = $form.find('#form-field-state option:selected').val(); 874 let vinNumber = $form.find('#form-field-vin_number').val(); 875 876 if( (licensePlate === '' || state === '') && vinNumber === '') { 877 return false;
878 } 879 880 let href = '/results/'; 881 882 if(licensePlate !== '') { 883 href += '?plateno=' + licensePlate; 884 } 885 886 if(state !== '') { 887 href += '&state=' + state; 888 } 889 890 if(vinNumber !== '') { 891 href += '?vin=' + vinNumber; 892 } 893 894 $('.result-anchor a').attr('href', href); 895 }); 896 897 }); 898 899})( jQuery );
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.