Untitled
unknown
plain_text
2 years ago
24 kB
1
Indexable
Never
/* CUSTOM CODE */ (function() { var debug = 0; var variation_name = ""; if (window.location.href.indexOf('qa-debug=true') > -1) { debug = 1; } try { function waitForElement(selector, trigger, delayInterval, delayTimeout) { var interval = setInterval(function() { if ( document && document.querySelector(selector) && document.querySelectorAll(selector).length > 0 ) { clearInterval(interval); trigger(); } }, delayInterval); setTimeout(function() { clearInterval(interval); }, delayTimeout); } function live(selector, event, callback, context) { // helper for enabling IE 8 event bindings function addEvent(el, type, handler) { if (el.attachEvent) el.attachEvent("on" + type, handler); else el.addEventListener(type, handler); } // matches polyfill this.Element && (function(ElementPrototype) { ElementPrototype.matches = ElementPrototype.matches || ElementPrototype.matchesSelector || ElementPrototype.webkitMatchesSelector || ElementPrototype.msMatchesSelector || function(selector) { var node = this, nodes = (node.parentNode || node.document).querySelectorAll( selector ), i = -1; while (nodes[++i] && nodes[i] != node); return !!nodes[i]; }; })(Element.prototype); // live binding helper using matchesSelector function live(selector, event, callback, context) { addEvent(context || document, event, function(e) { var found, el = e.target || e.srcElement; while ( el && el.matches && el !== context && !(found = el.matches(selector)) ) el = el.parentElement; if (found) callback.call(el, e); }); } live(selector, event, callback, context); } var logoSection = `<div class="right-logo-section"> <div class="top-logo"> <div class="logo-inner-container"> <div class="logo"> <img src="https://www.wineselectors.com.au/getmedia/5c8bcfed-c406-483d-ba79-01690d857866/Pig" > </div> <p class="logo-discription"> <b>100%</b></br> SATISFACTION GUARANTEE </p> </div> <div class="logo-inner-container"> <div class="logo"> <img src="https://www.wineselectors.com.au/getmedia/b8a0c206-0b70-4441-8cb8-6b55c9a5f7b0/Grapes"> </div> <p class="logo-discription"> <b>500+</b></br> AUSTRALIAN WINERIES </p> </div> <div class="logo-inner-container"> <div class="logo"> <img src="https://www.wineselectors.com.au/getmedia/1fb16233-3ea9-42ce-9084-e5dd237416c6/Wine-glasses"> </div> <p class="logo-discription"> <b>47+yrs</b></br> EXPERIENCE & PASSION </p> </div> </div> <div class="banner-scetion"> <div class="percent-img"> <img src="https://www.wineselectors.com.au/getmedia/a4a3e5ad-b552-4b30-ae43-7af767cbffab/Discount"> </div> <p><b>15% off</b> when you buy 12</p> <a><img src="https://www.wineselectors.com.au/getmedia/e543e005-795a-4a14-bbdc-ac36fed75bb5/Question"></a> </div> </div>`; var accordSection = `<div class='accordin-section'> <h3 class='wine-discription active'>Wine Description</h3> <h3 class='wine-details'>Wine Details</h3> </div>`; var NewStrip = `<div class="new-strip"> <span class="opt9-saven">save 15%</span> when you buy <span class="opt9-addcount">12</span> more bottles<a><img src="https://www.wineselectors.com.au/getmedia/e543e005-795a-4a14-bbdc-ac36fed75bb5/Question"></a> </div> <div class="saving-strip"><span class="opt9-saving">You're saving 15%!</span></div>`; var WineDetails = '' + ' <div class="kb-product-details">' + ' <div class="kb-inner-container">' + ' <div class="kb-left-container">' + ' <h2 class="kb-wine-discription active">Wine Description</h2>' + ' </div>' + ' <div class="kb-right-container">' + ' <h2 class="kb-wine-details">Wine Details</h2>' + ' </div>' + ' </div>' + ' </div>' + '<div class="kb-pack-contents-container"><div class="kb-pack-contents-inner-container"><div class="kb-pack-contents-title"><h2>PACK CONTENTS</h2></div></div></div>' + ' <div class="kb-vartical-banner-conatiner">' + ' <div class="kb-vartical-banner-inner-conatiner">' + ' </div>' + ' </div>'; var Gift_Icon = '' + ' <svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">' + ' <path d="M12.7695 3.78125H11.1004C11.3585 3.43825 11.5117 3.0121 11.5117 2.55078C11.5117 1.41998 10.5917 0.5 9.46094 0.5C8.77978 0.5 8.2775 0.744043 7.88022 1.268C7.54786 1.70638 7.30483 2.31844 7 3.09178C6.69517 2.31841 6.45214 1.70638 6.11978 1.268C5.7225 0.744043 5.22022 0.5 4.53906 0.5C3.40826 0.5 2.48828 1.41998 2.48828 2.55078C2.48828 3.0121 2.64149 3.43825 2.89956 3.78125H1.23047C0.551988 3.78125 0 4.33324 0 5.01172V5.83203C0 6.36674 0.342918 6.82264 0.820312 6.99195V13.2695C0.820312 13.948 1.3723 14.5 2.05078 14.5H11.9492C12.6277 14.5 13.1797 13.948 13.1797 13.2695V6.99195C13.6571 6.82264 14 6.36674 14 5.83203V5.01172C14 4.33324 13.448 3.78125 12.7695 3.78125ZM7.75288 3.41867C8.38122 1.82459 8.62009 1.32031 9.46094 1.32031C10.1394 1.32031 10.6914 1.8723 10.6914 2.55078C10.6914 3.22926 10.1394 3.78125 9.46094 3.78125H7.60941C7.65967 3.65506 7.7076 3.53357 7.75288 3.41867ZM4.53906 1.32031C5.37991 1.32031 5.61879 1.82459 6.24712 3.41867C6.2924 3.53357 6.34033 3.65506 6.39059 3.78125H4.53906C3.86058 3.78125 3.30859 3.22926 3.30859 2.55078C3.30859 1.8723 3.86058 1.32031 4.53906 1.32031ZM5.35938 13.6797H2.05078C1.82462 13.6797 1.64062 13.4957 1.64062 13.2695V7.0625H5.35938V13.6797ZM5.35938 6.24219H1.23047C1.00431 6.24219 0.820312 6.05819 0.820312 5.83203V5.01172C0.820312 4.78556 1.00431 4.60156 1.23047 4.60156H5.35938V6.24219ZM7.82031 13.6797H6.17969V4.60156C6.26563 4.60156 7.34891 4.60156 7.82031 4.60156V13.6797ZM12.3594 13.2695C12.3594 13.4957 12.1754 13.6797 11.9492 13.6797H8.64062V7.0625H12.3594V13.2695ZM13.1797 5.83203C13.1797 6.05819 12.9957 6.24219 12.7695 6.24219H8.64062V4.60156H12.7695C12.9957 4.60156 13.1797 4.78556 13.1797 5.01172V5.83203Z" fill="#B00A2C"></path>' + ' </svg>'; function init() { if (debug) { console.log('Inside init Function'); } var RightSection = document.querySelector(".product-detail-row .right-column"); document.querySelector(".product-detail-row .left-column").insertAdjacentElement("beforeBegin", RightSection); var Title = document.querySelector(".page-heading.product"); document.querySelector(".product-detail-row .right-column").insertAdjacentElement("beforeBegin", Title); document.querySelector(".more .readmore").click() var ATC = document.querySelector(".product-add-to-cart"); document.querySelector(".product-stats").insertAdjacentElement("beforeBegin", ATC); if (document.querySelector(".price-container .opt9-addmore") && !document.querySelector(".new-strip")) { document.querySelector(".price-container .opt9-addmore").insertAdjacentHTML("afterend", NewStrip); } if (!document.querySelector(".opt9-group")) { document.body.classList.add("not-persent") } setTimeout(() => { if (!document.querySelector('.left-column .product-info')) { var Bars = document.querySelector('.product-info').outerHTML; document.querySelector(".product-stats").insertAdjacentHTML("afterend", Bars); } }, 1500); waitForElement(".input-quantity", offerBanner, 50, 15000); // waitForElement(".left-column .product-info", infobars, 50, 25000); } // function infobars(){ // var Bars = document.querySelector('.product-info').outerHTML; // document.querySelector(".product-stats").insertAdjacentHTML("afterend", Bars); // } function rightATCscetion() { // Wrap ATC section function wrap(el, wrapper) { el.parentNode.insertBefore(wrapper, el); wrapper.appendChild(el); } wrap(document.querySelector('.product-add-to-cart '), document.createElement('div')); document.querySelector(".product-add-to-cart ").parentElement.classList.add("atc-outer-container"); // no re setTimeout(() => { if (!document.querySelector(".right-logo-section")) { document.querySelector(".atc-outer-container .product-add-to-cart").insertAdjacentHTML("afterend", logoSection); } }, 1500); // if(document.querySelector('.opt9-group')){ // var bottomlogo = document.querySelector('.opt9-group').innerHTML; // document.querySelector(".atc-outer-container .banner-scetion").insertAdjacentHTML('afterbegin', bottomlogo); // } waitForElement(".atc-outer-container .banner-scetion", optgroup, 50, 15000); } function optgroup() { if (document.querySelector('.opt9-group')) { var bottomlogo = document.querySelector('.opt9-group').innerHTML; document.querySelector(".atc-outer-container .banner-scetion").insertAdjacentHTML('afterbegin', bottomlogo); } } function qty() { document.querySelector('.input-quantity').insertAdjacentHTML("afterend", '<div class="qty-container"><a class="plus">+</a> <a class="minus">-</a></div>'); document.querySelector('.plus').addEventListener("click", () => { document.querySelector(".input-quantity").setAttribute("value", parseInt(document.querySelector(".input-quantity").getAttribute('value')) + 1); document.querySelector(".input-quantity").value = parseInt(document.querySelector(".input-quantity").getAttribute('value')); document.querySelector('.input-quantity').dispatchEvent(new Event('change', { 'bubbles': true })) // change value if (document.querySelector(".new-strip .opt9-addcount")) { var valueminus = document.querySelector(".input-quantity").value; var minusvalue = parseInt(valueminus); console.log(minusvalue) vwo_$(".new-strip .opt9-addcount").text(12 - minusvalue); } }) document.querySelector('.minus').addEventListener("click", () => { if (parseInt(document.querySelector(".input-quantity").getAttribute('value')) > 0) { document.querySelector(".input-quantity").setAttribute("value", parseInt(document.querySelector(".input-quantity").getAttribute('value')) - 1); document.querySelector(".input-quantity").value = parseInt(document.querySelector(".input-quantity").getAttribute('value')); document.querySelector('.input-quantity').dispatchEvent(new Event('change', { 'bubbles': true })) // change value if (document.querySelector(".new-strip .opt9-addcount")) { var valueminus = document.querySelector(".input-quantity").value; var minusvalue = parseInt(valueminus); console.log(minusvalue) vwo_$(".new-strip .opt9-addcount").text(12 - minusvalue); } } }) } function iconClick() { live(".new-strip a", "click", function() { document.querySelector(".optpop-pophold").classList.add("optpop-pophold-active"); document.querySelector(".optpop-bg").style.display = "block"; }); } function OTSproduct() { if (!document.querySelector(".new-oos-cta")) { document.querySelector(".price-container").insertAdjacentHTML("afterend", "<a class='new-oos-cta'>Out of stock</a>"); } } function AvgValue() { var AvgValueSelector = document.querySelector(".grey-bar span").innerText; var getAvgValue = AvgValueSelector.substring( AvgValueSelector.indexOf("$") + 1, AvgValueSelector.lastIndexOf(".") ); if (!document.querySelector(".new-avg-value")) { document.querySelector(".product-add-to-cart .grey-bar").insertAdjacentHTML("afterend", "<p class='new-avg-value'>You're saving <span class='price-color'>$" + getAvgValue + "</span> on RRP</p>"); } } if (document.querySelector(".product-add-to-cart .opt9-addmore .opt9-addcount")) { vwo_$('body').on('DOMSubtreeModified', '.product-add-to-cart .opt9-addmore .opt9-addcount', function() { var offerval = document.querySelector(".product-add-to-cart .opt9-addmore .opt9-addcount").innerText; document.querySelector(".new-strip .opt9-addmore").innerText = offerval; }); } vwo_$('body').on('DOMSubtreeModified', '.grey-bar span', function() { var AvgValue = document.querySelector(".grey-bar span").innerText; var getAvgValuee = AvgValue.substring( AvgValue.indexOf("$") + 1, AvgValue.lastIndexOf(".") ); document.querySelector(".new-avg-value .price-color").innerText = "$" + getAvgValuee; vwo_$(".input-quantity").on("change paste keyup click", function() { var quntityval = document.querySelector(".input-quantity").value; if (parseInt(quntityval) == 0) { document.querySelector(".new-avg-value").style.display = "none"; } else { document.querySelector(".new-avg-value").style.display = "block"; } }); }); function offerBanner() { vwo_$(".input-quantity").on("change paste keyup click", function() { var quntity = document.querySelector(".input-quantity").value; if (parseInt(quntity) >= 12) { document.querySelector(".saving-strip span.opt9-saving ").style.display = "block"; document.querySelector(".new-strip").style.display = "none"; } else { document.querySelector(".saving-strip span.opt9-saving ").style.display = "none"; document.querySelector(".new-strip").style.display = "block"; } }); }; // Adding new wineDetaile Section function WineDetailSection() { var BannerSelector = document.querySelector(".product-detail ").parentElement; if (!document.querySelector(".kb-product-details")) { BannerSelector.insertAdjacentHTML("afterend", WineDetails); setTimeout(() => { waitForElement(".kb-left-container .inner p", largeText, 100, 25000); }, 500); } if (document.querySelector(".product-detail-intro-copy .inner >p")) { document.querySelector('.kb-product-details').style.display = "block"; var productDetail = document.querySelector('.product-table').outerHTML; document.querySelector(".kb-wine-details").insertAdjacentHTML("afterend", productDetail); document.querySelector(".kb-wine-discription ").insertAdjacentElement("afterend", document.querySelector(".product-detail-intro-copy .inner ")); } if (document.querySelector(".cellar-door-cta") != null) { document.querySelector(".kb-vartical-banner-conatiner").style.display = "block"; var ctaLink = document.querySelector(".cellar-door-cta .inner .cta a").getAttribute("href"); if (document.querySelector(".cellar-door-cta .inner .lead") != null) { var bannerText = document.querySelector(".cellar-door-cta .inner .lead").innerText; } if (!document.querySelector(".learn-more-section")) { document.querySelector('.kb-vartical-banner-inner-conatiner').insertAdjacentHTML("beforeend", '<div class="learn-more-section"><div class="inner-learn-more"><div class="bottel-img"><img src="https://www.wineselectors.com.au/getmedia/558fe174-db79-4d64-99b2-9e835febe35c/Group-17"></div><div class="text-more"><p>' + bannerText + '</p></div><a href="' + ctaLink + '" class="learn-more-cta">Learn more</a></a></div></div>'); } } if (document.querySelector(".product-detail-accordion.accordion .contents > div.copy > div.inner") != null) { document.querySelector(".kb-pack-contents-container").style.display = "block"; var PackSelector = document.querySelector(".product-detail-accordion.accordion .contents > div.copy > div.inner").innerHTML; document.querySelector(".kb-pack-contents-title").insertAdjacentHTML("afterend", PackSelector); var Packqty = document.querySelectorAll(".kb-pack-contents-inner-container .product-tile .name"); Packqty.forEach(function(e) { e.insertAdjacentHTML("afterend", "<p><b>QTY: 1<b></p>") }) } } // function giftSection(){ // document.querySelector(".gf-creation__button .gf-creation__button_text").insertAdjacentHTML("afterend", "<p class='gift-icon'>" + Gift_Icon + "</p>"); // document.querySelector(".gf-creation__button .gf-creation__button_text >div").innerText="Send as an instant gift" // document.querySelector(".gf-learnMore .learnMore").innerHTML="Powered by <b>gift flick</b> <span class='learn-more-text'>learn more</span>" // } function largeText() { var $ = vwo_$; if (!document.querySelector(".showless")) { document.querySelector(".kb-left-container .inner>p:last-of-type").insertAdjacentHTML("beforeend", " <a class='showless'>Show less</a>") } setTimeout(() => { var elems = $('.kb-left-container .inner p:first-of-type'); elems.each(function() { var elem = $(this); if (document.querySelector(".kb-left-container p br:first-of-type")) { var textParts = elem.html().split("<"); var first = "<span class='kb-first-para'>" + textParts.shift() + "</span> <a class='showmore'>Show more</a>"; var test = "<span class='kb-second-para'> <" + textParts.join("<") + "</span>"; } else if (!document.querySelector(".kb-left-container p br:first-of-type")) { var textParts = elem.html().split("."); var first = "<span class='kb-first-para'>" + textParts.shift() + "</span> <a class='showmore'>Show more</a>"; var test = "<span class='kb-second-para'> <" + textParts.join(".") + "</span>"; } elem.html(first + test); }); $(".showmore").click(function() { $(".kb-left-container .inner").addClass("show"); }); $(".showless").click(function() { $(".kb-left-container .inner").removeClass("show"); }); }, 500); // setTimeout(() => { // if($(".kb-second-para br:first-of-type +br ")){ // $(".kb-second-para br:first-of-type").remove() // } // }, 600); } waitForElement(".product-detail-row .right-column", init, 50, 20000); waitForElement(".product-add-to-cart, .atc-outer-container .banner-scetion", rightATCscetion, 50, 15000); waitForElement(".product-add-to-cart .quantity-row .quantity-col", qty, 50, 20000); waitForElement(".new-strip a", iconClick, 50, 20000); waitForElement(".stock-col .availability .stock-red", OTSproduct, 50, 10000); waitForElement(".product-add-to-cart .grey-bar", AvgValue, 50, 20000); waitForElement(".product-detail", WineDetailSection, 50, 20000); //waitForElement(".gf-creation__button .gf-creation__button_text >div ", giftSection, 50, 20000); } catch (e) { if (debug) console.log(e, "error in Test" + variation_name); } })();