1const hpGTMDataLayer = (type, element) => ( 2 window.dataLayer.push({ 3 'event': type, 4 'promotions': { 5 'id': element.id, 6 'type': element.href, 7 'position': element.getAttribute('slot') 8 } 9 }) 10); 11 12const promoClicked = event => { 13 let target = event.target.offsetParent; 14 hpGTMDataLayer('promotionClick', target); 15} 16 17const promoView = element => { 18 if (element.classList.contains('banner-item') && element.hasAttribute('slot')) { 19 if (window.dataLayer.some((data) => (data.event === 'promoView' && data.promotions.id === element.id))) return; 20 hpGTMDataLayer('promoView', element); 21 } 22} 23 24const promoLoad = () => { 25 if (document.querySelector('.hp-banners') && document.querySelector('.hp-banners').children.length > 1) { 26 let hpBanners = document.querySelector('.hp-banners'), 27 hpBannersChldrn = hpBanners.children, counter = 0; 28 29 Array.from(hpBannersChldrn).forEach(element => { 30 if (element.classList.contains('banner-item')) { 31 counter++; 32 element.setAttribute("slot", `slot${counter}`); 33 hpGTMDataLayer('promoLoad', element); 34 } 35 }); 36 } 37} 38document.addEventListener("DOMContentLoaded", promoLoad); 39 40if (!!window.IntersectionObserver) { 41 let hpBanners = document.querySelectorAll('.banner-item'), 42 observer = new IntersectionObserver((entries) => { 43 entries.forEach(entry => { 44 if (entry.isIntersecting) { 45 promoView(entry.target); 46 } 47 }); 48 }, {threshold: 1}); 49 hpBanners.forEach(hpBanner => observer.observe(hpBanner)); 50}
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.