Untitled

 avatar
unknown
plain_text
a year ago
12 kB
4
Indexable
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    var svg = `<svg class="pa" width="15" height="10" viewBox="0 0 15 10" fill="none"><line x1="1.41421" y1="1.75" x2="7.5" y2="7.83579" stroke="#333333" stroke-width="2" stroke-linecap="square"></line><line x1="1" y1="-1" x2="9.6066" y2="-1" transform="matrix(-0.707107 0.707107 0.707107 0.707107 15 1.75)" stroke="#333333" stroke-width="2" stroke-linecap="square"></line></svg>`

    var products = {
      "tshirts": [
        {
          "url": "/products/vacation-logo-swap-t-shirt",
          "text": "Vacation® Logo Swap T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/867f2c6878c9276a8d64d9f4611d898b01fcab71-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/refresh-and-protect-t-shirt",
          "text": "Refresh & Protect T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/960bc04ee81d938da03493a16ee2f3dffefeb148-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/arizona-logo-swap-t-shirt",
          "text": "AriZona® Logo Swap T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/c7e6f4b68802fc60a767600cfaab1ddb9bbf36c0-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/don-approved-t-shirt",
          "text": "\"Don Approved\" T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/7ad6b108f5b3bae60d89d5f9e275001b818ccadb-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-by-vacation-eau-de-toilette-t-shirt",
          "text": "VACATION by Vacation® Eau de Toilette T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/c3aafbf3afc110d7483c1e86e6babaab98d87679-1560x1430.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-tshirt-swisscoffee",
          "text": "Vacation® White T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/b741c7e23e47d7b5b02eb3d6ec407d3611e5a3a7-1658x1536.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/corporate-cookout-t-shirt",
          "text": "Corporate Cookout T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/a936876fd38fe9e3769fc1741dcef706f8176e8b-2000x1833.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-tshirt-poolwater",
          "text": "Vacation® Teal T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/7e8229904b2aaf3b607e1576f3c4f7f2b844fef5-2487x2304.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-tshirt-bluemoon",
          "text": "Vacation® Blue T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/71c6b80939758a6b2122ead7b432583fa96038c9-1501x1401.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/summer-summit-t-shirt",
          "text": "Vacation® Summer Summit T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/b4eb609e265101b4834aa1fe2e85710ee1c61f4a-1501x1401.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/poolsuite-tshirt",
          "text": "Poolsuite FM Off-White T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/7d743972b0f679fe0e96dd57ad34c063f9976906-1501x1401.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/office-holiday-t-shirt",
          "text": "Office Holiday Party T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/75f56675e29c87c31e047f7c426a12d7a5faeb92-1501x1401.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-leisure-services-t-shirt",
          "text": "Vacation® Leisure Services T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/2c857653f4c66548efa1e4343f9142ffe9234ad7-2000x1853.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/prince-tshirt",
          "text": "Prince® x Vacation® T-Shirt",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/8a99b7a04303a85e3007dbb3e9e37ad0bc5a0121-2000x1383.jpg?auto=format&q=75&w=800"
        },
      ],
      "caps": [
        {
          "url": "/products/perfection-hat",
          "text": "\"Perfection\" Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/47f06992cd1662a7364932cb3ffb29ade71e11a6-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-logo-swap-hat",
          "text": "Vacation® Logo Swap Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/c219ae37b2a84c126801ec0b1297b15e2e1255bb-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/arizona-logo-swap-hat",
          "text": "AriZona® Logo Swap Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/90bc52f091d0f1f313e98d4942823d07a492a31b-1997x2000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-visor",
          "text": "Vacation® Visor",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/d19e59ae09a9c0b2a1ee3f2a97359f0ddc1dad41-1658x1536.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-hat-white",
          "text": "Vacation® White Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/7bdc64f5dd13fecdc34795e4ef3cba3d8fa63ec7-1920x1710.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/poolsuite-hat",
          "text": "Poolsuite FM Black Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/339c868cf14791ad61eb4200e655260e746666bf-1658x1536.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-hat-skyblue",
          "text": "Vacation® Blue Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/f12cb490a41f58b8468d4d029c33288c583e5eed-1658x1536.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/vacation-leisure-services-hat",
          "text": "Vacation® Leisure Services Hat",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/a3e8c4e83984e8b271108792d642e0459d6143fd-2000x1853.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/prince-cap",
          "text": "Prince® x Vacation® Cap",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/eab4d53a5b8033321727ca5b008a71f5e2da6699-2000x1383.jpg?auto=format&q=75&w=800"
        }
      ],
      "airfresheners": [
        {
          "url": "/products/super-spritz-air-freshener",
          "text": "Super Spritz Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/fd7080ad340c99af47b2b8c2cbfa37708e1154d8-2000x1833.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/baby-oil-air-freshener",
          "text": "Baby Oil Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/dcec22c98a5f2f6d765eec6795b6c0f4c5188b7d-2000x1833.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/air-freshener",
          "text": "Vacation® Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/6c27a0141ce72b4798090258bf1ca5566cde1cff-901x1000.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/after-sun-gel-air-freshener",
          "text": "After Sun Gel Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/7f798e773507dabe3e3630510af7802eb66afdbd-2000x1833.png?auto=format&q=75&w=800"
        },
        {
          "url": "/products/classic-whip-air-freshener",
          "text": "Classic Whip Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/f13baf3b8907b9e2a4ca7728651175a04341179f-2000x1737.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/chardonnay-air-freshener",
          "text": "Vacation® Chardonnay Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/2ddeb58d2406a7aa2c4e555a90f234e17243a8fb-1717x1491.jpg?auto=format&q=75&w=800"
        },
        {
          "url": "/products/ball-boy-air-freshener",
          "text": "Ball Boy Air Freshener",
          "image": "https://cdn.sanity.io/images/kie4hq77/development/81c52c6624ad61da4b9fd8abdaa6ad06048bdf26-2000x1833.jpg?auto=format&q=75&w=800"
        }
      ]
    }

    /* 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) {
      function addEvent(el, type, handler) {
        if (el.attachEvent) el.attachEvent('on' + type, handler);
        else el.addEventListener(type, handler);
      }
      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);
      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);
    };

    live("html body .eg-dropdown > .eg-dropbtn", "click", function () {
      document.body.classList.toggle("eg-show");
    })

    var productType = "tshirts"; // Default to t-shirts if not found
    var url = window.location.pathname;
    if (url.includes("air-freshener")) {
      productType = "airfresheners";
    } else if (url.includes("cap")) {
      productType = "caps";
    }

    // Find the product data based on the product type
    var productDataList = products[productType];

    // Create dropdown items for each product
    var dropDownItems = productDataList.map(function (productData) {
      return `
        <a href="${productData.url}" class="eg-content-1">
          <img src="${productData.image}" class="eg-product-image">
          <span class="eg-product-name">${productData.text}</span>
        </a>`;
    }).join('');

    var h2Text = productDataList[0].text;

    var dropDown = `
      <div class="eg-dropdown">
        <button class="eg-dropbtn">${h2Text} ${svg}</button>
        <div class="eg-dropdown-content" id="eg-myDropdown">
          ${dropDownItems}
        </div>
      </div>`;


    /* Variation Init */
    function init() {
      if (!document.querySelector('.eg-dropdown')) {
        document.querySelector('.site__wrapper .pdp-container:first-child > div:nth-child(2)').insertAdjacentHTML('afterend', dropDown);
      }
    }

    /* Initialize variation */
    waitForElement('.site__wrapper .pdp-container:first-child > div:nth-child(2)', init, 1000, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();
Editor is loading...
Leave a Comment