MediaWiki:Group-user.js: Difference between revisions
From Halopedia, the Halo wiki
No edit summary |
mNo edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
/* Upload cleanup and fix mobile */ | /* Upload cleanup and fix mobile */ | ||
$(function() { | $(function() { | ||
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload | if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) { | ||
if (mw.config.get('wgMFMode')) { | if (mw.config.get('wgMFMode')) { | ||
$("#wpUploadFile").change(function() { | $("#wpUploadFile").change(function() { | ||
Line 14: | Line 14: | ||
}); | }); | ||
} | } | ||
$(' | $('.mw-htmlform-submit-buttons > *').click(function() { | ||
var file = $('#wpDestFile').val().replace(/\.+$/, ''); | var file = $('#wpDestFile').val().replace(/\.+$/, ''); | ||
if (file.includes('.')) { | if (file.includes('.')) { | ||
var fileName = file.substr(0, file.lastIndexOf('.')).replace(/ | var fileName = file.substr(0, file.lastIndexOf('.')).replace(/[.-]+$/, '').trim(); | ||
var fileExt = file.split('.').pop().toLowerCase(); | var fileExt = file.split('.').pop().toLowerCase().split('?')[0].trim(); | ||
var regex = new RegExp('(\.' + fileExt + ')+$', 'i'); | var regex = new RegExp('(\.' + fileExt + ')+$', 'i'); | ||
fileName = fileName.replace(regex, ''); | fileName = fileName.replace(regex, ''); | ||
if (fileExt == 'jpeg' || fileExt == 'jfif') | if (fileExt == 'jpeg' || fileExt == 'jfif') | ||
fileExt = 'jpg'; | fileExt = 'jpg'; | ||
if (fileExt == 'mpeg') | |||
fileExt = 'mpg'; | |||
if (fileExt == 'midi') | |||
fileExt = 'mid'; | |||
$('#wpDestFile').val(fileName + '.' + fileExt); | $('#wpDestFile').val(fileName + '.' + fileExt); | ||
} | } | ||
Line 31: | Line 35: | ||
}); | }); | ||
/* | /* Halo/HotCat upload scripts */ | ||
$(function() { | $(function() { | ||
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) { | if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) { | ||
mw.loader.load('/MediaWiki: | mw.loader.load('/MediaWiki:UploadScript.js?action=raw&ctype=text/javascript'); | ||
if ($.inArray('ext.gadget.HotCat', RLPAGEMODULES) === -1) { | if ($.inArray('ext.gadget.HotCat', RLPAGEMODULES) === -1) { | ||
mw.loader.load('/MediaWiki:Gadget-HotCat.js?action=raw&ctype=text/javascript'); | mw.loader.load('/MediaWiki:Gadget-HotCat.js?action=raw&ctype=text/javascript'); | ||
Line 40: | Line 44: | ||
} | } | ||
} | } | ||
}); | }); |
Latest revision as of 17:29, April 2, 2024
/* 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, ''));
});
}
});
/* Halo/HotCat upload scripts */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) {
mw.loader.load('/MediaWiki:UploadScript.js?action=raw&ctype=text/javascript');
if ($.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');
}
}
});