Skip to content

Instantly share code, notes, and snippets.

@nicastelo
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicastelo/150aa81ba6bd01d555c0 to your computer and use it in GitHub Desktop.
Save nicastelo/150aa81ba6bd01d555c0 to your computer and use it in GitHub Desktop.
var iSelected = jQuery('.idiom-s');
//Cuando el usuario hace click en algún idioma
iSelected.click(function(){
//Declaramos y/o definimos variables
var changed;
var fPlayer = document.getElementById('player-embed');
var vFrame = document.getElementsByTagName('iframe')[0];
//if(vFrame.src != this.getAttribute('url')){
//Escondemos el iframe
jQuery('iframe:first').fadeOut();
//Mostramos que está cargando
jQuery('#player-embed').append("<i class='fa fa-play-circle fa-spin'></i>");
//Cambiamos la src del iframe por la del idioma clickeado
vFrame.src = this.getAttribute('url');
//Le decimos que ya cambió
changed = true;
//Cuando el iframe esté precargado...
document.getElementsByTagName('iframe')[0].onload = function(){
//Lo mostramos y borramos el mensaje de carga
reShow();
};
//Si pasados 7 segundos, no ha cargado, lo mostramos igual
setTimeout(function(){
reShow();
}, 7000);
function reShow(){
jQuery('#fCarga').remove();
jQuery('iframe:first').fadeIn('slow');
}
//}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment