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=!1 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!1} 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=!0 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/ 60let match=video_src.match(pattern) 61if(match===null){if(fcaPcOptions.debug){console.log('no video id match')} 62return} 63this.url=match[1] 64let video_id=match[2] 65if(typeof video_id==='undefined'){if(fcaPcOptions.debug){console.log('pixel cat video: wistia video_id not found.')} 66return} 67window._wq=window._wq||[] 68this.api=window._wq 69this.api.push({id:video_id,onReady:this.api_wistia_ready.bind(this)})} 70api_wistia_ready(video){if(fcaPcOptions.debug){console.log('pixel cat video: wistia video ready.')} 71this.video_ready=!0 72this.api=video 73this.video_id=video.data.media.hashedId 74this.title=video.data.media.name!==undefined?video.data.media.name:'Untitled' 75this.url=this.url+'/'+this.video_id 76this.events_triggered={} 77this.api_wistia_state_change.bind(this)()} 78api_wistia_state_change(){this.api.bind('play',event=>{this.trigger_event('VideoPlay')}) 79this.api.bind('pause',event=>{this.trigger_event('VideoPause',{percentage_watched:this.percentage_watched()+'%'})}) 80this.api.bind('percentwatchedchanged',(percent,lastPercent)=>{this.track_progress()}) 81this.api.bind('end',event=>{this.trigger_event('VideoWatchToEnd')})}
82api_youtube_load(){this.load_async_script('https://www.youtube.com/iframe_api')} 83api_youtube_setup(){let player_dom=this.element[0] 84this.api=new YT.Player(player_dom,{events:{'onReady':this.api_youtube_ready.bind(this),'onStateChange':this.api_youtube_state_change.bind(this)}})} 85api_youtube_ready(event){if(fcaPcOptions.debug){console.log('pixel cat video: youtube video ready')} 86this.video_ready=!0 87this.data=this.api.getVideoData() 88this.video_id=this.data.video_id 89this.title=this.data.title 90this.url=this.api.getVideoUrl() 91this.events_triggered={}} 92api_youtube_state_change(event){if(fcaPcOptions.debug){console.log(event)} 93switch(event.data){case 0:this.trigger_event('VideoWatchToEnd') 94clearInterval(this.timer) 95break 96case 1:this.trigger_event('VideoPlay') 97this.timer=setInterval(this.track_progress.bind(this),1000) 98break 99case 2:this.trigger_event('VideoPause',{percentage_watched:this.percentage_watched()+'%'}) 100clearInterval(this.timer) 101break}} 102video_youtube_end(){if(fcaPcOptions.debug){console.log('end')}} 103load_async_script(url){let new_script=document.createElement('script') 104let first_script=document.getElementsByTagName('script')[0] 105new_script.src=url 106first_script.parentNode.insertBefore(new_script,first_script) 107if(fcaPcOptions.debug){console.log('pixel cat video: '+url+' has been loaded.')}} 108track_progress(){switch(this.video_type()){case 'YOUTUBE':case 'VIMEO':case 'WISTIA':this.video_track_progress() 109break}} 110video_track_progress(){let percent=this.percentage_watched() 111if(fcaPcOptions.debug){console.log(this.percentage_watched())} 112switch(!0){case(percent>=10&&percent<25):this.trigger_event('VideoWatch10Percent') 113break 114case(percent>=25&&percent<50):this.trigger_event('VideoWatch25Percent') 115break 116case(percent>=50&&percent<75):this.trigger_event('VideoWatch50Percent') 117break 118case(percent>=75&&percent<90):this.trigger_event('VideoWatch75Percent') 119break 120case(percent>=90&&percent<100):this.trigger_event('VideoWatch90Percent') 121break}} 122video_params(){return{video_title:this.title,video_url:this.url,video_id:this.video_id}} 123percentage_watched(){switch(this.type){case 'YOUTUBE':return Math.round(this.api.getCurrentTime()/this.api.getDuration()*100) 124case 'VIMEO':this.api.getCurrentTime().then(current_time=>{this.current_time=current_time}) 125return Math.round(this.current_time/this.duration*100) 126case 'WISTIA':return Math.round(this.api.time()/this.api.duration()*100) 127default:return!1}} 128trigger_event(action,additional_params={}){if(this.events_triggered[action]){return} 129let params=Object.assign({},this.video_params(),additional_params) 130this.emit('pixel_event','trackCustom',action,params) 131if(action!=='VideoPause'){this.events_triggered[action]=!0}}} 132FCA_PC_Video.prototype.__proto__=EventEmitter.prototype;function onYouTubeIframeAPIReady(){fcaPcVideos.forEach(video=>{if(video.type!=='YOUTUBE'){return} 133video.emit('api_youtube_loaded')})} 134window.fcaPcVideos=[];function detect_videos(){let videos=[];jQuery('iframe').each(function(){var char=jQuery(this)[0].src.includes('?')?'&':'?' 135jQuery(this)[0].src=jQuery(this)[0].src+char+'enablejsapi=1' 136videos.push(jQuery(this))}) 137jQuery('script').each(function(){let src=jQuery(this).attr('src') 138if(typeof src==='undefined'){return} 139if(src.indexOf('https://fast.wistia.com/embed/medias/')===-1){return} 140videos.push(jQuery(this))}) 141if(videos.length===0){if(fcaPcOptions.debug){console.log('No videos detected')} 142return}
143videos.forEach(function(video){window.fcaPcVideos.push(new FCA_PC_Video(video))})} 144detect_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.