1 2(function($) { 3 4 window.init_codicts_cvp_init_player_handler = function() { 5 $('div.codicts-video-player.cvp-process').each(function(){ 6 $( this ).removeClass( 'cvp-process' ); 7 attach_video_player( $( this ) ); 8 }); 9 }; 10 11 function create_video_container( vid_cont ) 12 { 13 let video_elem = $('<video id="' + vid_cont.data('id') + '" class="video-js vjs-'+ vid_cont.data('template') +' codicts-video-player" preload="auto"></video>'); 14 vid_cont.replaceWith( video_elem ); 15 return video_elem; 16 } 17 18 function attach_video_player( elem ) 19 { 20 let video_id = elem.data( 'id' ), 21 video_type = elem.data( 'type' ), 22 video_url = elem.data( 'src' ), 23 is_autoplay = Boolean( elem.data( 'autoplay' ) ); 24 25 if ( video_type === 'instagram' ) { 26 attach_alternate_player( elem ); 27 return; 28 } 29 30 let video_elem = create_video_container( elem ); 31 playerAtt = { 32 techOrder: [ video_type, "html5" ], 33 autoplay: is_autoplay, 34 muted : is_autoplay, 35 preload: 'auto', 36 sources: [{ 37 type: "video/" + ( video_type == 'html5' ? 'mp4' : video_type ), 38 src: video_url + ( video_type == 'html5' ? '#t=0.1' : '' ), 39 }], 40 controls: true, 41 controlBar: { 42 pictureInPictureToggle: false 43 }, 44 plugins: { 45 // videoJsResolutionSwitcher: { 46 // default: 'high', 47 // dynamicLabel: true 48 // } 49 }, 50 [video_type]: { 51 autoplay: is_autoplay, 52 controls: 1, 53 disablekb: 1, 54 modestbranding: 1, 55 loop: 0, 56 playsinline: 1, 57 } 58 }; 59 let myPlayer = videojs( video_elem[ 0 ], playerAtt ); 60 61 // let seek_offset = 10, 62 // seek_class_switch = 1000; 63 // 64 // myPlayer.seekButtons({ 65 // forward: seek_offset, 66 // back: seek_offset 67 // }); 68 // 69 video_elem.closest( '.codicts-video-player-wrapper' ).addClass( 'cvpt-' + video_type ); 70 71 myPlayer.on( 'ready', function(){ 72 $(document).trigger('codicts:video-ready'); 73 }); 74 75 myPlayer.on("play", function(e) { 76 var currentPlayerId = e.target.id; 77 if ( $( e.target ).closest( '.codicts-video-player-wrapper' ).length ) { 78 $( e.target ).closest( '.codicts-video-player-wrapper' ).addClass( 'codicts-video-player-is-playing' ); 79 } 80 $('.video-js.codicts-video-player').not('#'+currentPlayerId).each(function(){ 81 if ( this && this.player ) { 82 this.player.pause(); 83 } 84 }); 85 }); 86 87 myPlayer.on("pause", function(e) { 88 if ( $( e.target ).closest( '.codicts-video-player-wrapper.codicts-video-player-is-playing' ).length ) { 89 $( e.target ).closest( '.codicts-video-player-wrapper.codicts-video-player-is-playing' ).removeClass( 'codicts-video-player-is-playing' ); 90 } 91 }); 92 } 93 94 function create_modal() 95 { 96 if ( ! $( '.codicts-video-player-modal' ).length ) { 97 $('body').append('<div class="codicts-modal codicts-video-player-modal" role="dialog"><div class="codicts-modal-content"></div></div>'); 98 99 // add instagram api 100 $('body').append('<script async="" src="//www.instagram.com/embed.js"></script>'); 101 102 $(window).click(function(event) { 103 if (event.target == $(".codicts-video-player-modal")[0]) { 104 hideModal(); 105 } 106 }); 107 108 } 109 } 110 111 function hideModal() { 112 $(".codicts-video-player-modal").fadeOut(function(){ 113 $(this).find( '.codicts-modal-content' ).empty(); 114 }); 115 } 116 117 function showModal() { 118 $(".codicts-video-player-modal").fadeIn(); 119 } 120 121 function removeScripts(html) { 122 return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ''); 123 } 124 125 function attach_alternate_player( elem ) 126 { 127 create_modal(); 128 129 // id="${elem.data('id')}" 130 let template = $( ` 131 <div class="video-js vjs-fluid codicts-video-player codicts-alt-video-player vjs-${elem.data('type')}"> 132 <div> 133 </div> 134 <div class="vjs-poster" aria-disabled="false"> 135 <picture class="vjs-poster" tabindex="-1"><img style="display:none;" class="codicts-pl-thmb" loading="lazy" alt="" src=""></picture> 136 </div> 137 <button class="vjs-big-play-button" type="button" title="Play Video" aria-disabled="false">
138 <span class="vjs-icon-placeholder" aria-hidden="true"></span><span class="vjs-control-text" aria-live="polite">Play Video</span> 139 </button> 140 </div> 141 ` ); 142 143 elem.replaceWith( template ); 144 145 let call_url = elem.data('call-url'), 146 video_url = elem.data( 'src' ); 147 148 template.closest( '.codicts-video-player-wrapper' ).addClass( 'cvpt-' + elem.data('type') ); 149 150 $.getJSON( call_url + video_url, function( data ) { 151 if ( ! data ) { 152 return; 153 } 154 if ( data.hasOwnProperty( 'thumbnail_url' ) ) { 155 if ( data.thumbnail_url != '' ) { 156 template.find( 'img.codicts-pl-thmb' ) 157 .attr( "src", data.thumbnail_url ) 158 .show(); 159 } 160 } 161 162 if ( data.hasOwnProperty( 'author_name' ) ) { 163 // add this class to main wrapper to allow author data injection 164 if ( template.closest( '.codicts-video-player-wrapper' ).length ) { 165 166 let elem_wrapper = template.closest( '.codicts-video-player-wrapper' ).first(); 167 if ( elem_wrapper.find( '.codicts-video-player-author-name .elementor-heading-title' ).length ) { 168 elem_wrapper.find( '.codicts-video-player-author-name .elementor-heading-title' ).text( data.author_name ); 169 elem_wrapper.find( '.codicts-video-player-author-name' ).addClass( 'codicts-vp-dp' ); 170 } 171 if ( elem_wrapper.find( '.codicts-video-player-author-image img' ).length ) { 172 if ( data.hasOwnProperty( 'cached_author_data' ) ) { 173 if ( data.cached_author_data.hasOwnProperty( 'images' ) ) { 174 elem_wrapper.find( '.codicts-video-player-author-image img' ).attr( 'src', data.cached_author_data.images ) 175 .attr( 'data-spai-orig', data.cached_author_data.images ) 176 .attr( 'data-orig', data.cached_author_data.images ); 177 elem_wrapper.find( '.codicts-video-player-author-image' ).addClass( 'codicts-vp-dp' ); 178 } 179 } 180 } 181 } 182 } 183 184 if ( data.hasOwnProperty( 'html' ) ) { 185 template.on( 'click', function(){ 186 $( '.codicts-video-player-modal > .codicts-modal-content' ).html( removeScripts( data.html ) ); 187 $(".video-js").not('.codicts-alt-video-player').each(function (index) { 188 if ( this.player ) { 189 if ( ! this.player.paused() ) { 190 this.player.pause(); 191 } 192 } 193 }); 194 showModal(); 195 if (typeof window.instgrm !== 'undefined') { 196 if (typeof window.instgrm.Embeds.process === 'function') { 197 window.instgrm.Embeds.process(); 198 } 199 } 200 }); 201 } 202 203 }); 204 } 205 206})(jQuery);
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.