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