User:Qwerfjkl/scripts/convertAbbreviations.js
Appearance
< User:Qwerfjkl | scripts
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Qwerfjkl/scripts/convertAbbreviations. |
function fixAbbreviations() {
var text = document.editform.wpTextbox1.value;
text = text.replace(/(\|\s*)AK(?!\w)/g, '$1Alaska');
text = text.replace(/(\|\s*)AL(?!\w)/g, '$1Alabama');
text = text.replace(/(\|\s*)AR(?!\w)/g, '$1Arkansas');
text = text.replace(/(\|\s*)AZ(?!\w)/g, '$1Arizona');
text = text.replace(/(\|\s*)CA(?!\w)/g, '$1California');
text = text.replace(/(\|\s*)CO(?!\w)/g, '$1Colorado');
text = text.replace(/(\|\s*)CT(?!\w)/g, '$1Connecticut');
text = text.replace(/(\|\s*)DE(?!\w)/g, '$1Delaware');
text = text.replace(/(\|\s*)FL(?!\w)/g, '$1Florida');
text = text.replace(/(\|\s*)GA(?!\w)/g, '$1Georgia');
text = text.replace(/(\|\s*)HI(?!\w)/g, '$1Hawaii');
text = text.replace(/(\|\s*)IA(?!\w)/g, '$1Iowa');
text = text.replace(/(\|\s*)ID(?!\w)/g, '$1Idaho');
text = text.replace(/(\|\s*)IL(?!\w)/g, '$1Illinois');
text = text.replace(/(\|\s*)IN(?!\w)/g, '$1Indiana');
text = text.replace(/(\|\s*)KS(?!\w)/g, '$1Kansas');
text = text.replace(/(\|\s*)KY(?!\w)/g, '$1Kentucky');
text = text.replace(/(\|\s*)LA(?!\w)/g, '$1Louisiana');
text = text.replace(/(\|\s*)MA(?!\w)/g, '$1Massachusetts');
text = text.replace(/(\|\s*)MD(?!\w)/g, '$1Maryland');
text = text.replace(/(\|\s*)ME(?!\w)/g, '$1Maine');
text = text.replace(/(\|\s*)MI(?!\w)/g, '$1Michigan');
text = text.replace(/(\|\s*)MN(?!\w)/g, '$1Minnesota');
text = text.replace(/(\|\s*)MO(?!\w)/g, '$1Missouri');
text = text.replace(/(\|\s*)MS(?!\w)/g, '$1Mississippi');
text = text.replace(/(\|\s*)MT(?!\w)/g, '$1Montana');
text = text.replace(/(\|\s*)NC(?!\w)/g, '$1North Carolina');
text = text.replace(/(\|\s*)ND(?!\w)/g, '$1North Dakota');
text = text.replace(/(\|\s*)NE(?!\w)/g, '$1Nebraska');
text = text.replace(/(\|\s*)NH(?!\w)/g, '$1New Hampshire');
text = text.replace(/(\|\s*)NJ(?!\w)/g, '$1New Jersey');
text = text.replace(/(\|\s*)NM(?!\w)/g, '$1New Mexico');
text = text.replace(/(\|\s*)NV(?!\w)/g, '$1Nevada');
text = text.replace(/(\|\s*)NY(?!\w)/g, '$1New York');
text = text.replace(/(\|\s*)OH(?!\w)/g, '$1Ohio');
text = text.replace(/(\|\s*)OK(?!\w)/g, '$1Oklahoma');
text = text.replace(/(\|\s*)OR(?!\w)/g, '$1Oregon');
text = text.replace(/(\|\s*)PA(?!\w)/g, '$1Pennsylvania');
text = text.replace(/(\|\s*)RI(?!\w)/g, '$1Rhode Island');
text = text.replace(/(\|\s*)SC(?!\w)/g, '$1South Carolina');
text = text.replace(/(\|\s*)SD(?!\w)/g, '$1South Dakota');
text = text.replace(/(\|\s*)TN(?!\w)/g, '$1Tennessee');
text = text.replace(/(\|\s*)TX(?!\w)/g, '$1Texas');
text = text.replace(/(\|\s*)UT(?!\w)/g, '$1Utah');
text = text.replace(/(\|\s*)VA(?!\w)/g, '$1Virginia');
text = text.replace(/(\|\s*)VT(?!\w)/g, '$1Vermont');
text = text.replace(/(\|\s*)WA(?!\w)/g, '$1Washington');
text = text.replace(/(\|\s*)WI(?!\w)/g, '$1Wisconsin');
text = text.replace(/(\|\s*)WV(?!\w)/g, '$1West Virginia');
text = text.replace(/(\|\s*)WY(?!\w)/g, '$1Wyoming');
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();
} );
}
} );
} );