1jQuery(document).ready(function ($) { 2 var isSimpleBannerTextSet = simpleBannerScriptParams.simple_banner_text != ""; 3 var isDisabledByPagePath = simpleBannerScriptParams.simple_banner_disabled_page_paths ? simpleBannerScriptParams.simple_banner_disabled_page_paths.split(',') 4 .filter(Boolean) 5 .some(path => { 6 var pathname = path.trim(); 7 if (pathname.at(0) === '*' && pathname.at(-1) === '*') { 8 return window.location.pathname.includes(pathname.slice(1, -1)); 9 } 10 if (pathname.at(0) === '*') { 11 return window.location.pathname.endsWith(pathname.slice(1)); 12 } 13 if (pathname.at(-1) === '*') { 14 return window.location.pathname.startsWith(pathname.slice(0, -1)); 15 } 16 return window.location.pathname === pathname; 17 }) : false; 18 var isSimpleBannerEnabledOnPage = !simpleBannerScriptParams.pro_version_enabled || 19 (simpleBannerScriptParams.pro_version_enabled && !simpleBannerScriptParams.disabled_on_current_page && !isDisabledByPagePath); 20 var isSimpleBannerVisible = isSimpleBannerTextSet && isSimpleBannerEnabledOnPage; 21 22 if (isSimpleBannerVisible) { 23 if (!simpleBannerScriptParams.wp_body_open || !simpleBannerScriptParams.wp_body_open_enabled) { 24 var closeButton = simpleBannerScriptParams.close_button_enabled ? '<button aria-label="Close" id="simple-banner-close-button" class="simple-banner-button">✕</button>' : ''; 25 var prependElement = document.querySelector(simpleBannerScriptParams.simple_banner_insert_inside_element || simpleBannerScriptParams.simple_banner_prepend_element || 'body'); 26 $('<div id="simple-banner" class="simple-banner"><div class="simple-banner-text"><span>' 27 + simpleBannerScriptParams.simple_banner_text 28 + '</span></div>' + closeButton + '</div>') 29 .prependTo(prependElement || 'body'); 30 } 31 32 var bodyPaddingLeft = $('body').css('padding-left') 33 var bodyPaddingRight = $('body').css('padding-right') 34 35 if (bodyPaddingLeft != "0px") { 36 $('head').append('<style type="text/css" media="screen">.simple-banner{margin-left:-' + bodyPaddingLeft + ';padding-left:' + bodyPaddingLeft + ';}</style>'); 37 } 38 if (bodyPaddingRight != "0px") { 39 $('head').append('<style type="text/css" media="screen">.simple-banner{margin-right:-' + bodyPaddingRight + ';padding-right:' + bodyPaddingRight + ';}</style>'); 40 } 41 42 // Add scrolling class 43 function scrollClass() { 44 var scroll = document.documentElement.scrollTop; 45 if (scroll > $("#simple-banner").height()) { 46 $("#simple-banner").addClass("simple-banner-scrolling"); 47 } else { 48 $("#simple-banner").removeClass("simple-banner-scrolling"); 49 } 50 } 51 document.addEventListener("scroll", scrollClass); 52 } 53 54 // Add close button function to close button and close if cookie found 55 function closeBanner() { 56 if (!simpleBannerScriptParams.keep_site_custom_css && document.getElementById('simple-banner-site-custom-css')) document.getElementById('simple-banner-site-custom-css').remove(); 57 if (!simpleBannerScriptParams.keep_site_custom_js && document.getElementById('simple-banner-site-custom-js')) document.getElementById('simple-banner-site-custom-js').remove(); 58 if (document.getElementById('simple-banner-header-margin')) document.getElementById('simple-banner-header-margin').remove(); 59 if (document.getElementById('simple-banner-header-padding')) document.getElementById('simple-banner-header-padding').remove(); 60 if (document.getElementById('simple-banner')) document.getElementById('simple-banner').remove(); 61 } 62 63 if (isSimpleBannerVisible) { 64 var sbCookie = "simplebannerclosed"; 65 66 if (simpleBannerScriptParams.close_button_enabled){ 67 if (getCookie(sbCookie) === "true") { 68 closeBanner(); 69 // Set cookie again here in case the expiration has changed
70 setCookie(sbCookie, "true", simpleBannerScriptParams.close_button_expiration); 71 } else { 72 document.getElementById("simple-banner-close-button").onclick = function() { 73 closeBanner(); 74 setCookie(sbCookie, "true", simpleBannerScriptParams.close_button_expiration); 75 }; 76 } 77 } else { 78 // disable cookie if it exists 79 if (getCookie(sbCookie) === "true") { 80 document.cookie = "simplebannerclosed=true; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; 81 } 82 } 83 } 84 85 // Cookie Getter/Setter 86 function setCookie(cname,cvalue,expiration) { 87 var d; 88 if (expiration === '' || expiration === '0' || parseFloat(expiration)) { 89 var exdays = parseFloat(expiration) || 0; 90 d = new Date(); 91 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 92 } else { 93 d = new Date(expiration); 94 } 95 var expires = "expires=" + d.toUTCString(); 96 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 97 } 98 function getCookie(cname) { 99 var name = cname + "="; 100 var decodedCookie = decodeURIComponent(document.cookie); 101 var ca = decodedCookie.split(';'); 102 for(var i = 0; i < ca.length; i++) { 103 var c = ca[i]; 104 while (c.charAt(0) == ' ') { 105 c = c.substring(1); 106 } 107 if (c.indexOf(name) == 0) { 108 return c.substring(name.length, c.length); 109 } 110 } 111 return ""; 112 } 113 114 // Debug Mode 115 // Console log all variables 116 if (simpleBannerScriptParams.pro_version_enabled && simpleBannerScriptParams.debug_mode) { 117 console.log(simpleBannerScriptParams); 118 } 119});
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.