1/** 2 * Script for cookies box that check if is ip is europe, via the api free service. 3 * Starts after window load 4 * CSS included 5 */ 6 7//show cookie message 8function cookieConsent(code) { 9 10 //european union countries 11 var countries = ['AD', 'AL', 'AT', 'AX', 'BA' ,'BE', 'BG', 'CH', 'CZ', 'HR', 'CY', 'CZ', 'DK', 'EE', 'ES', 'EU', 'FI', 'FO', 'FR', 'DE', 'GB', 'GG', 'GI', 'GR', 'HU', 'IE', 'IM', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MD', 'ME', 'MK', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SK', 'SI', 'SE', 'UK']; 12 13 //if country is europe 14 if (countries.indexOf(code) >= 0) { 15 16 document.write('<div id="cookies">Our advertisers use cookies to personalize ads on our web pages. <br><br><button id="accept">ACCEPT</button> <button id="decline">DECLINE</button> <a id="details" href="https://policies.google.com/technologies/cookies" target="_blank">Details</a> <a id="close">×</a></div>'); 17 18 //box styles 19 document.getElementById('cookies').style.position = 'fixed'; 20 document.getElementById('cookies').style.zIndex = '99'; 21 document.getElementById('cookies').style.bottom = '18px'; 22 document.getElementById('cookies').style.right = '18px'; 23 document.getElementById('cookies').style.width = '365px'; 24 document.getElementById('cookies').style.background = 'rgba(0, 0, 0, 0.6)'; 25 document.getElementById('cookies').style.padding = '24px'; 26 document.getElementById('cookies').style.boxSizing = 'border-box'; 27 document.getElementById('cookies').style.color = 'white'; 28 document.getElementById('cookies').style.fontSize = '12pt'; 29 document.getElementById('cookies').style.fontFamily = 'sans-serif'; 30 document.getElementById('cookies').style.border = '1px solid white'; 31 32 //button styles 33 document.getElementById('accept').style.color = 'rgba(0, 0, 0, 0.8)'; 34 document.getElementById('accept').style.padding = '9px'; 35 document.getElementById('accept').style.marginRight = '6%'; 36 document.getElementById('accept').style.fontSize = '10pt'; 37 document.getElementById('accept').style.fontWeight = '700'; 38 document.getElementById('accept').style.background = 'whitesmoke'; 39 document.getElementById('accept').style.border = '0'; 40 document.getElementById('accept').style.cursor = 'pointer'; 41 42 //button styles 43 document.getElementById('decline').style.color = 'rgba(0, 0, 0, 0.8)'; 44 document.getElementById('decline').style.padding = '9px'; 45 document.getElementById('decline').style.fontSize = '10pt'; 46 document.getElementById('decline').style.fontWeight = '700'; 47 document.getElementById('decline').style.background = 'whitesmoke'; 48 document.getElementById('decline').style.border = '0'; 49 document.getElementById('decline').style.cursor = 'pointer'; 50 51 //button styles 52 document.getElementById('details').style.color = 'lightblue'; 53 document.getElementById('details').style.float = 'right'; 54 55 //close styles 56 document.getElementById('close').style.color = 'white'; 57 document.getElementById('close').style.padding = '5px'; 58 document.getElementById('close').style.width = '18px'; 59 document.getElementById('close').style.textAlign = 'center'; 60 document.getElementById('close').style.fontWeight = '700'; 61 document.getElementById('close').style.background = 'orangered'; 62 document.getElementById('close').style.position = 'absolute'; 63 document.getElementById('close').style.top = '0'; 64 document.getElementById('close').style.right = '0'; 65 document.getElementById('close').style.cursor = 'pointer'; 66 67 //responsive styles 68 if(window.screen.width < 700) { 69 70 document.getElementById('cookies').style.width = '100%'; 71 document.getElementById('cookies').style.bottom = '0'; 72 document.getElementById('cookies').style.right = '0'; 73 document.getElementById('cookies').style.border = '0'; 74 document.getElementById('cookies').style.padding = '12px'; 75 document.getElementById('cookies').style.borderTop = '2px solid white'; 76 document.getElementById('accept').style.fontSize = '12pt'; 77 document.getElementById('decline').style.fontSize = '12pt'; 78 document.getElementById('accept').style.marginRight = '8px'; 79 } 80 81 //ON PRESS ACCEPT COOKIES 82 document.getElementById("accept").addEventListener("click", function(){ 83 84 document.getElementById('cookies').style.display = 'none'; 85 acceptCookies(); 86 }); 87 88 //ON PRESS DECLINE COOKIES 89 document.getElementById("decline").addEventListener("click", function(){ 90 91 document.getElementById('cookies').style.display = 'none'; 92 deleteAllCookies(); 93 denyCookies(); 94 }); 95 96 //ON PRESS CLOSE 97 document.getElementById("close").addEventListener("click", function(){ 98 99 document.getElementById('cookies').style.display = 'none'; 100 }) 101 102 } 103 104 //if country not be europe 105 else { 106 107 //put the cookies accept, prevents useless loading 108 acceptCookies(); 109 } 110} 111 112function acceptCookies() { 113 114 Set_Cookie('cookieConsent', true, '90', '/', window.location.hostname, ''); 115} 116 117function denyCookies() { 118 119 Set_Cookie('denyConsent', true, '90', '/', window.location.hostname, ''); 120} 121 122function deleteAllCookies() { 123 var cookies = document.cookie.split(";"); 124 125 for (var i = 0; i < cookies.length; i++) { 126 var cookie = cookies[i]; 127 var eqPos = cookie.indexOf("="); 128 var name = eqPos >
128 -1 ? cookie.substr(0, eqPos) : cookie; 129 document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; 130 } 131} 132 133function Set_Cookie(name, value, expires, path, domain, secure) { 134 135 //set time, it's in milliseconds 136 var today = new Date(); 137 today.setTime(today.getTime()); 138 139 //setup value variable to be in days 140 if (expires) { 141 expires = expires * 1000 * 60 * 60 * 24; 142 } 143 var expires_date = new Date(today.getTime() + (expires)); 144 145 document.cookie = name + "=" +escape(value) + 146 ((expires) ? ";expires=" + expires_date.toGMTString() : "") + 147 ((path) ? ";path=" + path : "") + 148 ((domain) ? ";domain=" + domain : "") + 149 ((secure) ? ";secure" : ""); 150} 151 152function Get_Cookie(check_name) { 153 154 //first we'll split this cookie up into name/value pairs 155 var a_all_cookies = document.cookie.split(';'); 156 var a_temp_cookie = ''; 157 var cookie_name = ''; 158 var cookie_value = ''; 159 var b_cookie_found = false; //set boolean t/f default f 160 161 for (i = 0; i < a_all_cookies.length; i++) { 162 163 //now we'll split apart each name=value pair 164 a_temp_cookie = a_all_cookies[i].split('='); 165 166 //and trim left/right whitespace while we're at it 167 cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); 168 169 //if the extracted name matches passed check_name 170 if (cookie_name == check_name) { 171 b_cookie_found = true; 172 173 //we need to handle case where cookie has no value but exists 174 if (a_temp_cookie.length > 1) { 175 cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, '')); 176 } 177 178 //note that in cases where cookie is initialized but no value 179 return cookie_value; 180 break; 181 } 182 a_temp_cookie = null; 183 cookie_name = ''; 184 } 185 if (!b_cookie_found) { 186 return null; 187 } 188} 189 190//this deletes the cookie when called 191function Delete_Cookie(name, path, domain) { 192 193 if (Get_Cookie(name)) document.cookie = name + "=" + 194 ((path) ? ";path=" + path : "") + 195 ((domain) ? ";domain=" + domain : "") + 196 ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; 197} 198 199//setup the data from the api 200function cookies(data) { 201 202 var code = data.countryCode; 203 cookieConsent(code); 204} 205 206//start cookies 207if (!Get_Cookie('denyConsent') == false) { 208 209 //stuff to do when decline is on user prefs 210 //..or just do none.. 211} 212else if (!Get_Cookie('cookieConsent') == true) { 213
214 document.write('<script type="text/javascript" src="https://geographic.org/cookies.php"><\/script>'); 215 //document.write('<script type="text/javascript" src="//ip-api.com/json/?fields=countryCode&callback=cookies"><\/script>'); 216 cookies(); 217 218}
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.