1(function () { 2 function getStorageKey(id) { 3 return 'SiteAlert_' + id + '_Dismiss'; 4 } 5 6 // Called when a user closes a alert. 7 function callback(event) { 8 console.log('CLICKED'); 9 var button = event.currentTarget; 10 var alertId = button.getAttribute('data-id'); 11 var alert = document.getElementById('site-alert-' + alertId); 12 13 // The alert can only be closed once, so we don't need the click handler anymore. 14 button.removeEventListener('click', callback); 15 16 // Remove the alert from the page. 17 alert.parentNode.removeChild(alert); 18 19 // Make sure the alert doesn't re-appear when the page is re-loaded. 20 sessionStorage.setItem(getStorageKey(alertId), 'true'); 21 } 22 23 var alertNodeList = document.querySelectorAll('.site-alert'); 24 var index = 0; 25 var alertId = 0; 26 var button = null; 27 28 for (index; index < alertNodeList.length; index += 1) { 29 alertId = alertNodeList[index].getAttribute('data-id'); 30 31 // Don't display alerts which have been dismissed. 32 if (sessionStorage.getItem(getStorageKey(alertId))) { 33 continue; 34 } 35 36 // Display the alert. 37 alertNodeList[index].setAttribute('aria-hidden', 'false'); 38 39 // Add a click event the "dismiss" button, if it exists. 40 button = document.querySelector('#' + alertNodeList[index].id + ' .site-alert-close'); 41 42 if (button) { 43 // hide close button for browsers without sessionStorage compatibility 44 if (!sessionStorage) { 45 button.style.display = 'none'; 46 } else { 47 button.addEventListener('click', callback); 48 } 49 } 50 } 51}());
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.