Untitled

 avatar
unknown
plain_text
3 years ago
9.8 kB
5
Indexable
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";

    /* helper library */
    var _$;
    !(function (factory) {
      _$ = factory();
    })(function () {
      var bm = function (s) {
        if (typeof s === "string") {
          this.value = Array.prototype.slice.call(document.querySelectorAll(s));
        }
        if (typeof s === "object") {
          this.value = [s];
        }
      };
      bm.prototype = {
        eq: function (n) {
          this.value = [this.value[n]];
          return this;
        },
        each: function (fn) {
          [].forEach.call(this.value, fn);
          return this;
        },
        log: function () {
          console && console.log(this);
        },
         live : function(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);
          },
        waitForElement: function (
          selector,
          trigger,
          delayInterval,
          delayTimeout
        ) {
          var interval = setInterval(function () {
            if (_$(selector).value.length) {
              clearInterval(interval);
              trigger();
            }
          }, delayInterval);
          setTimeout(function () {
            clearInterval(interval);
          }, delayTimeout);
        },
      };
      return function (selector) {
        return new bm(selector);
      };
    });

    var helper = _$();
    /* Variation Init */
    function init() {
      if(document.querySelector('.eg_button-column')) return;

      document.querySelectorAll('.market-availability').forEach(function(el){
        el.parentElement.insertAdjacentHTML('afterend','<td class="spec eg_button-column"><div>View Part</div></td>')
      })

      helper.live('.eg_button-column div','click',function(){
        this.parentElement.closest('tr').querySelector('.mpn a').click();
      })

      document.querySelectorAll('tr.columns > th').forEach(function(el){
        if(el.innerHTML.toLocaleLowerCase() == 'market availability'){
          el.insertAdjacentHTML('afterend','<th></th>');
        }
      })

      document.querySelectorAll('tr.groups > th').forEach(function(el){
        if(el.innerHTML.toLocaleLowerCase() == 'market data'){
          el.setAttribute('colspan','4');
        }
      })

      if(document.querySelectorAll('tr.sorts-filters th')[5]){
        document.querySelectorAll('tr.sorts-filters th')[5].insertAdjacentHTML('afterend','<th><div class="jsx-2157070 sort-and-filter"><button type="button" class="jsx-2157070 up"><svg viewBox="0 0 256 512" class="jsx-4181420323"><path d="M136.5 185.1l116 117.8c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L128 224.7 27.6 326.9c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17l116-117.8c4.7-4.6 12.3-4.6 17 .1z" fill="#333333" class="jsx-4181420323"></path></svg></button><button type="button" class="jsx-2157070 filter"><svg viewBox="0 0 496 512" class="jsx-2808761772 bullseye"><path d="M248 104c-84.02 0-152 68-152 152 0 84.02 68 152 152 152 84.02 0 152-68 152-152 0-84.02-68-152-152-152zm0 256c-57.35 0-104-46.65-104-104s46.65-104 104-104 104 46.65 104 104-46.65 104-104 104zm0-352C111.03 8 0 119.03 0 256s111.03 248 248 248 248-111.03 248-248S384.97 8 248 8zm0 448c-110.28 0-200-89.72-200-200S137.72 56 248 56s200 89.72 200 200-89.72 200-200 200zm0-256c-30.88 0-56 25.12-56 56s25.12 56 56 56 56-25.12 56-56-25.12-56-56-56z" fill="#333333" class="jsx-2808761772"></path></svg></button><button type="button" class="jsx-2157070 down"><svg viewBox="0 0 256 512" class="jsx-4181420323"><path d="M119.5 326.9L3.5 209.1c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0L128 287.3l100.4-102.2c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L136.5 327c-4.7 4.6-12.3 4.6-17-.1z" fill="#333333" class="jsx-4181420323"></path></svg></button></div></th>');
      }

    }

    document.addEventListener('click',function(){
      helper.waitForElement(".pagination.sticky-content,.supply-chain-value", init, 50, 15000);
      checkSelectedButton();
    })

    function checkSelectedButton(){
      setTimeout(function(){
        if(document.querySelector('.prices-view')){
          document.body.classList.add('eg_pricing');
        }else{
          document.body.classList.remove('eg_pricing');
        }
      },500)
    }


    // check the spa window location
    listener();

    function listener() {
      /* These are the modifications: */
      window.addEventListener("locationchange", function() {
        var interval = setInterval(function(){
          helper.waitForElement(".pagination.sticky-content,.supply-chain-value", init, 500, 15000);
        },20)

        setTimeout(function(){
          clearInterval(interval)
        },5000)

      });
      history.pushState = ((f) =>
        function pushState() {
          var ret = f.apply(this, arguments);
          window.dispatchEvent(new Event("pushstate"));
          window.dispatchEvent(new Event("locationchange"));
          return ret;
        })(history.pushState);
      history.replaceState = ((f) =>
        function replaceState() {
          var ret = f.apply(this, arguments);
          window.dispatchEvent(new Event("replacestate"));
          window.dispatchEvent(new Event("locationchange"));
          return ret;
        })(history.replaceState);
      window.addEventListener("popstate", () => {
        window.dispatchEvent(new Event("locationchange"));
      });
    }

    function init2(){
      var interval = setInterval(function(){
      //  document.querySelector('.controls .widgets form > button.specs').click();
      },50)

      setTimeout(function(){
        clearInterval(interval)
      },3000)
    }

    helper.waitForElement(".controls .widgets form > button.specs", init2, 500, 15000);

    /* Initialize variation */
    helper.waitForElement(".pagination.sticky-content,.supply-chain-value", init, 500, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();



html body .controls {  
    position: relative;
    margin: 50px 0px 0px 0px !important;
    padding: 15px;
    border-top: 1px solid #7ca8d1;
    border-left: 1px solid #7ca8d1;
    margin-right: -40px !important;
    background: #fff;
    padding-bottom: 60px;
    padding-top: 30px;
}
html body.eg_pricing .controls{
    margin-right: 0px !important;
    border-left: none;
}
html body .controls .widgets form {
    position: absolute;
    top: -38px;
    left: -1px;
}
html body .controls .widgets form > .specs,
html body .controls .widgets form > .prices {
     background: #e8f3fd;
    color: #697596;
    border: 1px solid #d9d7d1;
    border-bottom: 1px solid #7ca8d1;
    width: 200px;
   
}

html body .controls .widgets form > div.specs,
html body .controls .widgets form > div.prices {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    width: 200px;
    background-color: #ffffff;
    cursor: pointer;
    font-size: 14px !important;
    height: 38px;
    border-radius: 0px;
    color: #697596;
    border: 1px solid #7ca8d1;
    border-bottom: none;
}

html body .prices-view {
    border-top: 0px;
    /* margin-top: -2px; */
}

html body .eg_button-column div{
    color: #fff;
    background: #4da881;
    text-align: center;
    cursor: pointer;
    padding: 2px;
}

html body .sticky-content .filters-controls{
    padding: 0 0;
    max-width: 100%;
}

html body .bottom .sticky-content + div > div{
    padding-left: 15px !important;
    background: #fff;
    border-left: 1px solid #7ca8d1;
    border-bottom: 1px solid #7ca8d1;
}
/*
html body th.image::before{
    content: '';
    width: 20px;
    height: 100%;
    position: absolute;
    background: #f0f0f0;
    left: -35px;
    border-right: 1px solid #7ca8d1;
    top: 0;
    z-index: 99;
}

html body th.image::after{
    content: '';
    width: 15px;
    height: 100%;
    position: absolute;
    background: #fff;
    left: -15px;
    top: 0;
    z-index: 99;
}

html body th.image {
    left: 35px !important;
}

html body th.mpn{
    left: 110px !important;
} 
*/
Editor is loading...