Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
4.3 kB
2
Indexable
Never
<script>
    (function () {

 

        var els_phone = document.querySelectorAll(".eg-call-section a[href*=\"tel\"]");
        var defaultAutoDiscoveryNumber = "+1-877-585-1235";
        var geoVisitor = "";
        var geoLookup = {
            "GB": "0808 134 6000",
            "IE": "0808 134 6000",
            "AU": "+61 1800 959 394"
        }

 

        var updateHref = function (_el, _newAutoDisocveryNumber) {
            if (_el.tagName == "A") {
                _el.href = _el.href.replace(defaultAutoDiscoveryNumber.replace(/\D/g, ''), _newAutoDisocveryNumber.replace(/\D/g, ''));
            }
        };

 

        var updateText = function (_el, _newAutoDisocveryNumber) {
            _el.innerHTML = _el.innerHTML.replace(defaultAutoDiscoveryNumber, _newAutoDisocveryNumber);
        };

 

        if (els_phone.length > 0 && 
            window.qrk_helper && 
            window.qrk_helper.visitor && 
            window.qrk_helper.visitor.country) {

 

            geoVisitor = window.qrk_helper.visitor.country;

 

            if (geoLookup[geoVisitor]) {

 

                newAutoDisocveryNumber = geoLookup[geoVisitor];

 

                els_phone.forEach(function(_el) { 
                    updateText(_el, newAutoDisocveryNumber);
                    updateHref(_el, newAutoDisocveryNumber);
                });    

 

            }
        }    

 

 

        var updateInfinityLinks = function () {

 

              var arr_infinityAutoDiscovery = [];
            var els_phoneNumbers = document.querySelectorAll(".eg-call-section a[href*=\"tel\"]");
            var displayNumber = "";
            var displayNumberNoFormatting = "";
            var href = "";
            var i;

 

 

            arr_infinityAutoDiscovery.push(defaultAutoDiscoveryNumber.replace(/\D/g, ''));

 

            for (var key in geoLookup) {
                if (geoLookup.hasOwnProperty(key)) {
                    arr_infinityAutoDiscovery.push(geoLookup[key].replace(/\D/g, ''));
                }
            }

 

            if (els_phoneNumbers.length) {

                els_phoneNumbers.forEach(function(el) { 

                    if (el.tagName == "A") {

                        displayNumber = el.innerText.toString();
                        displayNumberNoFormatting = displayNumber.replace(/\D/g, '');
                        href = el.href.toString();

 

                        // Has Infinity Updated the number?
                        if (arr_infinityAutoDiscovery.indexOf(displayNumberNoFormatting) == -1) {

 

                            for (i = 0; i < arr_infinityAutoDiscovery.length; i = i + 1) {

                                if (href.indexOf(arr_infinityAutoDiscovery[i]) > -1) {
                                    // This has an original 
                                    el.href = href.replace(arr_infinityAutoDiscovery[i], displayNumberNoFormatting);
                                }
                            }

 

                        }
                    }

 

                });
            };
        };        

 

        window.addEventListener('InfinityAllocated', function () {
              updateInfinityLinks();
        });

 

    })(window);
</script>

 

<script>

 

  (function(i,n,f,t,y,x,z) {
    y=i._its=function(){return y.queue.push(arguments)};y.version='2.0';y.queue=[];z=n.createElement(f);z.async=!0;z.src=t;x=n.getElementsByTagName(f)[0];x.parentNode.insertBefore(z,x)})(window, document,'script','https://script.infinity-tracking.com/infinitytrack.js?i=6002');
  window.uniqueId||(window.uniqueId=([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,function(e){return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}));
  var fbqProxy,_fbq,uuid=window.uniqueId,fbqHandler={get:function(e,i){return Reflect.get.apply(Reflect,arguments)},apply:function(e,i,n){return'init'===n[0]&&(_its('setVariable','fb_pid',n[1]),_its('setVariable','fb_uuid',uuid),n[2]?n[2].external_id=uuid:n.push({external_id:uuid})),e.apply(i,n)}};window.fbq&&(_fbq=window.fbq),Object.defineProperty(window,'fbq',{get:function(){return fbqProxy},set:function(e){fbqProxy=new Proxy(e,fbqHandler)}}),_fbq&&(window.fbq=_fbq);

  window._its('init', '6002');
  window._its('track');

</script>