1/** 2 * @package ConiNet Videos 3 * @author ConiNet 4 * @copyright Copyright (c) 2023 ConiNet 5 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later 6 */ 7 8$(document).ready(function () { 9 10 // YouTube API stuff 11 if ($("body").hasClass("com-cnvideos") && $("#cnvideos").length > 0) { 12 var tag = document.createElement("script"); 13 tag.src = "https://www.youtube.com/iframe_api"; 14 var firstScriptTag = document.getElementsByTagName("script")[0]; 15 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 16 } 17 18 /** 19 * Date: 15/03/2023 20 * Author: A.Gammieri 21 * Description: Iframe YouTube 22 */ 23 try { 24 let elemVideo = $("#cnvideos .element-video"); 25 26 if (elemVideo.length) { 27 $('body').append(` 28 <div class="videolightbox-mask" data-videolightbox="mask"> 29 <div class="videolightbox-container" data-videolightbox="container"> 30 <button style="display: none;" title="Close (Esc)" type="button" class="close">Ã</button> 31 <div class="video-container"></div> 32 </div> 33 </div> 34 `); 35 36 elemVideo.each(function () { 37 let playerId = $(this).attr("data-videolightbox-id"); 38 $(".videolightbox-container>.video-container").append('<div id="' + playerId + '"></div>'); 39 }); 40 } 41 } catch (error) { 42 console.log("Iframe YouTube", error); 43 } 44 /** 45 * End: Iframe YouTube 46 */ 47 48 /** 49 * Date: 15/03/2023 50 * Author: A.Gammieri 51 * Description: Open Video LightBox 52 */ 53 try { 54 let elemVideo = $("#cnvideos .element-video"); 55 let singleVideo = $(".videolightbox-container>.video-container").children(); 56 singleVideo.hide(); 57 58 if (elemVideo.length) { 59 elemVideo.on("click", function () { 60 let videoId = $(this).attr("data-videolightbox-id"); 61 62 singleVideo.each(function (index, element) { 63 if (videoId == $(element).attr("id")) { 64 if (iframeAPIReady(videoId) == true) { 65 $("body").addClass("lightbox-on no-scroll"); 66 $('body [data-videolightbox="mask"]').css("display", "block"); 67 $('body [data-videolightbox="container"]').addClass('visible'); 68 69 setTimeout(() => { 70 $(".videolightbox-container>.close").show(); 71 }, 1000); 72 73 $("#" + videoId).show(); 74 } 75 } 76 }); 77 }); 78 } 79 } catch (error) { 80 console.log("Open Video LightBox", error); 81 } 82 /** 83 * End: Open Video LightBox 84 */ 85 86 /** 87 * Date: 15/03/2023 88 * Author: A.Gammieri 89 * Description: Close Video LightBox 90 */ 91 try { 92 let singleVideo = $(".videolightbox-container>.video-container").children(); 93 let mask = $('body [data-videolightbox="mask"]'); 94 95 mask.on("click", function (e) { 96 $("body").removeClass("lightbox-on no-scroll"); 97 $('body [data-videolightbox="mask"]').css("display", "none"); 98 $('body [data-videolightbox="container"]').removeClass('visible'); 99 $(".videolightbox-container>.keyboard").hide(); 100 101 singleVideo.each(function (index, element) { 102 $("#" + $(element).attr("id")).hide(); 103 stopAllYouTubeVideos(); 104 }); 105 }); 106 } catch (error) { 107 console.log("Close Video LightBox", error); 108 } 109 /** 110 * End: Close Video LightBox 111 */ 112}); 113 114/** 115 * Date: 15/03/2023 116 * Author: A.Gammieri 117 * Description: Iframe YouTube 118 */ 119function iframeAPIReady(videoId) { 120 try { 121 player = new YT.Player(videoId, { 122 height: 390, 123 width: 640, 124 videoId: videoId, 125 playerVars: { 126 'autoplay': 0, 127 'rel': 0, 128 'showinfo': 0, 129 'egm': 0, 130 'showsearch': 0, 131 'controls': 0, 132 'modestbranding': 1, 133 'playlist': videoId 134 }, 135 events: { 136 'onReady': onPlayerReady 137 } 138 }); 139 140 return true; 141 142 } catch (error) { 143 alert("Loading Fallito"); 144 } 145} 146 147function onPlayerReady(event) { 148 // event.target.playVideo(); 149 player.stopVideo(); 150} 151/** 152 * End: Iframe YouTube 153 */ 154 155/** 156 * Date: 15/03/2023 157 * Author: A.Gammieri 158 * Description: Stop Video You Tube 159 */ 160const stopAllYouTubeVideos = () => { 161 var iframes = document.querySelectorAll('iframe'); 162 Array.prototype.forEach.call(iframes, iframe => { 163 iframe.contentWindow.postMessage(JSON.stringify({ 164 event: 'command', 165 func: 'stopVideo' 166 }), '*'); 167 }); 168} 169/** 170 * End: Stop Video You Tube 171 */
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.