1M.widget('stryker-standalone-video', function (standaloneVideoElement) { 2 'use strict'; 3 4 let videoNode; 5 let repeater = window.setInterval(function() { 6 // for non YouTube video 7 window.adobeDataLayer = window.adobeDataLayer || []; 8 let videoNodes = standaloneVideoElement.find('.s7container'); 9 if (!videoNodes || videoNodes.length === 0) { 10 return; 11 } 12 videoNode = videoNodes[0]; 13 14 let oneFourthVideoReached; 15 let halfVideoReached; 16 let threeFourthVideoReached; 17 let videoCompleted; 18 let currentState = 'start'; 19 20 function getTimeInSeconds(time) { 21 let splitTime = time.split(':'); 22 let seconds = 0; 23 if(splitTime.length === 3) { 24 seconds = (+Number(splitTime[0])) * 60 * 60 + (+Number(splitTime[1])) * 60 + (+Number(splitTime[2])); 25 } else if(splitTime.length === 2) { 26 seconds = (+Number(splitTime[0])) * 60 + (+Number(splitTime[1])); 27 } else if(splitTime.length === 1) { 28 seconds = (+Number(splitTime[0])); 29 } 30 return seconds; 31 } 32 33 function updateAdobeDataLayerForVideo(){ 34 return function () { 35 let videoName = videoNode.parentElement.getAttribute('data-asset-name'); 36 let videoTimeString = videoNode.querySelectorAll('.s7videotime')[1].textContent.trim().split('/ ')[1]; 37 let videoTime = getTimeInSeconds(videoTimeString); 38 let played = videoNode.getElementsByClassName('s7button s7playpausebutton')[0].getAttribute('selected'); 39 if(played === 'false' && currentState === 'start') { 40 currentState = 'stop'; 41 window.adobeDataLayer.push({ 42 event: "Video Play", 43 web: { 44 video: { 45 videoName: videoName, // Video Name or ID 46 videoDuration: videoTime // Duration of the video 47 } 48 } 49 }); 50 window.setInterval(function() { 51 let currentTime = Number(videoNode.querySelectorAll('.s7knob')[0].getAttribute('aria-valuenow')); 52 let maxTime = Number(videoNode.querySelectorAll('.s7knob')[0].getAttribute('aria-valuemax')); 53 if(currentTime / maxTime >= 0.25 && oneFourthVideoReached === false) { 54 window.adobeDataLayer.push({ 55 event: "Video Viewed25", 56 web: { 57 video: { 58 videoName: videoName, // Video Name or ID 59 videoDuration: videoTime // Duration of the video 60 } 61 } 62 }); 63 oneFourthVideoReached = true; 64 } else if(currentTime / maxTime >= 0.50 && halfVideoReached === false) { 65 window.adobeDataLayer.push({ 66 event: "Video Viewed50", 67 web: { 68 video: { 69 videoName: videoName, // Video Name or ID 70 videoDuration: videoTime // Duration of the video 71 } 72 } 73 }); 74 halfVideoReached = true; 75 } else if(currentTime / maxTime >= 0.75 && threeFourthVideoReached === false) { 76 window.adobeDataLayer.push({ 77 event: "Video Viewed75", 78 web: { 79 video: { 80 videoName: videoName, // Video Name or ID 81 videoDuration: videoTime // Duration of the video 82 } 83 } 84 }); 85 threeFourthVideoReached = true; 86 } else if(currentTime / maxTime === 1 && videoCompleted === false) { 87 window.adobeDataLayer.push({ 88 event: "Video Completed", 89 web: { 90 video: { 91 videoName: videoName, // Video Name or ID 92 videoDuration: videoTime // Duration of the video 93 } 94 } 95 }); 96 videoCompleted = true; 97 } 98 }, 1000); 99 } else if(currentState === 'stop' && played !== 'false') { 100 window.adobeDataLayer.push({ 101 event: "Video Pause", 102 web: { 103 video: { 104 videoName: videoName, // Video Name or ID 105 videoDuration: videoTime // Duration of the video 106 } 107 } 108 }); 109 currentState = 'start'; 110 } 111 }; 112 } 113 114 function pushPlayPausedData() { 115 return function() { 116 window.setTimeout(updateAdobeDataLayerForVideo(), 1000); 117 }; 118 } 119 120 function addEventListenerToVideos() { 121 oneFourthVideoReached = false;
122 halfVideoReached = false; 123 threeFourthVideoReached = false; 124 videoCompleted = false; 125 videoNode.addEventListener('click', pushPlayPausedData()); 126 } 127 128 addEventListenerToVideos(); 129 clearInterval(repeater); 130 }, 1000); 131});
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.