1(function($) { 2 $.cookit = function(options) { 3 4 // ðï¸ SETTINGS 5 var settings = $.extend({ 6 backgroundColor: '#1c1c1c', 7 messageColor: '#fff', 8 linkColor: '#fad04c', 9 buttonColor: '#fad04c', 10 buttonTextColor:'#00000', 11 messageText: "<b>Do you hungry ?</b> ðª Pursuing navigation on this site, you accept the use of cookies.", 12 linkText: "Learn more", 13 linkUrl: "https://www.cookiesandyou.com", 14 buttonText: "I accept", 15 lifetime: 365 16 }, options); 17 18 // ð¯ DOM ITEMS 19 const body = $("body"); 20 const banner = $("<div id='cookit'></div>"); 21 const container = $("<div id='cookit-container'></div>"); 22 const message = $("<p id='cookit-message'>"+ settings.messageText +"</p>"); 23 const link = $("<a id='cookit-link' href='" + settings.linkUrl + "' target='_blank'>" + settings.linkText + "</a>"); 24 const button = $("<a id='cookit-button' href='#'>" + settings.buttonText + "</a>"); 25 26 // âï¸ CHECK IF COOKIE ALREADY EXISTS 27 if (!getCookie('cookie-consent')) { init(); } 28 29 // â¶ï¸ INITIALISATION 30 function init() { 31 body.append(banner); 32 banner.append(container).css({'background-color': settings.backgroundColor}); 33 container.append(message.css({'color': settings.messageColor})).append(link.css({'color': settings.linkColor})).append(button.css({'background-color': settings.buttonColor,'color': settings.buttonTextColor})); 34 } 35 36 // ð EVENT LISTENER (click) 37 button.on('click', (e) => { 38 e.preventDefault(); 39 banner.remove(); 40 setCookie('cookie-consent', 1, settings.lifetime); 41 }); 42 43 // âï¸ GET COOKIE 44 function getCookie(name) { 45 const decodedCookie = decodeURIComponent(document.cookie); 46 const ca = decodedCookie.split(';'); 47 name = name + "="; 48 for(let i = 0; i < ca.length; i++) { 49 let c = ca[i]; 50 while (c.charAt(0) === ' ') { 51 c = c.substring(1); 52 } 53 if (c.indexOf(name) === 0) { 54 return c.substring(name.length, c.length); 55 } 56 } 57 } 58 59 // âï¸ SET COOKIE 60 function setCookie(name, value, days) { 61 const date = new Date(); 62 date.setTime(date.getTime() + (days*24*60*60*1000)); 63 const expires = "expires=" + date.toUTCString(); 64 var parts = window.location.hostname.split('.'); 65 var upperleveldomain; 66 if(parts.length > 2) { 67 parts.shift(); 68 upperleveldomain = parts.join('.'); 69 } 70 else { 71 upperleveldomain = window.location.hostname; 72 } 73 //document.cookie = name + "=" + value + ";" + expires + ";path=/Secure"; 74 document.cookie = name + "=" + value + ";" + expires + ";domain=" + upperleveldomain + ";path=/"; 75 } 76 77 }; 78})(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.