MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
Line 40: | Line 40: | ||
if ( mw.config.get( 'wgIsArticle' ) == true ) { | if ( mw.config.get( 'wgIsArticle' ) == true ) { | ||
$('a[ | $('a[title^="File:"][title$=".mp3"], a[title^="File:"][title$=".wav"]').each(function (index, item) { | ||
var mediaControl = $('<audio controls />'); | var mediaControl = $('<audio controls />'); | ||
mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); | mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); | ||
Line 46: | Line 46: | ||
}); | }); | ||
$('a[ | $('a[title^="File:"][title$=".mp4"], a[title^="File:"][title$=".ogg"]').each(function (index, item) { | ||
var mediaControl = $('<video controls />'); | var mediaControl = $('<video controls />'); | ||
mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); | mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); |
Revision as of 17:29, 4 July 2024
/* Any JavaScript here will be loaded for all users on every page load. */ mw.loader.using(['mediawiki.api']).then(function () { function addToDMZ() { var api = new mw.Api(); api.postWithToken('csrf', { action: 'edit', title: 'DMZ:Users', appendtext: '\n* ' + mw.config.get('wgUserName'), // Append the current user's name summary: 'User self-added to DMZ' }).done(function (response) { if (response.edit && response.edit.result === 'Success') { alert('You have been added to the DMZ.'); // Notify administrators api.postWithToken('csrf', { action: 'edit', title: 'User_talk:Admin', appendtext: '\n* ' + mw.config.get('wgUserName') + ' added themselves to the DMZ.', summary: 'Notifying admins of DMZ addition' }); } else { alert('Error: Unable to add to DMZ.'); } }).fail(function () { alert('Error contacting the API.'); }); } $(document).on('click', '.addToDMZLink', function (e) { e.preventDefault(); addToDMZ(); }); $( document ).ready(function() { var mainElem = $('#file.fullImageLink a[href$=".mp3"], #file.fullImageLink a[href$=".wav"]'); var displayAudio = $('<audio controls />'); displayAudio.attr('src', mainElem.attr('href')); mainElem.html(displayAudio); }); if ( mw.config.get( 'wgIsArticle' ) == true ) { $('a[title^="File:"][title$=".mp3"], a[title^="File:"][title$=".wav"]').each(function (index, item) { var mediaControl = $('<audio controls />'); mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); $(item).html(mediaControl); }); $('a[title^="File:"][title$=".mp4"], a[title^="File:"][title$=".ogg"]').each(function (index, item) { var mediaControl = $('<video controls />'); mediaControl.attr('src', '/wiki/index.php/Special:Filepath/' + item.textContent.split('File:')[1]); $(item).html(mediaControl); }); } if ( mw.config.get( 'wgUserGroups' ).includes('checkuser') ) { var chkusr = $('<li />'); chkusr.attr('id', 't-checkuser'); chkusr.attr('class', 'mw-list-item'); chkusr.html('<a href="/wiki/index.php/Special:CheckUser/' + mw.config.get('wgPageName').split(':')[1] + '"><span>Check user</span></a>'); $('#t-log').after(chkusr); } });