1/** 2 * Violator cookie handling for template-rendered violators 3 * Handles "show once" functionality using cookies 4 */ 5(function() { 6 'use strict'; 7 8 // Wait for DOM to be ready 9 if (document.readyState === 'loading') { 10 document.addEventListener('DOMContentLoaded', initViolators); 11 } else { 12 initViolators(); 13 } 14 15 function initViolators() { 16 var violators = document.querySelectorAll('.violators__violator[data-cookiename]'); 17 18 violators.forEach(function(violator) { 19 var cookieName = violator.getAttribute('data-cookiename'); 20 21 // Hide if cookie exists 22 if (getCookie(cookieName)) { 23 violator.style.display = 'none'; 24 } else { 25 // Add event listener to close button 26 var closeButton = violator.querySelector('.btn-close'); 27 if (closeButton) { 28 closeButton.addEventListener('click', function() { 29 setCookie(cookieName, 'true', 365); 30 }); 31 } 32 } 33 }); 34 } 35 36 function setCookie(name, value, days) { 37 var date = new Date(); 38 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 39 var expires = "expires=" + date.toUTCString(); 40 document.cookie = name + "=" + value + ";" + expires + ";path=/"; 41 } 42 43 function getCookie(name) { 44 var nameEQ = name + "="; 45 var ca = document.cookie.split(';'); 46 for (var i = 0; i < ca.length; i++) { 47 var c = ca[i]; 48 while (c.charAt(0) === ' ') c = c.substring(1, c.length); 49 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); 50 } 51 return null; 52 } 53})();
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.