1$(document).ready(function(){ 2 3 // This code loads the IFrame Player API code asynchronously. 4 var tag = document.createElement('script'); 5 tag.src = "https://www.youtube.com/iframe_api"; 6 var firstScriptTag = document.getElementsByTagName('script')[0]; 7 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 8 9 $(document).on('click','.video-button', function(event){ 10 11 console.log('clicked video-button'); 12 13 // Grab the data-button contents 14 var button = $(this).attr('data-button'); 15 // Turn the data-button attribute into a class 16 var button = "." + button; 17 18 // Clean up the name for data-tags 19 var videoInfo = $(button); 20 21 // Grab the uid and trailer information 22 var uid = $(videoInfo).children(['[data-uid]']).attr('data-uid'); 23 var trailer = $(videoInfo).children('[data-trailer]').attr('data-trailer'); 24 25 if(trailer.indexOf('you') >= 0){ 26 27 if ( trailer != $('#ocular-slide-video-popup .video-frame').attr('data-video') && uid != $('#ocular-slide-video-popup .full-width-video').attr('data-uid') || $('#ocular-slide-video-popup .video-frame').attr('data-video') && $('#ocular-slide-video-popup .full-width-video').attr('data-uid') == '' ) { 28 29 $('#ocular-slide-video-popup iframe, #ocular-slide-video-popup div.video-frame').remove(); 30 $('#ocular-slide-video-popup .full-width-video').append('<div class="video-frame"></div>'); 31 32 // Add attributes to lighbox elements 33 $('#ocular-slide-video-popup .full-width-video').attr('data-pop', 'video-' + uid); 34 $('#ocular-slide-video-popup .full-width-video').attr('data-uid', uid); 35 $('#ocular-slide-video-popup .video-frame').attr('data-video', trailer); 36 $('#ocular-slide-video-popup .video-frame').attr('id', 'video-frame-' + uid); 37 38 onYouTubeIframeAPIReady(); 39 } else { 40 playVideo(); 41 } 42 43 // Show lightbox 44 $('#ocular-slide-video-popup').fadeIn(); 45 46 } else if (trailer.indexOf('vim') >= 0) { 47 48 $('#ocular-slide-video-popup iframe, #ocular-slide-video-popup div.video-frame').remove(); 49 $('#ocular-slide-video-popup .full-width-video').append('<div class="video-frame"></div>'); 50 51 // Add attributes to lighbox elements 52 $('#ocular-slide-video-popup .full-width-video').attr('data-pop', 'video-' + uid); 53 $('#ocular-slide-video-popup .full-width-video').attr('data-uid', uid); 54 $('#ocular-slide-video-popup .video-frame').attr('data-video', trailer); 55 $('#ocular-slide-video-popup .video-frame').attr('id', 'video-frame-' + uid); 56 57 58 var videoName = $('.full-width-video .video-frame').attr('id'); 59 var src = $('.full-width-video .video-frame').attr('data-video'); 60 61 var id = getVimeoId(src); 62 63 var iframe = '<iframe src="https://player.vimeo.com/video/'+ id +'?color=fff&title=0&byline=0&portrait=0&autoplay=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' 64 $('#ocular-slide-video-popup .video-frame').remove(); 65 $('#ocular-slide-video-popup .full-width-video').html(iframe); 66 67 68 // Show lightbox 69 $('#ocular-slide-video-popup').fadeIn(); 70 71 } 72 73 }); 74 75 // Hide lightbox on click 76 $('#ocular-slide-video-popup').click(function(){ 77 78 var src = $('#ocular-slide-video-popup iframe').attr('src') 79 80 if ( src.indexOf('you') >= 0 ) { 81 // Stop Video 82 stopVideo(); 83 } else if ( src.indexOf('vim') >= 0 ) { 84 $('#ocular-slide-video-popup iframe').remove(); 85 } 86 87 // Hide lightbox 88 $('#ocular-slide-video-popup').fadeOut(); 89 }); 90 91 // Stop the closing of lightbox when iframe is clicked 92 $('#ocular-slide-video-popup iframe').click(function(e){ 93 e.stopPropagation(); 94 }); 95 96}); 97 98var player; 99function onYouTubeIframeAPIReady() { 100 var videoName = $('.full-width-video .video-frame').attr('id'); 101 var src = $('.full-width-video .video-frame').attr('data-video'); 102
103 if ( $('.full-width-video .video-frame[data-video]').length ) { 104 105 var youtubeRegex = /^(?:(?:https?:\/\/)?(?:www\.)?)?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/g; 106 var youtube = src.replace(youtubeRegex,'$1'); 107 if (src && youtube!=src){ 108 player = new YT.Player(videoName, { 109 height: '720', 110 width: '1200', 111 videoId: youtube, 112 events: { 113 'onReady' : playVideo 114 } 115 }); 116 } 117 } 118} 119 120// The API will call this function when the video player is ready. 121function playVideo() { 122 player.playVideo(); 123} 124 125// Pause all videos 126function pauseVideo() { 127 player.pauseVideo(); 128} 129 130// Stop all videos 131function stopVideo() { 132 player.stopVideo(); 133} 134 135function getVimeoId( url ) { 136 137 // Look for a string with 'vimeo', then whatever, then a 138 // forward slash and a group of digits. 139 var match = /vimeo.*\/(\d+)/i.exec( url ); 140 141 // If the match isn't null (i.e. it matched) 142 if ( match ) { 143 // The grouped/matched digits from the regex 144 return match[1]; 145 } 146}
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.