Untitled

 avatar
unknown
plain_text
2 years ago
16 kB
5
Indexable
<style>
/*hiding elements*/
.wizard-body>div:nth-child(2)>div>div.pb-5 #content-title,
.wizard-body>div:nth-child(2)>div>div.pb-5 .rounded-top,
.wizard-body>div:nth-child(2)>div>div.pb-5 .separator,
.wizard-body>div:nth-child(2)>div>div.pb-5 .separator+h3,
.wizard-body>div:nth-child(2)>div>div.pb-5 .separator+h3+div,
.wizard-body>div:nth-child(2)>div>div.pb-5 .separator+h3+div+div>*:not(strong, .eg_dropdown),
.wizard-body>div:nth-child(2)>div>div.pb-5 .separator+h3+div~:not(.m-0.my-4:has(.eg_dropdown), strong, .eg_dropdown) {
    display: none !important;
}

.eg_dropdown {
    display: block !important;
}

.wizard-body strong {
    display: unset !important;
}

.wizard-body strong>div:nth-child(2) {
    display: none;
}

/*hiding elements*/


html body .wizard-body.eg_paymentStep .pb-5 .eg_dropdown+strong {
    display: block !important;
}

html body .paymentPageCheckbox {
    margin-bottom: 2.5rem !important;
}

html body .eg_dropdown p {
    margin: 0;
}

html body .eg_finalPrice {
    background: #F7EEDE;
    border-radius: 10px;
    margin-bottom: 12px;
}

html body .eg_finalPrice p {
    padding: 5px 15px;
    font-weight: 600;
    font-size: 18px;
    line-height: 25px;
}

html body .eg_disclaimer {
    text-align: center;
    font-weight: 400;
    font-size: 14px;
    line-height: 19px;
    margin-bottom: 25px !important;
}

html body .eg_tab {
    margin-bottom: 22px;
    background: #FEFEFE;
    border: 4px solid #F5F5F5;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}

html body .eg_tab:not(.eg_active) {
    border-radius: 14px;
}



html body .eg_tab .eg_title {
    padding: 14px 0 14px 50px;
    background: #F5F5F5;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
}

html body .eg_tab .eg_title p {
    font-weight: 600;
    font-size: 16px;
    line-height: 22px;
}

html body .eg_tab .eg_title span {
    position: absolute;
    left: 20px;
    top: 14px;
    font-weight: 600;
    font-size: 20px;
    line-height: 27px;
}

html body .eg_tab .eg_title span.openIcon {
    top: 10px;
}

html body .eg_tab .eg_title span i {
    color: #000;
    font-size: 22px;
}

html body .eg_tab .eg_title span.openIcon {
    transform: rotate(180deg);
}

html body .eg_tab .eg_title span.openIcon,
html body .eg_tab.eg_active .eg_title span.closeIcon {
    display: none;
}

html body .eg_tab.eg_active .eg_title span.openIcon {
    display: block;
}

html body .eg_tab .eg_body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
}


html body .eg_tab.eg_active .eg_body {
    max-height: 400px;
    transition: max-height 0.5s ease-in-out;
}


html body .eg_tab .eg_body>div {
    padding: 10px 20px;
}

html body .eg_tab .eg_body .eg_shippingOffer,
html body .eg_tab .eg_body .eg_gifts p,
html body .eg_tab .eg_body .days_of_food {
    font-weight: 600;
    font-size: 16px;
    line-height: 22px;
}

html body .eg_tab .eg_body .eg_deliveryDetails,
html body .eg_tab .eg_body .eg_shippingDetails,
html body .eg_tab .eg_body .eg_package {
    padding-left: 15px;
    margin: 10px 0;
}


html body .eg_tab .eg_body .eg_deliveryDetails p,
html body .eg_tab .eg_body .eg_shippingDetails p,
html body .eg_tab .eg_body .eg_package p {
    font-weight: 400;
    font-size: 14px;
    line-height: 19px;
    margin-bottom: 5px;
}

html body .eg_tab .eg_body .eg_deliveryDetails .eg_date {
    font-weight: 600;
}

html body .eg_tab .eg_body .eg_edit a {
    font-weight: 600;
    font-size: 16px;
    line-height: 22px;
}

html body .eg_tab .eg_body .eg_edit {
    text-align: right;
}
  strong div#bd_footer.footer {
    display: none !important;
}
</style>



