Untitled

 avatar
unknown
plain_text
2 years ago
11 kB
4
Indexable
(function () {
    try {
      /* main variables */
      var debug = 0;
      var variation_name = "";
      /* 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 setCookie (name, value, days) {
       localStorage.setItem('egHidePopup11',true);
      }
      function getCookie (name) {
       return localStorage.getItem('egHidePopup11');
      }
      /* Variation functions */
      var htmlString =''+ 
      '  <div class="overlayofadd overlayshow ">'+ 
      '      <div class="overlay-wrapper">'+ 
      '          <div class="image_and_title">'+ 
      '              <img class="product_img_1" src="https://images.wineselectors.com.au/media/vwo/3482CT-Pack-With-Node.png">'+ 
      '          </div>'+ 
      '          <div class="info_container">'+ 
      '              <p class="first_name"><span class="product_added"></span>, secret members only offer!</p>'+ 
      '              <p class="save_now"><strong>Give the gift of fun with Battle of the Senses! </strong></p>'+ 
      '              <p class="product_name">Get 3 mystery wines from the ultimate wine tasting challenge. Sure to be the favourite under the tree!</p>'+          
      '              <p class="product_offer">RRP $80, yours for only $60!</p>'+
      '              <p class="quantity_bottles">Quantity</p>'+ 
      '              <div class="overlay_button_wrapper">'+ 
      '                  <div>1</div><button class="continue_shop">Add to Cart</button>'+ 
      '                  <a href="https://www.wineselectors.com.au/product/battle-of-the-senses-festive-edition-mixed-3-pack/226213">'+ 
      '                      <div class="view_cart_redirect">View Product</div>'+ 
      '                  </a>'+ 
      '              </div>'+ 
      '          </div>'+ 
      '          <p class="close_icon">&times;</p>'+ 
      '      </div>'+ 
      '  </div>';
      /* Variation Init */
     function init(){
         document.querySelector('body footer').insertAdjacentHTML('afterend', htmlString);
        document.querySelector('.continue_shop').addEventListener('click', () => {
            const jsondata = {
                "quantity": 1,
                "sku": "226213",
                "value": null,
                "frequency": null,
                "startDate": null,
                "varieties": null,
                "years": null
            }
            sendData(jsondata);
        });
        document.querySelector('p.close_icon').addEventListener('click', () => {
            document.querySelector('.overlayofadd').remove();
            setCookie('egHidePopup11', 'true', 365);
        });
       document.querySelector('.view_cart_redirect').addEventListener('click', () => {
          setCookie('egHidePopup11', 'true', 365);
      });
     
     }
  function sendData(jsondata){
    const xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
    const theUrl = 'https://www.wineselectors.com.au/api/cart/add';
    xmlhttp.open('POST', theUrl);
    xmlhttp.setRequestHeader('Content-Type', 'application/json');
    xmlhttp.send(JSON.stringify(jsondata));
    xmlhttp.onreadystatechange = () => { // Call a function when the state changes.
        if (xmlhttp.readyState === 4 && (xmlhttp.status === 200 || xmlhttp.status === 204)) {
          setCookie('egHidePopup11', 'true', 365);
            location.reload();
        }
    };
  }
      function init1(){
        if(document.querySelector('.cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-mixed-3-pack-226213"], .cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-red-3-pack-226214"], .cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-white-3-pack-226215"]'))
       document.querySelector('.overlayofadd').remove();
        
     }
      /* Initialize variation */
          if(!getCookie('egHidePopup11')){
         waitForElement('body', init, 50, 15000);
      waitForElement('.cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-mixed-3-pack-226213"], .cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-red-3-pack-226214"], .cart-list .cart-item .image-container a[href="/wine-shop/mixed/battle-of-the-senses-festive-edition-white-3-pack-226215"]', init1, 50, 15000);
          }
    } catch (e) {
      if (debug) console.log(e, "error in Test" + variation_name);
    }
  })();




.overlayofadd {
    position: fixed;
    display: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    cursor: pointer;
}

.overlayofadd.overlayshow {
    display: block !important;
}

