Gebruiker:Rots61/Clear.js: verschil tussen versies

Uit Wikikids
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, '$1Alaska');
+
text = text.replace(/AK(?!\w)/g, 'Alaska');
text = text.replace(/AL(?!\w)/g, '$1Alabama');
+
text = text.replace(/AL(?!\w)/g, 'Alabama');
text = text.replace(/AR(?!\w)/g, '$1Arkansas');
+
text = text.replace(/AR(?!\w)/g, 'Arkansas');
text = text.replace(/[ ]{2,}/g, '$1 ');
+
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();

        } );
        }
    } );
} );
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:Rots61/Clear.js&oldid=747202"