User:K599/Vimeo.js

//Author: K599 / Kelvs599

//Code based on https://dev.fandom.com/wiki/MediaWiki:YoutubePlayer/code.js

//Loading this JavaScript allows Vimeo videos to be embedded by inserting the following code: // //Explanations for each parameter can be found on https://vimeo.zendesk.com/hc/en-us/articles/360001494447-Using-Player-Parameters //Default width and height is 640x360.

mw.hook('wikipage.content').add(function($content) {   $content.find('.vimeo:not(.loaded)').each(function { var $this = $(this), data = $this.data, uri = new mw.Uri('https://player.vimeo.com/video/');

uri.path += String(data.id || '').trim; uri.query = { autoplay: String(data.autoplay ?? '').trim, loop: String(data.loop ?? '').trim, color: String(data.color || '').trim, portrait: String(data.portrait ?? '').trim, title: String(data.title ?? '').trim, byline: String(data.byline ?? '').trim, muted: String(data.muted ?? '').trim, autopause: String(data.autopause ?? '').trim };       uri.fragment = 't=' + String(data.time || '').trim;

$this.html(           $(' ', { src: uri.toString, style: 'width: ' + (typeof data.width === 'number' ? data.width + 'px' : String(data.width || '640px').trim) + '; height: ' + (typeof data.height === 'number' ? data.height + 'px' : String(data.height || '360px').trim) + ';', frameborder: '0', allowfullscreen: 'true', allow: 'autoplay; fullscreen; picture-in-picture;' })       ).addClass('loaded'); }); });