.overlay-wrapper {
    width: 90%;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    margin: auto;
    max-width: 784px;
    background: white;
    text-align: center;
    padding: 40px 0px;
    display: flex;
    border-radius: 15px;
}


.overlay-wrapper .image_and_title {
    width: 35%;
    height: 250px;
    max-width: 250px;
    background: url("https://images.wineselectors.com.au/media/vwo/3482CT-Pack-With-Node.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    margin-left:30px
}
.overlay-wrapper .image_and_title img {visibility: hidden;}
img.product_img_1 {
    height: 100%;
}

.overlay-wrapper .info_container {
    width: 55%;
    margin: 0% 10%;
    text-align: left;
}

.overlay_button_wrapper>button {
    width: 100%;
    margin: 0px 2% 0px;
    height: 40px;
    line-height: 24px;
    max-width: 130px;
    background: #B00A2C;
    border-radius: 6px;
}
p.quantity_bottles {
    font-family: 'Helvetica Neue', sans-serif;
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 17px;
    color: #484944;
}


.overlay_button_wrapper>div {
    width: 20%;
    border: 1px solid;
    height: 40px;
    padding: 10px 10px;
    border-radius: 5px;
}

.overlay_button_wrapper {
    display: flex;
}

.overlay_button_wrapper a {
    width: 36%;
    height: 40px;
    max-width: 120px;
}
.overlay_button_wrapper a>div:hover{
    text-decoration: none;
}
.overlay_button_wrapper a>div {
    width: 100%;
    margin: 0px 2% 0px;
    height: 40px;
    line-height: 40px;
    background: white;
    color: #b81237;
    text-decoration: underline;
    text-align: center;
    text-transform: uppercase;
}

p.product_offer {
    margin-bottom: 15px;
    margin-top: 10px;
    font-family: 'Helvetica Neue', sans-serif;
    font-style: normal;
    font-weight: 700;
    font-size: 14px;
    line-height: 147.69%;
    color: #484944;
}

p.product_name {
    margin-bottom: 0px;
    font-family: 'Helvetica Neue', sans-serif;
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 19px;
    color: #302D3D;
}

p.save_now {
    font-family: 'Helvetica Neue', sans-serif;
    font-style: normal;
    font-size: 20px;
    line-height: 122.69%;
    color: #B00A2C;
    margin-bottom: 10px;
    font-weight: 400;
}

p.close_icon {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 49px;
    font-weight: 600;
    color: #adadad;
    line-height: 21px;
    margin: 0px !important;
    cursor: pointer;
    font-family: 'Poppins';
}

p.first_name {
    font-size: 18px;
    width: calc(100% - 30px);
   font-family: 'ITC Serif Gothic Std',sans-serif;
    color: #484944;
    font-weight: 400;
   display:none;
}

@media (max-width:768px) {
    .overlay-wrapper {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        max-width: 442px;
    }

    .image_and_title {
        width: 100% !important;
        height: 200px !important;
       margin-left:0 !important;
    }

    .info_container {
        width: 100% !important;
        text-align: center !important;
        margin: 0px !important;
        padding: 0px 20px !important;
    }

    .overlay_button_wrapper {
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        text-align: center;
    }


    .overlay_button_wrapper>a {
        width: 88%;
        margin: 10px 0px 0px;
        max-width: unset;
    }

    p.close_icon {
        right: 10px;
    }
    p.first_name {
        margin-top: 20px;
        width: 100% !important;
        padding: 0 20px;
    }
}
html body .quantity_bottles {
    font-family: 'Helvetica Neue', sans-serif !important;
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 17px;
    color: #484944;
}


@media screen and (max-height:450px) {
    html body .overlay-wrapper {
        display: flex;
        top: 50%;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        max-width: 442px;
        max-height: 90vh;
        overflow-y: auto;
        transform: translateY(-50%);
    }
    html body .overlay_button_wrapper {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    html body .overlay_button_wrapper a {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }
    html body .overlay-wrapper .info_container {
        width: 100% !important;
        margin: 0% !important;
        text-align: center !important;
    }
}
Editor is loading...