1document.addEventListener("DOMContentLoaded", function(event) { 2 3 var consentCookieName = 'stats_allowed'; 4 var cookieConsentDialog; 5 var cookieOptInBtnEl; 6 var cookieSettingsBtnEl; 7 var cookieConsentCheckboxEls; 8 var statsWereCollected = false; 9 10 var collectStats = function(){ 11 if(!statsWereCollected) { 12 var _paq = window._paq = window._paq || []; 13 /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ 14 _paq.push(['trackPageView']); 15 _paq.push(['enableLinkTracking']); 16 (function() { 17 var u="https://softmaker.com/analyze/"; 18 _paq.push(['setTrackerUrl', u+'matomo.php']); 19 _paq.push(['setSiteId', '1']); 20 var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; 21 g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); 22 })(); 23 } 24 25 statsWereCollected = true; 26 }; 27 28 var deleteObsoleteCookies = function() { 29 var allCookies = document.cookie.split(';'); 30 var cookiesToDelete = []; 31 for (i = 0; i < allCookies.length; i++) { 32 if (allCookies[i].trim().indexOf('_pk_') == 0) { 33 cookiesToDelete.push(allCookies[i].trim().split('=')[0]); 34 } 35 } 36 for (i = 0; i < cookiesToDelete.length; i++) { 37 eraseCookie(cookiesToDelete[i]); 38 } 39 }; 40 41 var setConsentStatus = function(statsAllowed) { 42 setGuiElementsVisibility(false); 43 for (i = 0; i < cookieConsentCheckboxEls.length; i++) { 44 cookieConsentCheckboxEls[i].checked = statsAllowed; 45 }; 46 if(statsAllowed) { 47 setCookie(consentCookieName, '1', 730); 48 collectStats(); 49 } else { 50 setCookie(consentCookieName, '0', 730); 51 deleteObsoleteCookies(); 52 } 53 }; 54 55 var setGuiElementsVisibility = function(isVisible) { 56 if(isVisible) { 57 cookieConsentDialog.classList.remove('invisible'); 58 } else { 59 cookieConsentDialog.classList.add('invisible'); 60 } 61 }; 62 63 var getDomainAttributeString = function() { 64 var hostnameArray = window.location.hostname.split('.'); 65 var domainAttributeString = '.' + hostnameArray[hostnameArray.length - 2] + '.' + hostnameArray[hostnameArray.length - 1]; 66 return domainAttributeString; 67 }; 68 69 var setCookie = function(name,value,days) { 70 var expires = ""; 71 if (days) { 72 var date = new Date(); 73 date.setTime(date.getTime() + (days*24*60*60*1000)); 74 expires = "; expires=" + date.toUTCString(); 75 } 76 document.cookie = name + "=" + (value || "") + expires + "; domain=" + getDomainAttributeString() + "; path=/"; 77 }; 78 79 var isConsentGiven = function() { 80 if (document.cookie.split(';').some(function(item) { 81 return item.indexOf(consentCookieName + '=1') >= 0 82 })) { 83 return true; 84 } 85 return false; 86 }; 87 88 var isConsentStatusDefined = function() { 89 if (document.cookie.split(';').some(function(item) { 90 return item.trim().indexOf(consentCookieName + '=') == 0 91 })) { 92 return true; 93 } 94 return false; 95 }; 96 97 var eraseCookie = function (name) { 98 document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 99 }; 100 101 var onCheckboxClicked = function (CheckboxEl) { 102 setConsentStatus(CheckboxEl.checked); 103 } 104 105 var onCookieOptInBtnClicked = function () { 106 setConsentStatus(true); 107 } 108 109 var onCookieSettingsBtnClicked = function () { 110 setConsentStatus(false); 111 } 112 113 var initCheckboxes = function () { 114 for (i = 0; i < cookieConsentCheckboxEls.length; i++) { 115 cookieConsentCheckboxEls[i].checked = isConsentGiven(); 116 cookieConsentCheckboxEls[i].addEventListener('click', function() { 117 onCheckboxClicked(this); 118 }); 119 }; 120 } 121 122 var initGuiElements = function() { 123 cookieConsentDialog = document.getElementById('CookiePopup'); 124 cookieOptInBtnEl = document.getElementById('CookieOptInBtn'); 125 cookieSettingsBtnEl = document.getElementById('CookieSettingsBtn'); 126 cookieConsentCheckboxEls = document.getElementsByClassName('CookieConsentCheckbox'); 127 128 if (!isConsentStatusDefined()) { 129 setGuiElementsVisibility(true); 130 } 131
132 initCheckboxes(); 133 134 cookieOptInBtnEl.addEventListener('click', onCookieOptInBtnClicked); 135 cookieSettingsBtnEl.addEventListener('click', onCookieSettingsBtnClicked); 136 }; 137 138 //MAIN 139 140 if (isConsentGiven()) { 141 collectStats(); 142 } else { 143 deleteObsoleteCookies(); 144 } 145 146 initGuiElements(); 147 148});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.