Difference between revisions of "MediaWiki:Common.js"
From Protoi Healing
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
+ | |||
+ | $('.video').on('click', function() { | ||
+ | $(this).html('<iframe width="560" height="315" src="//www.youtube.com/embed/9bZkp7q19f0?autoplay=1" frameborder="0" allowfullscreen></iframe>').css('background', 'none'); | ||
+ | }); | ||
+ | function getYoutubeID(url) { | ||
+ | var id = url.match("[\\?&]v=([^&#]*)"); | ||
+ | id = id[1]; | ||
+ | return id; | ||
+ | }; | ||
+ | $('a.youtube').each(function() { | ||
+ | var id = getYoutubeID( this.href ); | ||
+ | this.id = id; | ||
+ | var thumb_url = "http://img.youtube.com/vi/"+id+"/maxresdefault.jpg"; | ||
+ | $('<img width="100%" src="'+thumb_url+'" />').appendTo($(this.parentNode)); |
Revision as of 10:28, 31 May 2016
/* Any JavaScript here will be loaded for all users on every page load. */
$('.video').on('click', function() {
$(this).html('<iframe width="560" height="315" src="//www.youtube.com/embed/9bZkp7q19f0?autoplay=1" frameborder="0" allowfullscreen></iframe>').css('background', 'none');
});
function getYoutubeID(url) {
var id = url.match("[\\?&]v=([^&#]*)");
id = id[1];
return id;
};
$('a.youtube').each(function() {
var id = getYoutubeID( this.href );
this.id = id;
var thumb_url = "http://img.youtube.com/vi/"+id+"/maxresdefault.jpg";
$('<img width="100%" src="'+thumb_url+'" />').appendTo($(this.parentNode));