1if(typeof fcaPcOptions==='object'&&fcaPcOptions.video_enabled){class EventEmitter{constructor(){this.events={}} 2on(event,listener){if(typeof this.events[event]!=='object'){this.events[event]=[]} 3this.events[event].push(listener) 4return()=>this.removeListener(event,listener)} 5removeListener(event,listener){if(typeof this.events[event]==='object'){const idx=this.events[event].indexOf(listener) 6if(idx>-1){this.events[event].splice(idx,1)}}} 7emit(event,...args){if(typeof this.events[event]==='object'){this.events[event].forEach(listener=>listener.apply(this,args))}} 8once(event,listener){const remove=this.on(event,(...args)=>{remove() 9listener.apply(this,args)})}} 10class FCA_PC_Video extends EventEmitter{constructor(selector){super() 11this.video_ready=false 12if(typeof selector===undefined){return} 13this.element=selector 14this.init()} 15init(){this.setup_events() 16this.type=this.video_type() 17this.load_api()} 18load_api(){switch(this.type){case'YOUTUBE':this.api_youtube_load() 19break 20case'WISTIA':this.api_wistia_load() 21break 22case'VIMEO':this.api_vimeo_load() 23break}} 24setup_events(){this.on('api_youtube_loaded',this.api_youtube_setup) 25this.on('api_vimeo_loaded',this.api_vimeo_setup) 26this.on('api_wistia_loaded',this.api_wistia_setup)} 27video_type(){let src=this.element.attr('src') 28if(src===''){this.revoke('pixel cat video: video link not found.') 29return false} 30if(src.indexOf('youtube.com')>-1)return'YOUTUBE' 31if(src.indexOf('vimeo.com')>-1)return'VIMEO' 32if(src.indexOf('fast.wistia.com')>-1)return'WISTIA'} 33revoke(message){if(fcaPcOptions.debug){console.log(message) 34console.log('pixel cat video: revoked ')}} 35api_vimeo_load(){jQuery.getScript('https://player.vimeo.com/api/player.js',()=>{this.emit('api_vimeo_loaded')})} 36api_vimeo_setup(){let player_dom=this.element[0] 37try{this.api=new Vimeo.Player(player_dom) 38this.api.ready().then(()=>{this.api_vimeo_ready()})}catch(e){if(fcaPcOptions.debug) 39console.log(e.message) 40return}} 41api_vimeo_ready(){if(fcaPcOptions.debug){console.log('Pixel Cat video: Vimeo video ready')} 42this.video_ready=true 43this.api.getVideoId().then(id=>{this.video_id=id}) 44this.api.getVideoTitle().then(title=>{this.title=title}) 45this.api.getVideoUrl().then(url=>{this.url=url}) 46this.api.getDuration().then(duration=>{this.duration=duration}) 47this.events_triggered={} 48this.api_vimeo_state_change()} 49api_vimeo_state_change(){this.api.on('play',event=>{this.trigger_event('VideoPlay') 50this.timer=setInterval(this.track_progress.bind(this),1000)}) 51this.api.on('pause',event=>{this.trigger_event('VideoPause',{percentage_watched:this.percentage_watched()+'%'}) 52clearInterval(this.timer)}) 53this.api.on('ended',event=>{this.trigger_event('VideoWatchToEnd') 54clearInterval(this.timer)})} 55api_wistia_load(){jQuery.getScript('//fast.wistia.net/assets/external/E-v1.js',()=>{this.emit('api_wistia_loaded')})} 56api_wistia_setup(){let player_dom=this.element 57let video_src=player_dom.attr('src') 58if(typeof video_src==='undefined'){return} 59const pattern=/(https:\/\/fast\.wistia\.com\/embed\/medias)\/(.*)\.jsonp/let match=video_src.match(pattern) 60if(match===null){if(fcaPcOptions.debug){console.log('no video id match')} 61return} 62this.url=match[1] 63let video_id=match[2] 64if(typeof video_id==='undefined'){if(fcaPcOptions.debug){console.log('pixel cat video: wistia video_id not found.')} 65return} 66window._wq=window._wq||[] 67this.api=window._wq 68this.api.push({id:video_id,onReady:this.api_wistia_ready.bind(this)})} 69api_wistia_ready(video){if(fcaPcOptions.debug){console.log('pixel cat video: wistia video ready.')} 70this.video_ready=true 71this.api=video 72this.video_id=video.data.media.hashedId 73this.title=video.data.media.name!==undefined?video.data.media.name:'Untitled' 74this.url=this.url+'/'+this.video_id 75this.events_triggered={} 76this.api_wistia_state_change.bind(this)()} 77api_wistia_state_change(){this.api.bind('play',event=>{this.trigger_event('VideoPlay')}) 78this.api.bind('pause',event=>{this.trigger_event('VideoPause',{percentage_watched:this.percentage_watched()+'%'})}) 79this.api.bind('percentwatchedchanged',(percent,lastPercent)=>{this.track_progress()}) 80this.api.bind('end',event=>{this.trigger_event('VideoWatchToEnd')})}
81api_youtube_load(){this.load_async_script('https://www.youtube.com/iframe_api')} 82api_youtube_setup(){let player_dom=this.element[0] 83this.api=new YT.Player(player_dom,{events:{'onReady':this.api_youtube_ready.bind(this),'onStateChange':this.api_youtube_state_change.bind(this)}})} 84api_youtube_ready(event){if(fcaPcOptions.debug){console.log('pixel cat video: youtube video ready')} 85this.video_ready=true 86this.data=this.api.getVideoData() 87this.video_id=this.data.video_id 88this.title=this.data.title 89this.url=this.api.getVideoUrl() 90this.events_triggered={}} 91api_youtube_state_change(event){if(fcaPcOptions.debug){console.log(event)} 92switch(event.data){case 0:this.trigger_event('VideoWatchToEnd') 93clearInterval(this.timer) 94break 95case 1:this.trigger_event('VideoPlay') 96this.timer=setInterval(this.track_progress.bind(this),1000) 97break 98case 2:this.trigger_event('VideoPause',{percentage_watched:this.percentage_watched()+'%'}) 99clearInterval(this.timer) 100break}} 101video_youtube_end(){if(fcaPcOptions.debug){console.log('end')}} 102load_async_script(url){let new_script=document.createElement('script') 103let first_script=document.getElementsByTagName('script')[0] 104new_script.src=url 105first_script.parentNode.insertBefore(new_script,first_script) 106if(fcaPcOptions.debug){console.log('pixel cat video: '+url+' has been loaded.')}} 107track_progress(){switch(this.video_type()){case'YOUTUBE':case'VIMEO':case'WISTIA':this.video_track_progress() 108break}} 109video_track_progress(){let percent=this.percentage_watched() 110if(fcaPcOptions.debug){console.log(this.percentage_watched())} 111switch(true){case(percent>=10&&percent<25):this.trigger_event('VideoWatch10Percent') 112break 113case(percent>=25&&percent<50):this.trigger_event('VideoWatch25Percent') 114break 115case(percent>=50&&percent<75):this.trigger_event('VideoWatch50Percent') 116break 117case(percent>=75&&percent<90):this.trigger_event('VideoWatch75Percent') 118break 119case(percent>=90&&percent<100):this.trigger_event('VideoWatch90Percent') 120break}} 121video_params(){return{video_title:this.title,video_url:this.url,video_id:this.video_id}} 122percentage_watched(){switch(this.type){case'YOUTUBE':return Math.round(this.api.getCurrentTime()/this.api.getDuration()*100) 123case'VIMEO':this.api.getCurrentTime().then(current_time=>{this.current_time=current_time}) 124return Math.round(this.current_time/this.duration*100) 125case'WISTIA':return Math.round(this.api.time()/this.api.duration()*100) 126default:return false}} 127trigger_event(action,additional_params={}){if(this.events_triggered[action]){return} 128let params=Object.assign({},this.video_params(),additional_params) 129this.emit('pixel_event','trackCustom',action,params) 130if(action!=='VideoPause'){this.events_triggered[action]=true}}} 131FCA_PC_Video.prototype.__proto__=EventEmitter.prototype;function onYouTubeIframeAPIReady(){fcaPcVideos.forEach(video=>{if(video.type!=='YOUTUBE'){return} 132video.emit('api_youtube_loaded')})} 133window.fcaPcVideos=[];function detect_videos(){let videos=[];jQuery('iframe').each(function(){var char=jQuery(this)[0].src.includes('?')?'&':'?' 134jQuery(this)[0].src=jQuery(this)[0].src+char+'enablejsapi=1' 135videos.push(jQuery(this))}) 136jQuery('script').each(function(){let src=jQuery(this).attr('src') 137if(typeof src==='undefined'){return} 138if(src.indexOf('https://fast.wistia.com/embed/medias/')===-1){return} 139videos.push(jQuery(this))}) 140if(videos.length===0){if(fcaPcOptions.debug){console.log('No videos detected')} 141return}
142videos.forEach(function(video){window.fcaPcVideos.push(new FCA_PC_Video(video))})} 143detect_videos()}
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.