clickdimensions.Analytics.prototype.cookieLife = 90; clickdimensions.Analytics.prototype.cookieName = function() { var prefix = 'cd_optout_'; if (typeof (window.optOutHostId) == "undefined") { return prefix + this.i; } return prefix + window.optOutHostId; } clickdimensions.Analytics.prototype.onOptIn = function () { this.trackPage(); setCookie(this.cookieName(), false, this.cookieLife, this.i); } clickdimensions.Analytics.prototype.onOptOut = function () { setCookie(this.cookieName(), true, this.cookieLife, this.i); } clickdimensions.Analytics.prototype.optOutTracking = function (useOptOut) { if (useOptOut !== true) { this.trackPage(); return; } var optOutValue = getCookie(this.cookieName()); //already have a cookie if (optOutValue !== "") { //pressed ok if (optOutValue === "false") { this.trackPage(); } return; } var settings = typeof (window.optOutSettings) == "undefined" ? {} : window.optOutSettings; var defaultSettings = { text: 'Our website uses tracking technologies to learn how our visitors interact with our site so that we can improve our services and provide ' + 'you with valuable content. Disable Tracking.', optedOutText: 'Tracking for this website has been disabled in this browser.', backgroundgColor: 'white', fontColor: '#283541', fontFamily: 'arial, sans-serif', fontSize: '14px', okButttonText: 'OK', okButttonBackgroundColor: '#0b8be3', okButttonTextColor: '#fff', okButttonWidth: 'auto', daysToKeepTheAnswer: 183 }; var mergedSettings = extend(defaultSettings, settings); this.cookieLife = mergedSettings.daysToKeepTheAnswer; var self = this; var popup = new Popup(this.onOptIn.bind(self), this.onOptOut.bind(self), mergedSettings); popup.show(); }; function extend(a, b) { for (var key in b) if (b.hasOwnProperty(key)) a[key] = b[key]; return a; } function setCookie(cname, cvalue, exdays, domain) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";domain=." + domain + ";path=/"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function append(elString) { var div = document.createElement("div"); div.innerHTML = elString; document.body.appendChild(div.firstChild); } var Popup = function (okCallback, cancellCallback, settings) { var self = this; this.okCallback = okCallback; this.cancellCallback = cancellCallback; this.settings = settings; this.stepContent = function (stepText, okButtonId) { var template = '
' + stepText + '
' + '' + '
'; return template; }; this.show = function () { var popupData = ''; append(popupData); var trackMeButton = document.getElementById("trackMe"); trackMeButton.addEventListener('click', trackFunc = function () { self.okCallback(); self.hide(); this.removeEventListener('click', trackFunc); }); var stopTrackingButton = document.getElementById("stopTracking"); stopTrackingButton.addEventListener('click', stopFunc = function () { self.cancellCallback(); document.getElementById("modalMain").innerHTML = self.stepContent(self.settings.optedOutText, "hideMe"); this.removeEventListener('click', stopFunc); var hideButton = document.getElementById("hideMe"); hideButton.addEventListener('click', hideFunc = function () { self.hide(); this.removeEventListener('click', hideFunc); }); }); this.hide = function () { document.body.removeChild(document.getElementById("modal-overlay")); } }; }