(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    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 Functions****/
        // 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);
      }

      function getCookie(name) {
          var nameEQ = name + "=";
          var ca = document.cookie.split(';');
          for(var i=0;i < ca.length;i++) {
              var c = ca[i];
              while (c.charAt(0)==' ') c = c.substring(1,c.length);
              if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
          }
          return null;
      }

      function setCookie(name,value,days) {
          var expires = "";
          if (days) {
              var date = new Date();
              date.setTime(date.getTime() + (days*24*60*60*1000));
              expires = "; expires=" + date.toUTCString();
          }
          document.cookie = name + "=" + (value || "")  + expires + "; path=/";
      }


    /* Variation functions */

    /* Variation Init */
    function initUserDetails() {
      /* start your code here */

      live('#bd_wizard #btnSubmit','click',function(){
        var firstName = document.querySelector('[name="first-name"]').value;
        var lastName = document.querySelector('[name="surname"]').value;
        var postCode = document.querySelector('[name="billing-postcode"]').value;
        var addrOne = document.querySelector('[name="billing-address1"]').value;
        var addrTwo = document.querySelector('[name="billing-address2"]').value;
        var city = document.querySelector('[name="billing-city"]').value;

        var fullName = firstName +' '+ lastName;
        var address1 = addrOne;
        var address2 = addrTwo;
        var state = city +' '+postCode;

        setCookie('eg_fullName', fullName, 365);
        setCookie('eg_address1', address1, 365);
        setCookie('eg_address2', address2, 365);
        setCookie('eg_state', state, 365);
      })

    }

    function initDeliveryDate(){
      live('#bd_wizard #btnSubmit','click',function(){
        var chosenDate = document.querySelector('#txtStartDate').innerHTML.split(' ');
        var date = chosenDate[1];
        var month = chosenDate[2];

        var selectedDate = month +' '+date;
        setCookie('eg_date',selectedDate, 365);

      })
    }

    var eg_dropdown = ''+
    '<div class="eg_dropdown">'+
    '     <h3 class="mb-10 font-weight-bold text-dark"><p>The final step, summary &amp; payment.</p></h3>'+
    '     <div class="eg_orderSummary eg_tab">'+
    '           <div class="eg_title">'+
    '                 <span class="closeIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <span class="openIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <p>Order Summary</p>'+
    '           </div>'+
    '           <div class="eg_body">'+
    '               <div>'+
    '                 <p class="days_of_food"></p>'+
    '                 <div class="eg_package">'+
    '                 </div>'+
    '               </div>'+
    '           </div>'+
    '     </div>'+
    '     <div class="eg_shippingAddress eg_tab">'+
    '           <div class="eg_title">'+
    '                 <span class="closeIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <span class="openIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <p>Shipping Address</p>'+
    '           </div>'+
    '           <div class="eg_body">'+
    '               <div>'+
    '                 <p class="eg_shippingOffer"></p>'+
    '                 <div class="eg_shippingDetails">'+
    '                 </div>'+
    '                 <div class="eg_edit"><a href="https://hello.bellaandduke.com/user-details" class="shipping_edit">Edit</a></div>'+
    '               </div>'+
    '           </div>'+
    '     </div>'+
    '     <div class="eg_deliveryDate eg_tab">'+
    '           <div class="eg_title">'+
    '                 <span class="closeIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <span class="openIcon"> <i aria-hidden="true" class="fa fa-angle-down"></i> </span>'+
    '                 <p>Delivery Date</p>'+
    '           </div>'+
    '           <div class="eg_body">'+
    '               <div>'+
    '                 <p class="eg_shippingOffer"></p>'+
    '                 <div class="eg_deliveryDetails">'+
    '                       <p class="eg_firstDelivery">Your first delivery will arrive on</p>'+
    '                       <p class="eg_date"></p>'+
    '                 </div>'+
    '                 <div class="eg_edit"><a href="https://hello.bellaandduke.com/delivery" class="eg_dateEdit">Edit</a></div>'+
    '               </div>'+
    '           </div>'+
    '     </div>'+
    '     <div class="eg_finalPrice">'+
    '           <p>Your Final Price <span class="float-right"></span></p>'+
    '     </div>'+
    '     <p class="eg_disclaimer">You can pause or cancel anytime.</p>'+
    '</div>';

    function initPayment(){
      document.querySelector('.wizard-body').classList.add('eg_paymentStep')
      document.querySelector('.wizard-body .paymentPageCheckbox').parentElement.insertAdjacentHTML('beforebegin',eg_dropdown);

      var getFinalPrice = document.querySelector('.wizard-body .rounded-bottom span strong').innerHTML;
      document.querySelector('.eg_finalPrice span').innerHTML = getFinalPrice;

      var getDays = document.querySelector('.rounded-top h3').innerHTML;
      document.querySelector('.days_of_food').innerHTML = getDays + '<span class="float-right">'+getFinalPrice+'</span>';

      document.querySelectorAll('.wizard-body .pb-5 > h3:not(#content-title)').forEach(function(el){
        var getTitle = el.innerHTML;
        document.querySelector('.eg_package').insertAdjacentHTML('beforeend','<p class="eg_packageName">'+getTitle+'</p>');
      })

      var getWeight;
      var getRegularPrice;
      var getVoucher;
      var getShippingOffer;

      document.querySelectorAll('.p-1.text-white p').forEach(function(el){

        if(el.innerHTML.toLocaleLowerCase().indexOf('food') > -1){
          getWeight = el.querySelector('span').innerHTML;

        }

        if(el.innerHTML.toLocaleLowerCase().indexOf('regular') > -1){
          getRegularPrice = el.querySelector('span').innerHTML;

        }

        if(el.innerHTML.toLocaleLowerCase().indexOf('voucher') > -1){
          getVoucher = el.querySelector('span').innerHTML;

        }

        if(el.innerHTML.toLocaleLowerCase().indexOf('shipping') > -1){
          getShippingOffer = el.querySelector('span').innerHTML;

          document.querySelector('.eg_shippingAddress .eg_shippingOffer').innerHTML = 'Shipping <span class="float-right">'+getShippingOffer+'</span>';
          document.querySelector('.eg_deliveryDate .eg_shippingOffer').innerHTML = 'Shipping <span class="float-right">'+getShippingOffer+'</span>';
        }



      })

      if( getRegularPrice != null){
        document.querySelector('.eg_package').insertAdjacentHTML('beforeend','<p class="eg_packageWeight">'+getWeight+ '<span class="float-right"><s>'+getRegularPrice+'</s></span></p>');
      }else{
        document.querySelector('.eg_package').insertAdjacentHTML('beforeend','<p class="eg_packageWeight">'+getWeight+ '<span class="float-right">'+getFinalPrice+'</span></p>');
      }

      if( getVoucher != null){
        document.querySelector('.eg_package').insertAdjacentHTML('beforeend','<p class="eg_voucher"> Voucher '+getVoucher+'</p>');
      }


      if(document.querySelector('.text-primary')){
        document.querySelector('.eg_package').insertAdjacentHTML('afterend','<div class="eg_gifts"><p>Surprise Gift<span class="float-right">FREE</span></p></div>');
      }


      var eg_fullName = getCookie('eg_fullName');
      var eg_address1 = getCookie('eg_address1');
      var eg_address2 = getCookie('eg_address2');
      var eg_state = getCookie('eg_state');
      var eg_date = getCookie('eg_date');

      // insert address details
      document.querySelector('.eg_shippingDetails').innerHTML = ''+
      '<p class="eg_fullName">'+eg_fullName+'</p>'+
      '<p class="eg_address-one">'+eg_address1+'</p>'+
      '<p class="eg_address-two">'+eg_address2+'</p>'+
      '<p class="eg_state">'+eg_state+'</p>';


      // insert delivery date
      document.querySelector('.eg_date').innerHTML = eg_date;


      // checked the last checkbox
      document.querySelector('#checkboxThirdPartyMarketingQuestion').click();

      // toggle dropdown
      live('.eg_title','click',function(){
        if(this.parentElement.classList.contains('eg_active') == false){
          if(document.querySelector('.eg_active')){
            document.querySelector('.eg_active').classList.remove('eg_active');
          }
        }

        this.parentElement.classList.toggle('eg_active');

        var getTitle = this.querySelector('p').innerHTML;
        trackGAEvent('Wizard','Click','Module Open '+getTitle);
      })

      live('.eg_edit a','click',function(){
        var getTitle = this.closest('.eg_tab').querySelector('.eg_title p').innerHTML;
        trackGAEvent('Wizard','Click','Edit Link '+getTitle);
      })

    }

    function trackGAEvent(eventCategory, eventAction, eventLabel) {
            if ('ga' in window) {
              ga.getAll()[0].send('event', {
                eventCategory: eventCategory,
                eventAction: eventAction,
                eventLabel: eventLabel,
              });
            }
          }

    /* Initialize variation */
    if(window.location.pathname == '/user-details'){
      waitForElement("#bd_wizard #btnSubmit", initUserDetails, 50, 15000);
    }

    if(window.location.pathname == '/delivery'){
      waitForElement("#bd_wizard #btnSubmit", initDeliveryDate, 50, 15000);
    }

    if(window.location.pathname == '/payment'){
      if(getCookie('eg_fullName') != null){
        waitForElement(".wizard-body .paymentPageCheckbox", initPayment, 50, 15000);
      }
    }

  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();


Editor is loading...