1 2const players = []; 3 4const onYTubeCreateAllIframe = () => { 5 jQuery('.ytube-api-iframe').each(function(){ 6 const yt_code = jQuery(this).data('video-code'); 7 players[yt_code] = new YT.Player('yt-player-' + yt_code, { 8 height: '100%', 9 width: '100%', 10 videoId: yt_code, 11 events: { 12 'onReady': (event) => onYTPlayerReady(yt_code, event), 13 'onStateChange': (event) => onYTPlayerStateChange(yt_code, event) 14 }, 15 playerVars: {rel:0} 16 }); 17 }); 18} 19 20// The API will call this function when the video player is ready. 21function onYTPlayerReady(yt_code, event) { 22 // event.target.setVolume(0); 23 // event.target.playVideo(); 24} 25 26// The API calls this function when the player's state changes. 27// The function indicates that when playing a video (state=1), 28// the player should play for six seconds and then stop. 29function onYTPlayerStateChange(yt_code, event) { 30 if (event.data == YT.PlayerState.PLAYING && typeof pushEmbeddedVideo !== 'undefined') { 31 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_start'); 32 if (typeof window[yt_code] !== 'undefined') { 33 clearTimeout(window[yt_code]); 34 } 35 window[yt_code] = setTimeout(onYTPlayerProgress, 1000, yt_code); 36 } 37 if (event.data == YT.PlayerState.PAUSED && typeof pushEmbeddedVideo !== 'undefined') { 38 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_stop'); 39 } 40 if (event.data == YT.PlayerState.ENDED && typeof pushEmbeddedVideo !== 'undefined') { 41 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_progress_100'); 42 } 43} 44 45function onYTPlayerProgress(yt_code) { 46 const timeDuration = parseInt(players[yt_code].getDuration().toFixed(0)); 47 const timeCurrent = parseInt(Math.floor(players[yt_code].getCurrentTime()).toFixed(0)); 48 const timeProgressPercent25 = parseInt(Math.floor(timeDuration / 4).toFixed(0)); 49 const timeProgressPercent50 = timeProgressPercent25 * 2; 50 const timeProgressPercent75 = timeProgressPercent25 * 3; 51
52 if (timeCurrent == timeProgressPercent25) { 53 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_progress_25'); 54 } 55 if (timeCurrent == timeProgressPercent50) { 56 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_progress_50'); 57 } 58 if (timeCurrent == timeProgressPercent75) { 59 pushEmbeddedVideo(players[yt_code].getVideoData().title, 'embedded_video_progress_75'); 60 } 61 if (players[yt_code].getPlayerState() == YT.PlayerState.PLAYING && timeCurrent < timeDuration) { 62 if (typeof window[yt_code] !== 'undefined') { 63 clearTimeout(window[yt_code]); 64 } 65 window[yt_code] = setTimeout(onYTPlayerProgress, 1000, yt_code); 66 } 67} 68 69(function( $ ) { 70 'use strict'; 71 72 /** 73 * All of the code for your public-facing JavaScript source 74 * should reside in this file. 75 * 76 * Note: It has been assumed you will write jQuery code here, so the 77 * $ function reference has been prepared for usage within the scope 78 * of this function. 79 * 80 * This enables you to define handlers, for when the DOM is ready: 81 * 82 * $(function() { 83 * 84 * }); 85 * 86 * When the window is loaded: 87 * 88 * $( window ).load(function() { 89 * 90 * }); 91 * 92 * ...and/or other possibilities. 93 * 94 * Ideally, it is not considered best practise to attach more than a 95 * single DOM-ready or window-load handler for a particular page. 96 * Although scripts in the WordPress core, Plugins and Themes may be 97 * practising this, we should strive to set a better example in our own work. 98 */ 99 100 jQuery(document).ready(function($) { 101 // Gestione Wysiwyg 102 103 // Se, e solo se, esiste la sidebar (tpl page-sidebar.php) 104 var sidebar = jQuery(".wysiwyg_index"); 105 var indice_label = jQuery(".indice_label"); 106 107 if ( sidebar.length > 0 ) { 108 109 var h3 = jQuery(".wysiwyg h3"); 110 111 if ( h3.length > 0 ) { 112 113 indice_label.show(); 114 115 jQuery(h3).each(function(k) { 116 var v = $(this).html(); 117 jQuery(this).attr('id', 'indice' + k); 118 jQuery("ul#content-nav").append('<li class="nav-item"><a class="nav-link scroll-link" href="#indice' + k + '">' + v + '</a></li>'); 119 }); 120 121 } 122 123 } 124 125 var assistenza_sidebar = jQuery(".assistenza-rightsidebar"); 126 127 if ( indice_label.is(':hidden') && assistenza_sidebar.length == 0 ) { 128 jQuery(".banner-page-new-widget").hide(); 129 } else { 130 jQuery(".banner-page-new-widget").show(); 131 } 132 133 // smoothScroll(); 134 135 136 if ( !jQuery(".pagination li:first-child a").hasClass('.active') ) { 137 jQuery(".pagination li:first-child").remove(); 138 } 139 140 }); 141 142 /* SMOOTH SCROLL */ 143 144 145})( 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.