[dismiss]
Site Notice |
---|
Remember to pay a visit to our Discord server and chat with our community! See here for more info. Be sure to check out the KHUX Wiki for the latest on Kingdom Hearts Union χ and Kingdom Hearts Dark Road! Go and pitch in! The KHWiki contains spoilers for all Kingdom Hearts games. Read at your own risk. Please remember not to add information about unreleased games from trailers. |
MediaWiki:Gadget-GlobalScript.js: Difference between revisions
From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
mNo edit summary |
mNo edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all skins on both desktop and mobile */ | /* Any JavaScript here will be loaded for all skins on both desktop and mobile */ | ||
/* Revert superscript language */ | |||
$(function() { | |||
$('.mw-parser-output [lang] sup').attr('lang', 'en'); | |||
}); | |||
/* Add autocollapse support to mw-collapsible */ | /* Add autocollapse support to mw-collapsible */ | ||
Line 11: | Line 16: | ||
} | } | ||
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup); | mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup); | ||
/* Fix search suggestions on mobile devices */ | |||
$(function() { | |||
$('#searchInput').on('input', function(e) { | |||
$(this).trigger(jQuery.Event('keydown', { | |||
keyCode: e.keyCode, | |||
which: e.which | |||
})); | |||
$(this).trigger(jQuery.Event('keypress', { | |||
keyCode: e.keyCode, | |||
which: e.which | |||
})); | |||
}); | |||
}); | |||
/* Clean-up Unicode */ | /* Clean-up Unicode */ | ||
Line 16: | Line 35: | ||
var textAreas = ['#wpTextbox1', '#wikitext-editor']; | var textAreas = ['#wpTextbox1', '#wikitext-editor']; | ||
for (var i = 0; i < textAreas.length; i++) { | for (var i = 0; i < textAreas.length; i++) { | ||
if ($(textAreas[i]).length) | if ($(textAreas[i]).length) { | ||
$(textAreas[i]).val($(textAreas[i]).val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]{3}/g, "'''").replace(/[‘’]{2}/g, "''")); | $(textAreas[i]).val($(textAreas[i]).val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]{3}/g, "'''").replace(/[‘’]{2}/g, "''")); | ||
if ($('body:is(.ns-6, .ns-14, .ns-content)').length) | |||
$(textAreas[i]).val($(textAreas[i]).val().replace(/([=}])\n{3,}/g, '$1\n\n').replace(/\n{3,}([={]|<gallery|\[\[Category:)/gi, '\n\n$1')); | |||
} | |||
} | } | ||
} | } |
Latest revision as of 20:38, 3 February 2025
/* Any JavaScript here will be loaded for all skins on both desktop and mobile */
/* Revert superscript language */
$(function() {
$('.mw-parser-output [lang] sup').attr('lang', 'en');
});
/* Add autocollapse support to mw-collapsible */
function mwCollapsibleSetup($collapsibleContent) {
var $element, autoCollapseThreshold = 2;
$.each($collapsibleContent, function(index, element) {
$element = $(element);
if ($collapsibleContent.length >= autoCollapseThreshold && $element.hasClass('autocollapse'))
$element.data('mw-collapsible').collapse();
});
}
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup);
/* Fix search suggestions on mobile devices */
$(function() {
$('#searchInput').on('input', function(e) {
$(this).trigger(jQuery.Event('keydown', {
keyCode: e.keyCode,
which: e.which
}));
$(this).trigger(jQuery.Event('keypress', {
keyCode: e.keyCode,
which: e.which
}));
});
});
/* Clean-up Unicode */
function unicodeFixer() {
var textAreas = ['#wpTextbox1', '#wikitext-editor'];
for (var i = 0; i < textAreas.length; i++) {
if ($(textAreas[i]).length) {
$(textAreas[i]).val($(textAreas[i]).val().replace(/[\u200B-\u200F\uFEFF]/g, '').replace(/[‘’]{3}/g, "'''").replace(/[‘’]{2}/g, "''"));
if ($('body:is(.ns-6, .ns-14, .ns-content)').length)
$(textAreas[i]).val($(textAreas[i]).val().replace(/([=}])\n{3,}/g, '$1\n\n').replace(/\n{3,}([={]|<gallery|\[\[Category:)/gi, '\n\n$1'));
}
}
}
$(function() {
$('#searchform').on('submit', function() {
$('#searchInput').val($('#searchInput').val().replace(/[‘’]/g, "'").replace(/[“”]/g, '"'));
});
if (['edit', 'submit'].includes(mw.config.get('wgAction')) && ![8, 274, 828, 2300].includes(mw.config.get('wgNamespaceNumber'))) {
$('.editButtons input').click(unicodeFixer);
if ($('body.skin-minerva').length)
setTimeout(function() { $('.header-action button').click(unicodeFixer) }, 3000);
}
});