1/** 2 * Copyright (C) 2022 Codeplay Software Limited 3 * All Rights Reserved. 4 * 5 * @author Scott Straughan 6 */ 7 8(function ($) { 9 /** 10 * Cookie Policy Manager JQuery Plugin. 11 * @returns {$.fn.AlertBanner} 12 * @constructor 13 */ 14 $.fn.AlertBanner = function () { 15 const fThis = this; 16 const fCookieName = 'CDCHIDEALERT' 17 18 /** 19 * Set (or create) a cookie with a value. 20 * @param key 21 * @param value 22 */ 23 function setCookie(key, value) { 24 let expires = new Date(); 25 expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000)); 26 27 let cookieValue = key + '=' + value + '; expires=' + expires.toUTCString() + '; path=/; SameSite=Strict;'; 28 29 if (location.protocol === 'https:') { 30 cookieValue += ' Secure;'; 31 } 32 33 document.cookie = cookieValue; 34 } 35 36 /** 37 * Get a specific cookies value. 38 * @param key 39 * @returns {any} 40 */ 41 function getCookie(key) { 42 const keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 43 44 if (!keyValue) { 45 return false; 46 } 47 48 return keyValue[2] === 'true'; 49 } 50 51 /** 52 * Init on document ready. 53 */ 54 $(function() { 55 if (!getCookie(fCookieName)) { 56 if (getCookie('CDCCOOKIESACCEPTED') === true) { 57 fThis.find('.close').show().css('display', 'flex'); 58 fThis.find('.cookies-disabled').hide(); 59 } 60 61 fThis.show(); 62 } 63 64 fThis.find('.close').click(function () { 65 setCookie(fCookieName, true); 66 fThis.close(); 67 }); 68 }); 69 70 this.show = function () { 71 fThis.slideDown(); 72 }; 73 74 this.close = function () { 75 fThis.slideUp(); 76 }; 77 78 return this; 79 } 80})(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.