summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/EmbedVideo/js/evlPlayer.js
blob: 3419e6080b4c0095e6b8f67aed578950e26316a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function(mw, $) {
	$(function() {
		api = new mw.Api();
		$('a.embedvideo-evl').click(function(e){
			e.preventDefault();

			var data = $(this).data('video-json');
			data['action'] = 'embedvideo';
			if (typeof data['player'] === 'undefined') {
				data['player'] = 'default';
			}
			var player = data['player'];
			var container = $('#vplayerbox-'+player);
			if (!container.length) {
				mw.debug('No matching vplayer tag found for this link!');
				return;
			}
			// modify dimensions call to match container size if exists.
			if (container.data('size')) {
				data['dimensions'] = container.data('size');
			}
			api.get( data )
			.done( function( res ) {
				if (typeof res.embedvideo.html !== 'undefined') {
					content = res.embedvideo.html;
				} else {
					content = "There was an error while loading this video";
				}
				if (data.notice) {
					content = content + "<small>" + data.notice + "</small>";
				}
				container.html(content);
			} );
		});
    });
}(mediaWiki, jQuery));