MediaWiki:Gadget-YTGallery.js

if ($('.yt-gallery-container').length) { $('.yt-gallery-container').each(function(i, el) {		var ids = $(el).attr('data-vids').split('|').map(function(id) { return id.trim; });		$(el).attr('data-current', 0);		$left = $('L ').appendTo(el);		$left.unbind('click');		$left.click(move);		$.each(ids, function(i, id) { var $frame = $('').appendTo(el); if (i === parseInt($(el).attr('data-current'))) $frame.toggleClass('current'); });		$right = $('R ').appendTo(el);		$right.unbind('click');		$right.click(move);	}); }

function move(el) { var $container = $(el.target).parent; var amount = $container.find('iframe').length; var change = parseInt($(el.target).attr('data-change')); var current = parseInt($container.attr('data-current')); if (current + change > amount-1) current += change - amount; else if (current + change < 0) current += change + amount; else current += change; $container.find('.current')[0].contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*'); $container.find('.current').toggleClass('current'); $container.find('iframe').eq(current).toggleClass('current'); $container.attr('data-current', current); }