User:Frietjes/flagtrans.js

jQuery(document).ready(function($) { if(mw.config.get('wgNamespaceNumber') != -1) {	mw.loader.using(['mediawiki.util']).done( function { var portletlink = mw.util.addPortletLink('p-tb','#','Flag translation','t-flagtrans'); $(portletlink).click(function(e) {			e.preventDefault;			flagtranslationfunction;		}); }); } // // function flagtranslationfunction {  var myContent = document.getElementById('wpTextbox1').value;  var tlist = {};  tlist.goud = 'gold1';  tlist.zilver = 'silver2';  tlist.brons = 'bronze3';  tlist.AT = 'AUT';  tlist.BY = 'BLR';  tlist.CA = 'CAN';  tlist.CH = 'SUI';  tlist.CN = 'CHN';  tlist.CSHH = 'CSK';  tlist.CZ = 'CZE';  tlist.DDDE = 'DDR';  tlist.DE = 'DEU';  tlist.DK = 'DNK';  tlist.FI = 'FIN';  tlist.FR = 'FRA';  tlist.GB = 'GBR';  tlist.HU = 'HUN';  tlist.IT = 'ITA';  tlist.JP = 'JPN';  tlist.KR = 'KOR';  tlist.KZ = 'KAZ';  tlist.LV = 'LVA';  tlist.NL = 'NLD';  tlist.NO = 'NOR';  tlist.PL = 'POL';  tlist.RO = 'ROU';  tlist.RU = 'RUS';  tlist.SE = 'SWE';  tlist.SU = 'URS';  tlist.SUHH = 'URS';  tlist.UA = 'UKR';  tlist.US = 'USA';  tlist.YUCS = 'YUG';  for (var k in tlist) {    if (tlist.hasOwnProperty(k)) {    	var re = new RegExp('(\\{\\{)' + k + '(\\}\\})', 'g'); myContent = myContent.replace(re, '$1' + tlist[k] + '$2'); re = new RegExp('(\\{\\{)' + k + '\-([0-9]+\\}\\})', 'g'); myContent = myContent.replace(re, '$1' + tlist[k] + '|$2'); re = new RegExp('(\\{\\{)' + k + '\-VLAG(\\}\\})', 'g'); myContent = myContent.replace(re, '$1flagicon|' + tlist[k] + '$2'); } }

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value = myContent; document.getElementById('wpSummary').value = 'translating flags'; } document.getElementById('wpDiff').click; } // // });