User:Blossfeldia liliputańa/common.js

/* * based on https://fr.wikisource.org/wiki/MediaWiki:Gadget-Typo.js */ $.wtypo = { todo: [], add: function(fonction) { $.wtypo.todo.push(fonction); },	exec: function { var txt = $('#wpTextbox1').val; for (var i = 0; i < $.wtypo.todo.length; ++i) { txt = $.wtypo.todo[i](txt); }		$('#wpTextbox1').val(txt); }, };

if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) { $(function {		//typo		$.wtypo.add(function(str) { str = str.replace(/ll/g,"ł"); str = str.replace(/ly/g,"ły"); str = str.replace(/ç/g,"ę"); str = str.replace(/a,/g,'ą'); str = str.replace(/ñ/g,'ń'); str = str.replace(/C /g,'ć '); str = str.replace(/aC/g,'ać'); str = str.replace(/eC/g,'eć'); str = str.replace(/á/g,'ś'); str = str.replace(/ \n/g,'\n'); str = str.replace(/\{\{ae\}\}/g,'æ'); return $.trim(str); });		$.when( mw.loader.using( [ 'mediawiki.toolbar' ] ) ).then(function { mw.toolbar.addButton( {				imageFile: "//upload.wikimedia.org/wikipedia/commons/e/e9/Button_copy_edit.png",				speedTip: "Typo...",				onClick: $.wtypo.exec			}); });	}); }