MediaWiki:Group-user.js
From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for registered users only */
/* Upload cleanup and fix mobile */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) {
if (mw.config.get('wgMFMode')) {
$("#wpUploadFile").change(function() {
var ogFileName = $("#wpUploadFile").val().split('\\').pop();
$('#wpDestFile').val(ogFileName);
});
$("#wpUploadFileURL").change(function() {
var ogFileName = $("#wpUploadFileURL").val().split('/').pop();
$('#wpDestFile').val(ogFileName);
});
}
$('.mw-htmlform-submit-buttons > *').click(function() {
var file = $('#wpDestFile').val().replace(/\.+$/, '');
if (file.includes('.')) {
var fileName = file.substr(0, file.lastIndexOf('.')).replace(/\.+$/, '').trim();
var fileExt = file.split('.').pop().toLowerCase().split('?')[0].trim();
var regex = new RegExp('(\.' + fileExt + ')+$', 'i');
fileName = fileName.replace(regex, '');
if (fileExt == 'jpeg' || fileExt == 'jfif')
fileExt = 'jpg';
if (fileExt == 'mpeg')
fileExt = 'mpg';
if (fileExt == 'midi')
fileExt = 'mid';
$('#wpDestFile').val(fileName + '.' + fileExt);
}
$('#wpDestFile').val($('#wpDestFile').val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]/g, "'").replace(/[“”]/g, '"'));
$('#wpUploadDescription').val($('#wpUploadDescription').val().replace(/[\u200B-\u200F\uFEFF]/g, ''));
});
}
});
/* HotCat upload script */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length
&& $.inArray('ext.gadget.HotCat', RLPAGEMODULES) === -1) {
mw.loader.load('/MediaWiki:Gadget-HotCat.js?action=raw&ctype=text/javascript');
mw.loader.load('/MediaWiki:Gadget-HotCat.css?action=raw&ctype=text/css', 'text/css');
}
});