Gebruiker:Rots61/Clear.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 1: | Regel 1: | ||
function fixAbbreviations() { |
function fixAbbreviations() { |
||
var text = document.editform.wpTextbox1.value; |
var text = document.editform.wpTextbox1.value; |
||
− | text = text.replace(/AK(?!\w)/g, ' |
+ | text = text.replace(/AK(?!\w)/g, 'Alaska'); |
− | text = text.replace(/AL(?!\w)/g, ' |
+ | text = text.replace(/AL(?!\w)/g, 'Alabama'); |
− | text = text.replace(/AR(?!\w)/g, ' |
+ | text = text.replace(/AR(?!\w)/g, 'Arkansas'); |
− | text = text.replace(/[ ]{2,}/g, ' |
+ | text = text.replace(/[ ]{2,}/g, ' '); |
document.editform.wpTextbox1.value = text; |
document.editform.wpTextbox1.value = text; |
||
} |
} |
Versie van 15 nov 2022 22:22
function fixAbbreviations() {
var text = document.editform.wpTextbox1.value;
text = text.replace(/AK(?!\w)/g, 'Alaska');
text = text.replace(/AL(?!\w)/g, 'Alabama');
text = text.replace(/AR(?!\w)/g, 'Arkansas');
text = text.replace(/[ ]{2,}/g, ' ');
document.editform.wpTextbox1.value = text;
}
mw.loader.using( 'mediawiki.util', function () {
// Wait for the page to be parsed
$( document ).ready( function () {
if (document.editform) {
var link = mw.util.addPortletLink("p-tb", "#", "Convert abbreviations", "tb-convertabbreviations", "Convert column of US state abbreviations to full names", "");
$( link ).click( function ( event ) {
event.preventDefault();
fixAbbreviations();
} );
}
} );
} );