1document.addEventListener('DOMContentLoaded', function () { 2 const videoRows = document.querySelectorAll('.is-style-video-bg-row'); 3 4 if (!videoRows.length) { 5 return; 6 } 7 8 videoRows.forEach(row => { 9 // the video element isn't immediately created. we need to observe the changes 10 const observer = new MutationObserver((mutations, obs) => { 11 const video = row.querySelector('video'); 12 const videoControl = row.querySelector('.video-bg-row-control a'); 13 const videoIcon = videoControl.querySelector('i') 14 15 // if we have both elements, set up the event listener and disconnect the observer 16 if (video && videoControl && videoIcon) { 17 setupVideoControls(video, videoControl, videoIcon); 18 obs.disconnect(); // Stop observing once we've found what we need 19 } 20 }); 21 22 // start observing the row for childList changes 23 observer.observe(row, { 24 childList: true, 25 subtree: true 26 }); 27 28 // also check immediately in case the video is already there 29 const video = row.querySelector('video'); 30 const videoControl = row.querySelector('.video-bg-row-control a'); 31 const videoIcon = videoControl.querySelector('i') 32 if (video && videoControl && videoIcon) { 33 setupVideoControls(video, videoControl, videoIcon); 34 observer.disconnect(); 35 } 36 }); 37 38 function setupVideoControls(video, videoControl, videoIcon) { 39 videoControl.addEventListener('click', (evt) => { 40 evt.preventDefault(); 41 if (video.paused) { 42 video.play() 43 videoIcon.classList.remove('fa-play') 44 videoIcon.classList.add('fa-pause') 45 } else { 46 video.pause() 47 videoIcon.classList.remove('fa-pause') 48 videoIcon.classList.add('fa-play') 49 } 50 }, true); 51 } 52});
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.