1function adImpressionUrl(image_url, image_link, position) { 2 return '/actions/ad-tracking/ad-tracking/impression?image_url=' + image_url + '&image_link=' + image_link + '&position=' + position; 3} 4 5function adImpressionLoadOnView(targetElement, image_url, image_link, ad_position) { 6 if (!targetElement) { 7 //console.error("Target element not found:", targetElement); 8 return; 9 } 10 11 function handleIntersection(entries, observer) { 12 entries.forEach(entry => { 13 if (entry.isIntersecting) { 14 // Element is visible 15 //console.log(`Element is visible: ${image_url}`); 16 targetElement.src = image_url; 17 18 // Track the impression 19 //console.log(`Tracking impression for: ${image_url}`); 20 const impressionUrl = adImpressionUrl( 21 image_url, 22 image_link || targetElement.closest('a')?.href || '', 23 ad_position 24 ); 25 26 const impressionTracker = new Image(); 27 impressionTracker.src = impressionUrl; 28 29 } else { 30 // Element has gone out of view 31 //console.log(`Element is not visible: ${image_url}`); 32 targetElement.src = ''; // Remove the image source 33 } 34 }); 35 } 36 37 // Initialize Intersection Observer 38 const observerOptions = { 39 root: null, // Default to the viewport 40 threshold: 0.1, // Trigger when 10% of the element is visible or leaves 41 }; 42 const observer = new IntersectionObserver(handleIntersection, observerOptions); 43 44 // Start observing the target element 45 observer.observe(targetElement); 46}
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.