1jQuery(document).ready(function() { 2 jQuery('.video-block button[data-youtube]').on('click',function() { 3 console.log('open youtube'); 4 console.log(jQuery(this).attr('data-youtube')); 5 const ytUrl = jQuery(this).attr('data-youtube'); 6 jQuery('#youtube-modal').fadeIn('fast',function() { 7 const html = getYouTubeEmbedCode(ytUrl,true,false) 8 jQuery('#youtube-modal #youtube-content .iframe').html(html); 9 }); 10 }); 11 jQuery('#youtube-modal #youtube-content .close').on('click',function() { 12 jQuery('#youtube-modal #youtube-content .iframe').html(''); 13 jQuery('#youtube-modal').fadeOut('fast'); 14 }); 15}); 16function getYouTubeEmbedCode(url, autoplay = false, mute = false) { 17 var videoId = ''; 18 if (url.match(/(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&#]+)/)) { 19 videoId = RegExp.$2; 20 } 21 22 var embedCode = ''; 23 if (videoId) { 24 embedCode = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' + videoId + '?rel=0&modestbranding=1&controls=0'; 25 26 if (autoplay) { 27 embedCode += '&autoplay=1'; 28 } 29 30 if (mute) { 31 embedCode += '&mute=1'; // Muting the video to ensure autoplay works in more browsers 32 } 33 34 embedCode += '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; 35 } 36 37 return embedCode; 38} 39 40// Example usage with autoplay and mute enabled 41//var youtubeUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; // Replace with your YouTube URL 42//var embedCode = getYouTubeEmbedCode(youtubeUrl, true, true); // Set autoplay
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.