1// JavaScript Document 2//'use strict' 3 4// Function to set a cookie 5function setCookie(name, value, days) { 6 const date = new Date(); 7 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 8 const expires = "expires=" + date.toUTCString(); 9 //document.cookie = name + "=" + value + ";" + expires + ";path=/"; 10 11 document.cookie = name + "=" + value + ";domain=.royalmailtechnical.com;" + expires + ";path=/"; 12} 13 14// Function to get a cookie 15function getCookie(name) { 16 const nameEQ = name + "="; 17 const ca = document.cookie.split(';'); 18 19 for (var i = 0; i < ca.length; i++) { 20 var c = ca[i]; 21 while (c.charAt(0) === ' ') c = c.substring(1, c.length); 22 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); 23 } 24 return null; 25} 26 27// Function to delete a cookie 28function deleteCookie(name) { 29 var value = ""; 30 var expires = "expires=Thu, 01 Jan 1970 00:00:01 GMT" 31 32 //document.cookie = name + "=" + value + ";" + expires + ";path=/"; 33 document.cookie = name + "=" + value + ";domain=.royalmailtechnical.com;" + expires + ";path=/"; 34} 35 36// Function to delete a cookie by domain 37//function deleteCookie(name,domain) { 38// var value = ""; 39// var expires = "expires=Thu, 01 Jan 1970 00:00:01 GMT" 40// 41// document.cookie = name + "=" + value + ((domain)? "; domain=" + domain: "") + ";" + expires + ";path=/"; 42//} 43 44function fncSetGoogleAnalytics() { 45 var cookies_consent = getCookie('cookies_consent'); 46 47 //alert('Set Google Analytics = ' + cookies_consent); 48 49 if (cookies_consent === 'accept_all' || cookies_consent === 'accept_p') { 50 //alert('Enable Google Analytics window[]'); 51 window['ga-disable-G-97DMK2EZ2C'] = false; //this is what enable the tracking 52 } else { 53 //alert('Disable Google Analytics window[]'); 54 window['ga-disable-G-97DMK2EZ2C'] = true; //this is what disables the tracking 55 56 // Delete Google Ananlytic related cookies (_qa & _ga_*) 57 deleteCookie('_ga'); 58 deleteCookie('_ga_97DMK2EZ2C'); 59 deleteCookie('_ga_QS5PWC806Y'); 60 deleteCookie('_ga_QSZQGWQV4T'); 61 } 62} 63 64function fncSetLogout() { 65 var cookies_consent = getCookie('cookies_consent'); 66 67 //alert('Set Login = ' + cookies_consent); 68 69 if (cookies_consent === 'accept_all' || cookies_consent === 'accept_f') { 70 //alert('No need to do anything'); 71 72 } else { 73 //alert('Do Logout if user is logged in already'); 74 location.href = "logout_index.cfm"; 75 } 76} 77 78// Check for existing consent 79window.onload = function() { 80 81 //alert('Window Onload'); 82 83 if (window.location.pathname.endsWith("Cookies_Policy.cfm") == false) { 84 const cookies_consent = getCookie('cookies_consent'); 85 if (!cookies_consent) { 86 // Show consent banner if no consent cookie is found 87 document.getElementById('GDPRRecModal').style.display = 'block'; 88 } else if (cookies_consent === 'accept_all') { 89 // Load Google Analytics if consent was previously accepted 90 fncSetGoogleAnalytics(); 91 } 92 } 93} 94 95// When the user clicks the "Accept all" button 96function btnAcceptAll() { 97 // 1 - Leave logon details 98 // 2 - Enable Google Analytics 99 // 3 - Close the modal 100 //alert('Accept all'); 101 setCookie('cookies_consent', 'accept_all', 182); // Set consent cookie to 'accept_all' for 182 number of days 102 fncSetGoogleAnalytics(); 103 document.getElementById('GDPRRecModal').style.display = 'none'; 104} 105 106// When the user clicks the "Reject all" button 107function btnRejectAll() { 108 // 1 - Logout if still logged in 109 // 2 - Disable Google Analytics 110 // 3 - Close the modal 111 //alert('Reject all'); 112 setCookie('cookies_consent', 'reject_all', 182); // Set consent cookie to 'reject_all' for 182 number of days 113 fncSetLogout(); 114 fncSetGoogleAnalytics(); 115 document.getElementById('GDPRRecModal').style.display = 'none'; 116} 117 118// When the user clicks the "Let me choose" button 119function btnLetMeChoose() { 120 // 1 - Hide GDPRRecModal 121 // 2 - Show GDPRPerformanceModal 122 // 3 - Close the modal 123 document.getElementById('GDPRRecModal').style.display = 'none'; 124 document.getElementById("msgError").innerHTML = ""; 125 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 126} 127 128// When the user clicks on <span> (x), close the modal 129function btnX() { 130 document.getElementById('GDPRPerformanceModal').style.display = 'none'; 131 document.getElementById('GDPRRecModal').style.display = 'block'; 132} 133 134// When the user clicks the "Change Consent Preferences" link 135function fncChangeCookieConsent() { 136 //alert('Change My Consent Preferences'); 137 138 const cookies_consent = getCookie('cookies_consent'); 139 //alert('Change My Consent Preferences - read from cookie = ' + cookies_consent); 140 if (!cookies_consent) { 141 // Show consent banner if no consent cookie is found 142 //alert('Change My Consent Preferences - none'); 143 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 144 }
144 else if (cookies_consent === 'accept_all') { 145 //alert('Change My Consent Preferences - accept_all'); 146 document.getElementById('fncYes').checked = true; 147 document.getElementById('perfYes').checked = true; 148 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 149 } else if (cookies_consent === 'reject_all') { 150 //alert('Change My Consent Preferences - reject_all'); 151 document.getElementById('fncNo').checked = true; 152 document.getElementById('perfNo').checked = true; 153 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 154 } else if (cookies_consent === 'accept_f') { 155 //alert('Change My Consent Preferences - accept_f'); 156 document.getElementById('fncYes').checked = true; 157 document.getElementById('perfNo').checked = true; 158 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 159 } else if (cookies_consent === 'accept_p') { 160 //alert('Change My Consent Preferences - accept_p'); 161 document.getElementById('fncNo').checked = true; 162 document.getElementById('perfYes').checked = true; 163 document.getElementById('GDPRPerformanceModal').style.display = 'block'; 164 } 165} 166 167// When the user clicks the "Save Preferences" button 168function btnSavePref() { 169 // 1 - Hide GDPRRecModal 170 // 2 - Hide GDPRPerformanceModal 171 // 3 - Close the modal 172 173 //alert('save all' ); 174 var strErrorMsg = "Please select your cookie preferences."; 175 var checked_functional = document.querySelector('input[name = "functional"]:checked'); 176 var checked_performance = document.querySelector('input[name = "performance"]:checked'); 177 178 179 if(checked_functional != null && checked_performance != null){ //Test if something was checked 180 //alert('Functional = ' + checked_functional.value); //Alert the value of the checked. 181 //alert('Performance = ' + checked_performance.value); //Alert the value of the checked. 182 183 // set main cookies_consent flag 184 if (checked_functional.value == 'Yes' && checked_performance.value == 'Yes') { 185 setCookie('cookies_consent', 'accept_all', 182); // Set consent cookie to 'accept_all' for 182 number of days 186 } else if (checked_functional.value == 'No' && checked_performance.value == 'No') { 187 setCookie('cookies_consent', 'reject_all', 182); // Set consent cookie to 'reject_all' for 182 number of days 188 fncSetLogout(); 189 } else if (checked_functional.value == 'Yes' && checked_performance.value == 'No') { 190 setCookie('cookies_consent', 'accept_f', 182); // Set consent cookie to 'accept_f' for 182 number of days 191 } else if (checked_functional.value == 'No' && checked_performance.value == 'Yes') { 192 setCookie('cookies_consent', 'accept_p', 182); // Set consent cookie to 'accept_p' for 182 number of days 193 fncSetLogout(); 194 } 195 fncSetGoogleAnalytics(); 196 document.getElementById('GDPRPerformanceModal').style.display = 'none'; 197 198 } else { 199 //alert('One or more set is not checked'); //Alert, nothing was checked. 200 document.getElementById("msgError").innerHTML = strErrorMsg; 201 } 202 203} 204 205// When the user clicks anywhere outside of the modal, close it 206window.onclick = function(event) { 207 if (event.target == 'modal') { 208 document.getElementById('GDPRRecModal').style.display = 'none'; 209 document.getElementById('GDPRPerformanceModal').style.display = 'none'; 210 211 } 212}
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.