1/* Cookies Directive - The rewrite. Now a jQuery plugin 2 * Version: 2.0.1 3 * Author: Ollie Phillips 4 * 24 October 2013 5 */ 6 7;(function($) { 8 $.cookiesDirective = function(options) { 9 10 // Default Cookies Directive Settings 11 var settings = $.extend({ 12 //Options 13 explicitConsent: true, 14 position: 'top', 15 duration: 10, 16 limit: 0, 17 message: null, 18 cookieScripts: null, 19 privacyPolicyUri: 'privacy.html', 20 scriptWrapper: function(){}, 21 // Styling 22 fontFamily: 'helvetica', 23 fontColor: '#FFFFFF', 24 fontSize: '13px', 25 backgroundColor: '#000000', 26 backgroundOpacity: '80', 27 linkColor: '#CA0000' 28 }, options); 29 30 // Perform consent checks 31 if(!getCookie('cookiesDirective')) { 32 if(settings.limit > 0) { 33 // Display limit in force, record the view 34 if(!getCookie('cookiesDisclosureCount')) { 35 setCookie('cookiesDisclosureCount',1,365); 36 } else { 37 var disclosureCount = getCookie('cookiesDisclosureCount'); 38 disclosureCount ++; 39 setCookie('cookiesDisclosureCount',disclosureCount,365); 40 } 41 42 // Have we reached the display limit, if not make disclosure 43 if(settings.limit >= getCookie('cookiesDisclosureCount')) { 44 disclosure(settings); 45 } 46 } else { 47 // No display limit 48 disclosure(settings); 49 } 50 51 // If we don't require explicit consent, load up our script wrapping function 52 if(!settings.explicitConsent) { 53 settings.scriptWrapper.call(); 54 } 55 } else { 56 // Cookies accepted, load script wrapping function 57 settings.scriptWrapper.call(); 58 } 59 }; 60 61 // Used to load external javascript files into the DOM 62 $.cookiesDirective.loadScript = function(options) { 63 var settings = $.extend({ 64 uri: '', 65 appendTo: 'body' 66 }, options); 67 68 var elementId = String(settings.appendTo); 69 var sA = document.createElement("script"); 70 sA.src = settings.uri; 71 sA.type = "text/javascript"; 72 sA.onload = sA.onreadystatechange = function() { 73 if ((!sA.readyState || sA.readyState == "loaded" || sA.readyState == "complete")) { 74 return; 75 } 76 } 77 switch(settings.appendTo) { 78 case 'head': 79 $('head').append(sA); 80 break; 81 case 'body': 82 $('body').append(sA); 83 break; 84 default: 85 $('#' + elementId).append(sA); 86 } 87 } 88 89 // Helper scripts 90 // Get cookie 91 var getCookie = function(name) { 92 var nameEQ = name + "="; 93 var ca = document.cookie.split(';'); 94 for(var i=0;i < ca.length;i++) { 95 var c = ca[i]; 96 while (c.charAt(0)==' ') c = c.substring(1,c.length); 97 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 98 } 99 return null; 100 } 101 102 // Set cookie 103 var setCookie = function(name,value,days) { 104 if (days) { 105 var date = new Date(); 106 date.setTime(date.getTime()+(days*24*60*60*1000)); 107 var expires = "; expires="+date.toGMTString(); 108 } 109 else var expires = ""; 110 document.cookie = name+"="+value+expires+"; path=/"; 111 } 112 113 // Detect IE < 9 114 var checkIE = function(){ 115 var version; 116 if (navigator.appName == 'Microsoft Internet Explorer') { 117 var ua = navigator.userAgent; 118 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); 119 if (re.exec(ua) != null) { 120 version = parseFloat(RegExp.$1); 121 } 122 if (version <= 8.0) { 123 return true; 124 } else { 125 if(version == 9.0) { 126 if(document.compatMode == "BackCompat") { 127 // IE9 in quirks mode won't run the script properly, set to emulate IE8 128 var mA = document.createElement("meta"); 129 mA.content = "IE=EmulateIE8"; 130 document.getElementsByTagName('head')[0].appendChild(mA); 131 return true; 132 } else { 133 return false; 134 } 135 } 136 return false; 137 } 138 } else { 139 return false; 140 } 141 } 142 143 // Disclosure routines 144 var disclosure = function(options) { 145 var settings = options; 146 settings.css = 'fixed'; 147 148 // IE 9 and lower has issues with position:fixed, either out the box or in compatibility mode - fix that 149 if(checkIE()) { 150 settings.position = 'top'; 151 settings.css = 'absolute'; 152 } 153 154 // Any cookie setting scripts to disclose 155 var scriptsDisclosure = ''; 156 if (settings.cookieScripts) { 157 var scripts = settings.cookieScripts.split(','); 158 var scriptsCount = scripts.length; 159 var scriptDisclosureTxt = ''; 160 if(scriptsCount>1) { 161 for(var t=0; t < scriptsCount - 1; t++) { 162 scriptDisclosureTxt += scripts[t] + ', '; 163 } 164 scriptsDisclosure = ' We use ' + scriptDisclosureTxt.substring(0, scriptDisclosureTxt.length - 2) + ' and ' + scripts[scriptsCount - 1] + ' scripts, which all set cookies. '; 165 } else { 166 scriptsDisclosure = ' We use a ' + scripts[0] + ' script which sets cookies.'; 167 } 168 } 169 170 // Create overlay, vary the disclosure based on explicit/implied consent 171 // Set our disclosure/message if one not supplied 172 var html = ''; 173 html += '<div id="epd" style="overflow:visible">'; 174 html += '<div id="cookiesdirective" style="position:'+ settings.css +';'+ settings.position + ':-300px;left:0px;width:100%;overflow:visible;' 175 html += 'height:auto;background:' + settings.backgroundColor + ';opacity:.' + settings.backgroundOpacity + ';'; 176 html += '-ms-filter: ââ∠âalpha(opacity=' + settings.backgroundOpacity + ')âââ¬ÃÂ; filter: alpha(opacity=' + settings.backgroundOpacity + ');'; 177 html += '-khtml-opacity: .' + settings.backgroundOpacity + '; -moz-opacity: .' + settings.backgroundOpacity + ';'; 178 html += 'color:' + settings.fontColor + ';
178font-family:' + settings.fontFamily + ';font-size:' + settings.fontSize + ';'; 179 html += 'text-align:center;z-index:100000000;">'; 180 html += '<div style="position:relative;height:auto;width:98%;padding:10px;margin-left:auto;margin-right:auto;overflow:visible"><div class="container" style="margin:0px auto; float:none; text-align:left; width:100%;overflow:visible">'; 181 182 if(!settings.message) { 183 if(settings.explicitConsent) { 184 // Explicit consent message 185 settings.message = 'Utilizzando il sito, accetti il nostro uso dei cookie, per una migliore esperienza di navigazione. '; 186 //settings.message += 'Non bloccando l\'uso dei cookies potrai usare al meglio tutte le funzionalitÃÆ del sito.<br/>'; 187 } else { 188 // Implied consent message 189 settings.message = 'Utilizzando il sito, accetti il nostro uso dei cookie, per una migliore esperienza di navigazione. '; 190 //settings.message += 'Non bloccando l\'uso dei cookies potrai usare al meglio tutte le funzionalitÃÆ del sito.<br/>'; 191 } 192 } 193 html += settings.message; 194 195 // Build the rest of the disclosure for implied and explicit consent 196 if(settings.explicitConsent) { 197 // Explicit consent disclosure 198 //html += scriptsDisclosure + 'Navigando nel portale e lasciando attivi i cookies approvi il loro uso.'; 199 html += scriptsDisclosure + 'Maggiori info su <a style="color:'+ settings.linkColor + ';font-weight:bold;'; 200 html += 'font-family:' + settings.fontFamily + ';font-size:' + settings.fontSize + ';" href="'+ settings.privacyPolicyUri + '" target="_blank">'+settings.privacyPolicyTitle+'</a>.<br/>'; 201 html += '<div id="epdnotick" style="color:#ca0000;display:none;margin:2px;"><span style="background:#cecece;padding:2px;">You must tick the "I accept cookies from this site" box to accept</span></div>' 202 html += '<div style="margin-top:5px;">I accept cookies from this site <input type="checkbox" name="epdagree" id="epdagree" /> '; 203 html += '<input type="submit" name="explicitsubmit" id="explicitsubmit" value="Chiudi"/><br/></div></div>'; 204 205 } else { 206 // Implied consent disclosure 207 html += '<div class="btn-wrapper-consenso" style="position:relative; top:-30px; float:right"><input type="submit" style="background-color:#000000; color:#ffffff; cursor:pointer; border:0; padding:3px 6px;" name="impliedsubmit" id="impliedsubmit" value=" Accetta "/></div>'; 208 html += scriptsDisclosure + 'Maggiori info su <a style="color:'+ settings.linkColor + ';'; 209 html += 'font-weight:bold;font-family:' + settings.fontFamily + ';font-size:' + settings.fontSize + ';" href="'+ settings.privacyPolicyUri + '" target="_blank">'+settings.privacyPolicyTitle+'</a>.<br/>'; 210 //html += '<div style="margin-top:5px; width:100%; text-align:center;"><input type="submit" name="impliedsubmit" id="impliedsubmit" value="Non visualizzare piÃÆÃ¹ questo messaggio"/></div></div>'; 211 html += '</div>'; 212 } 213 html += '</div></div></div>'; 214 $('body').append(html); 215 216 // Serve the disclosure, and be smarter about branching 217 var dp = settings.position.toLowerCase(); 218 if(dp != 'top' && dp!= 'bottom') { 219 dp = 'top'; 220 } 221 var opts = new Array(); 222 if(dp == 'top') { 223 opts['in'] = {'top':'0'}; 224 opts['out'] = {'top':'-300'}; 225 } else { 226 opts['in'] = {'bottom':'0'}; 227 opts['out'] = {'bottom':'-300'}; 228 } 229 230 // Start animation 231 $('#cookiesdirective').animate(opts['in'], 1000, function() { 232 // Set event handlers depending on type of disclosure 233 if(settings.explicitConsent) { 234 // Explicit, need to check a box and click a button 235 $('#explicitsubmit').click(function() { 236 if($('#epdagree').is(':checked')) { 237 // Set a cookie to prevent this being displayed again 238 setCookie('cookiesDirective',1,365); 239 // Close the overlay 240 $('#cookiesdirective').animate(opts['out'],1000,function() { 241 // Remove the elements from the DOM and reload page 242 $('#cookiesdirective').remove(); 243 location.reload(true); 244 }); 245 } else { 246 // We need the box checked we want "explicit consent", display message 247 $('#epdnotick').css('display', 'block'); 248 } 249 }); 250 } else { 251 // Implied consent, just a button to close it 252 $('#impliedsubmit').click(function() { 253 // Set a cookie to prevent this being displayed again
254 setCookie('cookiesDirective', 1, 365); 255 // Close the overlay 256 $('#cookiesdirective').animate(opts['out'],1000,function() { 257 // Remove the elements from the DOM and reload page 258 $('#cookiesdirective').remove(); 259 }); 260 $( "#epd" ).html('<img style="display:none;" src="http://www.regione.sardegna.it/cookie.php"/>'); 261/* $( "#epd" ).html('<img style="display:none;" src="http://area.sardegna.it/cookie.php"/><img style="display:none;" src="http://www.aobrotzu.it/cookie.php"/><img style="display:none;" src="http://www.aoucagliari.it/cookie.php"/><img style="display:none;" src="http://www.aousassari.it/cookie.php"/><img style="display:none;" src="http://www.aslcagliari.it/cookie.php"/><img style="display:none;" src="http://www.aslcarbonia.it/cookie.php"/><img style="display:none;" src="http://www.asllanusei.it/cookie.php"/><img style="display:none;" src="http://www.aslnuoro.it/cookie.php"/><img style="display:none;" src="http://www.aslolbia.it/cookie.php"/><img style="display:none;" src="http://www.asloristano.it/cookie.php"/><img style="display:none;" src="http://www.aslsanluri.it/cookie.php"/><img style="display:none;" src="http://www.aslsassari.it/cookie.php"/><img style="display:none;" src="http://filmcommission.regione.sardegna.it/cookie.php"/><img style="display:none;" src="http://www.comunas.it/cookie.php"/><img style="display:none;" src="http://www.conoscere.it/cookie.php"/><img style="display:none;" src="http://www.isresardegna.it/cookie.php"/><img style="display:none;" src="http://www.regione.sardegna.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaagricoltura.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaambiente.it/cookie.php"/><img style="display:none;" src="http://www.sardegnabiblioteche.it/cookie.php"/><img style="display:none;" src="http://www.sardegnacultura.it/cookie.php"/><img style="display:none;" src="http://www.sardegnadigitallibrary.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaentrate.it/cookie.php"/><img style="display:none;" src="http://www.sardegnageoportale.it/cookie.php"/><img style="display:none;" src="http://www.sardegnait.it/cookie.php"/><img style="display:none;" src="http://www.sardegnamappe.it/cookie.php"/><img style="display:none;" src="http://www.sardegnamigrazioni.it/cookie.php"/><img style="display:none;" src="http://www.sardegnamobilita.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaprogrammazione.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaricerche.it/cookie.php"/><img style="display:none;" src="http://www.sardegnasalute.it/cookie.php"/><img style="display:none;" src="http://www.sardegnasociale.it/cookie.php"/><img style="display:none;" src="http://www.sardegnasolidarieta.it/cookie.php"/><img style="display:none;" src="http://www.sardegnastatistiche.it/cookie.php"/><img style="display:none;" src="http://www.sardegnaterritorio.it/cookie.php"/><img style="display:none;" src="http://www.tesseraservizisardegna.it/cookie.php"/>');*/ 262 }); 263 } 264 265 // Set a timer to remove the warning after 'settings.duration' seconds 266 /*setTimeout(function(){ 267 $('#cookiesdirective').animate({ 268 opacity:'0' 269 },2000, function(){ 270 $('#cookiesdirective').css(dp,'-300px'); 271 }); 272 }, settings.duration * 1000); 273 */ 274 }); 275 } 276})(jQuery);
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.