//! Calltracks Web Number Dynamics - 3rd generation - Copyright 2007 onwards, Calltracks //! This code is generated, and MUST be loaded from Calltracks. Do not simply copy and paste the code into your web site or tag manager. var class_names = []; var classNamesMatch = "exact"; var ctConditionalRules = []; var ctConditionalPersistenceMs = 2592000000; var ctConditionalStorageKey = 'calltracksCONDITIONS'; // fix for ie 8 if (!document.getElementsByClassName) { document.getElementsByClassName = function(search) { var d = document, elements, pattern, i, results = []; if (d.querySelectorAll) { // IE8 return d.querySelectorAll("." + search); } if (d.evaluate) { // IE6, IE7 pattern = ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]"; elements = d.evaluate(pattern, d, null, 0, null); while ((i = elements.iterateNext())) { results.push(i); } } else { elements = d.getElementsByTagName("*"); pattern = new RegExp("(^|\\s)" + search + "(\\s|$)"); for (i = 0; i < elements.length; i++) { if ( pattern.test(elements[i].className) ) { results.push(elements[i]); } } } return results; } } // Source: Eli Grey @ https://eligrey.com/blog/post/textcontent-in-ie8 if (Object.defineProperty && Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(Element.prototype, "textContent") && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) { (function() { var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText"); Object.defineProperty(Element.prototype, "textContent", // Passing innerText or innerText.get directly does not work, // wrapper function is required. { get: function() { return innerText.get.call(this); }, set: function(s) { return innerText.set.call(this, s); } } ); })(); } // end fix for ie 8 if (document.createElement && document.childNodes){ if (typeof(__ctwnd) == "object") { if(__ctwnd.isInitialised){__ctwnd.reinit()} } else{ function setCalltracksClassFromTextContent(elements) { for(var i = 0; i 0; }; var elementNeedsScan = function(el) { if (el.nodeType !== 1 || typeof el.className !== 'string') return false; var identifiers; if (ahrefEnabled && el.tagName == 'A' && !el.querySelector('span[class*="' + ctPrefix + '"]')) { identifiers = __ctTelIdentifiers(el.href); if (identifiers.length === 0) return false; } else { if (el.getAttribute('data-calltracks-replaced-at')) return false; if (skipHiddenSpans && el.className.indexOf('hidden') !== -1 && el.getAttribute('data-calltracks-class') && !el.getAttribute('data-calltracks-clicked')) return false; identifiers = getElementIdentifiers(el); if (identifiers.length === 0) return false; } if (allIdentifiersUnknown(identifiers)) { debugLog('reinit (g3 request) skipped for a newly added element - g3 already reported its identifiers as unknown on this page: ' + identifiers.join(', ')); return false; } debugLog('newly added element with identifiers ' + identifiers.join(', ') + ' - reinit (g3 request) in ' + domObserverDebounceMs + 'ms'); return true; }; var nodeNeedsScan = function(node) { if (node.nodeType !== 1) return false; if (elementNeedsScan(node)) return true; if (!node.querySelectorAll) return false; var candidates = node.querySelectorAll(domObserverSelector); for (var k = 0; k < candidates.length; k++) { if (elementNeedsScan(candidates[k])) return true; } return false; }; var startDomObserver = function() { if (domObserver || !window.MutationObserver || !document.body) return; domObserver = new MutationObserver(function(mutations) { for (var m = 0; m < mutations.length; m++) { var added = mutations[m].addedNodes; for (var n = 0; n < added.length; n++) { if (nodeNeedsScan(added[n])) { clearTimeout(domObserverTimer); domObserverTimer = setTimeout(function() { domObserverTimer = null; __ctwnd.reinit(); domObserver.takeRecords(); }, domObserverDebounceMs); return; } } } }); domObserver.observe(document.body, { childList: true, subtree: true }); }; var getNumberIdentifiers = function(){ var newNumberIdentifiers = []; var spanElements = getSpanElementsWithCtPrefixClass(); for (var i=0; i= __ctwnd.forceRefreshNumbersAfterMs) { continue; } } else { continue; } if(curr==identifierName||curr.indexOf(identifierName+lowercasedDelimiterForOriginalContent)===0){ spanIdentifiers.splice(l, 1); } } } if (spanIdentifiers.length == 0) { add=false; continue; } if (!__ctwnd.isInitialised && span.attributes['data-replace-delayed'] && span.attributes['data-replace-delayed'].value==='true'){add=false;break;} if(add){ reInitG3 = __ctwnd.isInitialised && true; var extra_info = ''; if (span.getAttribute('data-use_original_fmt') === 'true') { var origHtmlAttr = span.getAttribute('data-calltracks-orig-innerhtml'); var originalContent = origHtmlAttr ? decodeURIComponent(origHtmlAttr) : (span.innerText || (span.textContent || '').replace(/\s+/g, ' ')); extra_info = delimiterForOriginalContent + "original-content=" + encodeURIComponent(encodeURIComponent(originalContent)); } var without_attr_data = []; for( var l=0; l 0) { debugLog('g3 reported unknown identifiers (new elements with only these identifiers will not trigger reinit): ' + identifiers.join(', ')); } }, forgetUnknownIdentifier: function(identifier) { delete unknownIdentifiers[String(identifier).toLowerCase()]; }, matchValue: function(mode, haystack, needle) { if (mode === 'exists') return haystack != null && haystack !== ''; if (haystack == null) return false; if (mode === 'equals') return haystack === needle; if (mode === 'contains') return haystack.indexOf(needle) !== -1; if (mode === 'regex') { try { return new RegExp(needle).test(haystack); } catch (e) { return false; } } return false; }, getQueryParam: function(name) { var search = window.location.search; if (!search || search.length < 2) return null; var pairs = search.substring(1).split('&'); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); if (pair[0] === '') continue; var key; try { key = decodeURIComponent(pair[0]); } catch (e) { key = pair[0]; } if (key === name) { var raw = pair.length > 1 ? pair[1] : ''; try { return decodeURIComponent(raw.replace(/\+/g, ' ')); } catch (e) { return raw; } } } return null; }, writeConditionalInfo: function(rule) { try { if (!__ctwnd.localStorageEnabled()) return; var info = { rule: rule, url: window.location.href, ts: (new Date()).getTime() }; localStorage.setItem(ctConditionalStorageKey, JSON.stringify(info)); } catch (e) {} }, shouldLoadConditionally: function() { if (ctConditionalRules.length === 0) return true; try { if (__ctwnd.localStorageEnabled()) { var raw = localStorage.getItem(ctConditionalStorageKey); if (raw != null) { var info = null; try { info = JSON.parse(raw); } catch (e) {} if (info && info.ts && (info.ts + ctConditionalPersistenceMs > (new Date()).getTime())) { return true; } try { localStorage.removeItem(ctConditionalStorageKey); } catch (e) {} } } } catch (e) {} var i, rule, haystack; for (i = 0; i < ctConditionalRules.length; i++) { rule = ctConditionalRules[i]; if (rule.rule_type === 'query_param') { haystack = __ctwnd.getQueryParam(rule.key); } else if (rule.rule_type === 'path') { haystack = window.location.pathname; } else { continue; } if (__ctwnd.matchValue(rule.match_mode, haystack, rule.value)) { __ctwnd.writeConditionalInfo(rule); return true; } } for (i = 0; i < ctConditionalRules.length; i++) { rule = ctConditionalRules[i]; if (rule.rule_type !== 'referer') continue; if (__ctwnd.matchValue(rule.match_mode, document.referrer, rule.value)) { __ctwnd.writeConditionalInfo(rule); return true; } } return false; }, localStorageEnabled: function() { if (localStorage.forceLocalStorageDisabled) return false; if (this.localStorageEnabledCache === undefined) { var test = '__local_storage__test'; try { localStorage.setItem(test, test); if (localStorage[test] !== test) { this.localStorageEnabledCache = false; } else { this.localStorageEnabledCache = true; } localStorage.removeItem(test); } catch(e) { this.localStorageEnabledCache = false; } } return this.localStorageEnabledCache; }, sc: function(name,value){ if (this.localStorageEnabled()) { localStorage.setItem(name, value); } else { this.scCookie(name, value); } }, scCookie: function(name, value) { var date = new Date(); date.setTime(date.getTime() + 2592000000); var expires = ' expires=' + date.toGMTString() + ';'; var c = name + '=' + value + '; path=/; domain=safesitefacilities.co.uk; ' + expires; document.cookie = c; }, dc: function(name) { if (this.localStorageEnabled()) { localStorage.removeItem(name); } this.dcCookie(name); }, dcCookie: function(name) { var c = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;'; document.cookie = c; }, rc: function(name) { if ('false' == 'true' && name == '') { return this.rcCookie(name); } if (this.localStorageEnabled()) { var value = localStorage[name]; if (value !== undefined) { return value; } } return this.rcCookie(name); }, rcCookie: function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i=0; i= cutoffDate.getTime(); }, infoCookieName: function() { if (__ctwnd.isGdprActive()) { return 'calltracksINFO'; } else { return 'calltracksData'; } }, uidCookieName: function() { if ('false' == 'true') { return ''; } else if (__ctwnd.isGdprActive()) { return 'calltracksUID'; } else { return 'calltracksGuid'; } }, isMobile: function() { return window.calltracksForceMobile || (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) || (navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2) }, ctPrefix: ctPrefix, urlWatcherInterval: undefined, startUrlWatcher: function() { __ctwnd.urlWatcherInterval = setInterval(function() { if (__ctwnd.lastG3madeFromUrl && __ctwnd.lastG3madeFromUrl != window.location.href) { __ctwnd.reinit(); } }, 500); }, stopUrlWatcher: function() { clearInterval(__ctwnd.urlWatcherInterval); } }; })(window); window.setTimeout(function(){__ctwnd.init()},10); } }