1var youtubeID = jQuery('#videoArea').data('id') ? jQuery('#videoArea').data('id') : false; 2 3var tag = document.createElement('script'); 4 5tag.src = "https://www.youtube.com/player_api"; 6var firstScriptTag = document.getElementsByTagName('script')[0]; 7firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 8 9// 3. This function creates an <iframe> (and YouTube player) 10// after the API code downloads. 11var player; 12var playing = null; 13 14function onYouTubeIframeAPIReady() { 15 player = new YT.Player('youtubePlayer', { 16 videoId: youtubeID, 17 playerVars: { 18 autohide: 1, 19 autoplay: 0, 20 controls: 0, 21 enablejsapi: 1, 22 iv_load_policy: 3, 23 loop: 0, 24 modestbranding: 1, 25 playsinline: 1, 26 rel: 0, 27 showinfo: 0, 28 wmode: "opaque" 29 }, 30 origin: location.origin, 31 events: { 32 onReady: function (e) { 33 e.target.mute(); 34 e.target.playVideo(); 35 vidRescale(); 36 }, 37 onStateChange: onPlayerStateChange 38 } 39 }); 40} 41 42jQuery(window).on('load resize', function () { 43 vidRescale(); 44}); 45 46jQuery('.homepage-header').on('click', function () { 47 if (documentSize() <= 576 && playing != true) { 48 if (player.getPlayerState) { 49 player.mute(); 50 player.playVideo(); 51 vidRescale(); 52 jQuery('#youtubePlayer').addClass('active'); 53 playing = true; 54 } 55 } else { 56 console.warn('already playing'); 57 } 58}); 59 60function onPlayerStateChange(e) { 61 if (e.data === 1) { 62 jQuery('#youtubePlayer').addClass('active'); 63 playing = true; 64 } else if (e.data === 2) { 65 jQuery('#youtubePlayer').removeClass('active'); 66 } else if (e.data === 0) { 67 e.target.playVideo(); 68 } 69} 70 71function vidRescale() { 72 var w = jQuery(window).width() + 200, 73 h = jQuery(window).height() + 200; 74 if (w / h > 16 / 9) { 75 player.setSize(w, w / 16 * 9); 76 jQuery('#videoArea #youtubePlayer').css({ 77 'left': -getVideoCenter(w) 78 }); 79 } else { 80 player.setSize(h / 9 * 16, h); 81 jQuery('#videoArea #youtubePlayer').css({ 82 'left': -(jQuery('#videoArea #youtubePlayer').outerWidth() - w) / 2 83 }); 84 } 85} 86 87function getVideoCenter(w) { 88 var holderSize = jQuery('#videoArea').width(); 89 var windowSize = w; 90 var totalSize = w - holderSize; 91 return totalSize / 2; 92} 93 94function documentSize() { 95 return jQuery(document).width(); 96}
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.