|
(→Actualizar Acumulados del Empleado)
|
(→Actualizar Acumulados del Empleado)
|
| Line 13: | |||
| <script> | <script> | ||
| - | // Find all the YouTube video embedded on a page | + | function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()} |
| - | var videos = document.getElementsByClassName("youtube"); | + | r(function(){ |
| + | if (!document.getElementsByClassName) { | ||
| + | // IE8 support | ||
| + | var getElementsByClassName = function(node, classname) { | ||
| + | var a = []; | ||
| + | var re = new RegExp('(^| )'+classname+'( |$)'); | ||
| + | var els = node.getElementsByTagName("*"); | ||
| + | for(var i=0,j=els.length; i<j; i++) | ||
| + | if(re.test(els[i].className))a.push(els[i]); | ||
| + | return a; | ||
| + | } | ||
| + | var videos = getElementsByClassName(document.body,"youtube"); | ||
| + | } else { | ||
| + | var videos = document.getElementsByClassName("youtube"); | ||
| + | } | ||
| - | for (var i=0; i<videos.length; i++) { | + | var nb_videos = videos.length; |
| + | for (var i=0; i<nb_videos; i++) { | ||
| + | // Based on the YouTube ID, we can easily find the thumbnail image | ||
| + | videos[i].style.backgroundImage = 'url(http://i.ytimg.com/vi/' + videos[i].id + '/sddefault.jpg)'; | ||
| - | var youtube = videos[i]; | + | // Overlay the Play icon to make it look like a video player |
| + | var play = document.createElement("div"); | ||
| + | play.setAttribute("class","play"); | ||
| + | videos[i].appendChild(play); | ||
| - | // Based on the YouTube ID, we can easily find the thumbnail image | + | videos[i].onclick = function() { |
| - | var img = document.createElement("img"); | + | // Create an iFrame with autoplay set to true |
| - | img.setAttribute("src", "http://i.ytimg.com/vi/" | + | var iframe = document.createElement("iframe"); |
| - | + youtube.id + "/hqdefault.jpg"); | + | var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1"; |
| - | img.setAttribute("class", "thumb"); | + | if (this.getAttribute("data-params")) iframe_url+='&'+this.getAttribute("data-params"); |
| + | iframe.setAttribute("src",iframe_url); | ||
| + | iframe.setAttribute("frameborder",'0'); | ||
| + | // The height and width of the iFrame should be the same as parent | ||
| + | iframe.style.width = this.style.width; | ||
| + | iframe.style.height = this.style.height; | ||
| - | // Overlay the Play icon to make it look like a video player | + | // Replace the YouTube thumbnail with YouTube Player |
| - | var circle = document.createElement("div"); | + | this.parentNode.replaceChild(iframe, this); |
| - | circle.setAttribute("class","circle"); | + | } |
| + | } | ||
| - | youtube.appendChild(img); | + | }); |
| - | youtube.appendChild(circle); | ||
| - | // Attach an onclick event to the YouTube Thumbnail | ||
| - | youtube.onclick = function() { | ||
| - | // Create an iFrame with autoplay set to true | ||
| - | var iframe = document.createElement("iframe"); | ||
| - | iframe.setAttribute("src", | ||
| - | "https://www.youtube.com/embed/" + this.id | ||
| - | + "?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1"); | ||
| - | // The height and width of the iFrame should be the same as parent | ||
| - | iframe.style.width = this.style.width; | ||
| - | iframe.style.height = this.style.height; | ||
| - | // Replace the YouTube thumbnail with YouTube HTML5 Player | ||
| - | this.parentNode.replaceChild(iframe, this); | ||
| - | |||
| - | }; | ||
| - | } | ||
| </script> | </script> | ||