MediaWiki:Group-user.js: Difference between revisions
From Halopedia, the Halo wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for registered users only */ | /* Any JavaScript here will be loaded for registered users only */ | ||
/* | /* Upload cleanup and fix mobile */ | ||
$(function() { | $(function() { | ||
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length && !$('.warning').length) { | if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length && !$('.warning').length) { | ||
Line 20: | Line 20: | ||
var fileExt = file.split('.').pop().toLowerCase(); | var fileExt = file.split('.').pop().toLowerCase(); | ||
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'; | ||
$('#wpDestFile').val(fileName + '.' + fileExt); | $('#wpDestFile').val(fileName + '.' + fileExt); | ||
} | } | ||
var textAreas = ['#wpDestFile', '#wpUploadDescription']; | |||
for (var i = 0; i < textAreas.length; i++) { | |||
if ($(textAreas[i]).length) | |||
$(textAreas[i]).val($(textAreas[i]).val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]/g, "'").replace(/[“”]/g, '"')); | |||
} | |||
}); | }); | ||
} | } |
Revision as of 11:10, March 5, 2023
/* Any JavaScript here will be loaded for registered users only */
/* Upload cleanup and fix mobile */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length && !$('.warning').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);
});
}
$('input[name=wpUpload]').click(function() {
var file = $('#wpDestFile').val().replace(/\.+$/, '');
if (file.includes('.')) {
var fileName = file.substr(0, file.lastIndexOf('.')).replace(/\.+$/, '');
var fileExt = file.split('.').pop().toLowerCase();
var regex = new RegExp('(\.' + fileExt + ')+$', 'i');
fileName = fileName.replace(regex, '');
if (fileExt == 'jpeg' || fileExt == 'jfif')
fileExt = 'jpg';
$('#wpDestFile').val(fileName + '.' + fileExt);
}
var textAreas = ['#wpDestFile', '#wpUploadDescription'];
for (var i = 0; i < textAreas.length; i++) {
if ($(textAreas[i]).length)
$(textAreas[i]).val($(textAreas[i]).val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]/g, "'").replace(/[“”]/g, '"'));
}
});
}
});
/* Halopedia/HotCat upload scripts */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !$('#wpForReUpload').length) {
mw.loader.load('/MediaWiki:HalopediaUpload.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');
}
}
});
/* Username inserts for Template:USERNAME */
$(function() {
if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || mw.config.get('wgUserName') === null) return;
$('span.insertusername').each(function() {
$(this).text(mw.config.get('wgUserName'));
});
});