Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
22 kB
4
Indexable
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var pdImages = {
      '/products/square-chain-bracelet': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/MerlinMix_720x.jpg?v=1678789022",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-18_720x.jpg?v=1666317481"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-18_720x.jpg?v=1678789022"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div ul",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  h6:nth-of-type(4)"
        }
      },
      '/products/box-chain-bracelet': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/ExclusiveUnisizeCuff_BoxChainBracelet_900x.jpg?v=1678789263",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-20_900x.jpg?v=1666317567 "
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-47_900x.jpg?v=1674141238"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div p:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  h6:nth-of-type(4)"
        }
      },
      '/products/wire-chain-bracelet': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/WireChainPool_e80969f5-bb51-4ff0-8c0e-94ef14db21ed_900x.jpg?v=1663404133",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-35_900x.jpg?v=1663404133"
        },
        "gld": {
          "wtr": "https://us.vacier.com/cdn/shop/products/GoldLifestyleShot-2_540x.jpg?v=1697451679",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-45_900x.jpg?v=1663404133"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div div:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  h6:nth-of-type(4)"
        }
      },
      '/products/minimal-chain-bracelet': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-36_900x.jpg?v=1663401618"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-51_120ae9f8-c475-49de-8ac7-c57475c82d78_720x.jpg?v=1663431972"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  p:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  h6:nth-of-type(4)"
        }
      },
      '/products/unisize-ring': {
        "slvr": {
          "wtr": "https://us.vacier.com/cdn/shop/files/DSC04752-Redigera_540x.jpg?v=1697451362",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-17_720x.jpg?v=1674144872"
        },
        "gld": {
          "wtr": "https://vacier.com/cdn/shop/products/GoldUnisizieRing_720x.jpg?v=1674141663",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-17_720x.jpg?v=1674141663"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div p:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div  h6:nth-of-type(4)"
        }
      },
      '/products/unisize-cuff': {
        "slvr": {
          "wtr": "https://us.vacier.com/cdn/shop/products/SilverUnisizeCuff_1080x.jpg?v=1697451069",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-2_720x.jpg?v=1663407292"
        },
        "gld": {
          "wtr": "https://vacier.com/cdn/shop/products/GoldUnisizeCuff_720x.jpg?v=1674141525",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-8_720x.jpg?v=1674141525"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div div:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(4)"
        }
      },
      '/products/unisize-set': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/SetWaterFlares_f4dc2306-06e2-466b-83b4-5e86eee6c52d_720x.jpg?v=1663410053",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-3_720x.jpg?v=1663410053"
        },
        "gld": {
          "wtr": "https://us.vacier.com/cdn/shop/products/GoldUnisizieSet_SquareChain_BoxChain_20369b53-9150-492a-9209-3609f0fa8d2d_540x.jpg?v=1697451395",
          "rycl": "https://us.vacier.com/cdn/shop/products/Gold-3_540x.jpg?v=1697451395"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div p:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(5)"
        }
      },
      '/products/minimal-unisize-ring': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/MinimalSet-2_7625aa7b-2635-4b53-9b05-c059f8122e15_900x.jpg?v=1663408356",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-11_900x.jpg?v=1663408356"
        },
        "gld": {
          "wtr": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-37_900x.jpg?v=1663432923",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-11_900x.jpg?v=1663432923"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div div:nth-of-type(2)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(4)"
        }
      },
      '/products/minimal-unisize-cuff': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-6_900x.jpg?v=1663407957"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-5_720x.jpg?v=1663407957"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div ul",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(4)"
        }
      },
      '/products/minimal-unisize-set': {
        "slvr": {
          "wtr": "https://us.vacier.com/cdn/shop/products/MinimalSet-2_34757dea-1226-4942-a4f2-07bb571db675_540x.jpg?v=1697450425",
          "rycl": "https://us.vacier.com/cdn/shop/products/Silver-9_540x.jpg?v=1697450425"
        },
        "gld": {
          "wtr": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-38_720x.jpg?v=1663433065",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-9_720x.jpg?v=1663433065"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div div:nth-of-type(3)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(5)"
        }
      },
      '/products/square-pendant-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://us.vacier.com/cdn/shop/products/SquareChainNecklace-2_2cec9dcb-d061-4589-9fde-5cb3bda79ba2_540x.jpg?v=1697450932"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-23_720x.jpg?v=1683839507"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/box-pendant-necklace': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/BoxCHainNecklacePool_9f9f6809-44a4-4f84-a86f-08600ba4890f_900x.jpg?v=1683839240",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-25_720x.jpg?v=1683839240"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-23_720x.jpg?v=1683839240"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/wire-pendant-necklace': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/Wire_Chain_Jerome_83695256-2246-4715-8c13-d1b171760419_720x.jpg?v=1683839811",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-22_720x.jpg?v=1683839811"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-25_d5d83666-4b6b-4e0d-8395-9f829dbdfe46_720x.jpg?v=1663413546"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/minimal-pendant-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-24_720x.jpg?v=1683839416"
        },
        "gld": {
          "wtr": "https://vacier.com/cdn/shop/files/MinimalChainNecklace_2572a8df-982d-4b7d-8247-22484d7407aa_720x.jpg?v=1686736176",
          "rycl": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-15_fc0f168f-3ca3-4037-976f-85c92c58cd06_720x.jpg?v=1686736176"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/square-chain-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Silver-26_360x.jpg?v=1683839471"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-36_720x.jpg?v=1683839471"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/box-chain-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/BoxChainSingle_3bc399e4-dc35-4e99-8760-6d424174a8ac_900x.jpg?v=1683839178"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-21_720x.jpg?v=1663431652"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/wire-chain-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/WireChainNecklaceCombo-2_3e6e21a5-ff5b-4cf1-9e5d-f37188da5c9c_720x.jpg?v=1683839763"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/Gold-38_720x.jpg?v=1683839763"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/minimal-chain-necklace': {
        "slvr": {
          "wtr": "",
          "rycl": "https://us.vacier.com/cdn/shop/products/MinimalSingle_c9857a9c-c928-414e-9cc9-f0f531339a92_540x.jpg?v=1686734179"
        },
        "gld": {
          "wtr": "",
          "rycl": "https://vacier.com/cdn/shop/products/GoldLifestyleShot-16_720x.jpg?v=1683839336"
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div div:nth-of-type(1)",
          "rycl": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div h6:nth-of-type(3)"
        }
      },
      '/products/unisize-signet-ring-in-silver': {
        "slvr": {
          "wtr": "https://us.vacier.com/cdn/shop/files/SignetRing_MinimalCuff_3fc2de47-37cc-4032-8811-4c07ed39143c_900x.jpg?v=1697451556",
          "rycl": "https://us.vacier.com/cdn/shop/products/SignetRing3_900x.jpg?v=1697451556"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div",
          "rycl": ""
        }
      },
      '/products/unisize-signet-cuff-in-silver': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/SignetCuff_ec8039c7-3153-4539-ba15-0d90545b7dad_900x.jpg?v=1674703045",
          "rycl": "https://vacier.com/cdn/shop/products/SignetCuffOcean_900x.jpg?v=1674416013"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > p:first-of-type",
          "rycl": ""
        }
      },
      '/products/signet-set': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/SignetSet_SignetRing_900x.jpg?v=1674416140",
          "rycl": "https://vacier.com/cdn/shop/products/MainShots-4_900x.jpg?v=1674416140"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > div:nth-of-type(1)",
          "rycl": ""
        }
      },
      '/products/exclusive-unisize-wave-ring-in-silver': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/UnisizeWaveRing-4_720x.jpg?v=1674417671",
          "rycl": "https://vacier.com/cdn/shop/products/CloseUps-4_900x.jpg?v=1674417671"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > p:nth-of-type(2)",
          "rycl": ""
        }
      },
      '/products/exclusive-unisize-cuff-in-silver': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/ExclusiveUnisizeCuff_900x.jpg?v=1674703014",
          "rycl": "https://vacier.com/cdn/shop/products/MainShots-7_900x.jpg?v=1674415969"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > p:nth-of-type(1)",
          "rycl": ""
        }
      },
      '/products/exclusive-unisize-silver-set': {
        "slvr": {
          "wtr": "https://vacier.com/cdn/shop/products/ExclusiveUnisizeSet_720x.jpg?v=1674416063",
          "rycl": "https://vacier.com/cdn/shop/products/MainShots_720x.jpg?v=1674416084"
        },
        "gld": {
          "wtr": "",
          "rycl": ""
        },
        "selector": {
          "wtr": "[data-product-blocks] .station-tabs .station-tabs-tabset > div:first-of-type > div > p:nth-of-type(2)",
          "rycl": ""
        }
      },
    }


    var data, pathname;

    waitForElement = function (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);
    }

    live = function (selector, event, callback, context) {
      /****Helper Functions****/
      // helper for enabling IE 8 event bindings
      addEvent = function (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
      live = function (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 (el && found) callback.call(el, e);
        });
      }
      live(selector, event, callback, context);
    }
    init = function () {
      if (!document.querySelector(".eg-product-image")) {
        pathname = window.location.pathname.replace("/collections/shop", "");
        data = pdImages[pathname];
        console.log(data);
        // checking which color is clicked
        checkWhichColor();
        live(['[data-value="Silver"] input, [data-value="Gold"] input'], 'click', function () {
          checkWhichColor();
        });
      }
    }

    checkWhichColor = function () {
      // silver
      waitForElement('[data-value="Silver"] input:checked', function () {
        setImages("slvr");
      }, 50, 15000);
      // gold
      waitForElement('[data-value="Gold"] input:checked', function () {
        setImages("gld");
      }, 50, 15000);
      // exceptions
      if (pathname == "/products/exclusive-unisize-wave-ring-in-silver"
        || pathname == "/products/unisize-signet-ring-in-silver"
        || pathname == "/products/exclusive-unisize-cuff-in-silver"
        || pathname == "/products/exclusive-unisize-silver-set"
        || pathname == "/products/signet-set"
        || pathname == "/products/exclusive-unisize-cuff-in-silver"
        || pathname == "/products/unisize-signet-cuff-in-silver") {
        setImages("slvr");
      }
    }

    setImages = function (clr) {
      var wtrImg = "", rycleImg = "", sectionHTML = "";
      if (data[clr].wtr && data[clr].wtr !== "") {
        var imgsrc = data[clr].wtr || 'noimage';
        wtrImg = '' +
          '  <div class="eg-product-image eg-wtr">' +
          '      <img src="' + imgsrc + '" class="eg-img">' +
          "      <h6>WATERPROOF AND DURABLE</h6><p><span>All of Vacier's jewelry is crafted to be minimal yet durable. They are waterproof, making them suitable for use in the shower, sea, and pool. They can also withstand exposure to heat and sweat, making them perfect for everyday wear.</span></p>" +
          '  </div>';
      }
      if (data[clr].rycl && data[clr].rycl !== "") {
        var imgsrc = data[clr].rycl || 'noimage';
        rycleImg = '' +
          '  <div class="eg-product-image eg-rycl">' +
          '      <img src="' + imgsrc + '" class="eg-img">' +
          "      <h6>RECYCLED STAINLESS STEEL AND 18 K GOLD</h6><p><span>The original, silver-colored variant is made of recycled stainless steel. The gold variant is made of recycled stainless steel plated in 18-karat gold.</span></p>" +
          '  </div>';
      }
      sectionHTML = '<div class="eg-new-section">' + wtrImg + rycleImg + '</div>';
      if (!document.querySelector(".eg-new-section")) {
        document.querySelector("html body .station-tabs-tabpanel:nth-child(2)").insertAdjacentHTML("beforeend", sectionHTML);
      } else {
        document.querySelector(".eg-new-section").outerHTML = sectionHTML;
      }
    }

    /* Initialize variation */
    waitForElement('html body .station-tabs-tabpanel:nth-child(2)', init, 50, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();