User:Ankry/common.js

mediaWiki.loader.load( '//pl.wikisource.org/w/index.php?title=MediaWiki:Gadget-preload-prp-page-image.js&action=raw&ctype=text/javascript');

$.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(/ /g," "); str = str.replace(/¬ /g,""); str = str.replace(/”/g,'"');			str = str.replace(/“/g,'"'); str = str.replace(/’/g,"'"); str = str.replace(/‘/g,"'"); str = str.replace(/ *— */g,"—"); str = str.replace(/ ([:;!?]) /g,"$1 "); str = str.replace(/ ([a-z\-]*), /ig," $1, "); str = str.replace(/\.\.\./g,"&hellip;"); str = str.replace(/\. \. \./g,"&hellip;"); str = str.replace(/\. \n\. \n\./g,"&hellip;"); str = str.replace(/- \n([^A-Z\n])/g,"$1"); str = str.replace(/([^\.!?"]) \n([^A-Z\n])/g,"$1 $2");			str = str.replace(/([\.!?]) \n([A-Z"'])/g,"$1\n\n$2"); str = str.replace(/: \n("[A-Z])/g,':\n\n$1');			str = str.replace(/([\.!?]") \n([A-Z"'])/g,"$1\n\n$2");			str = str.replace(/ \n/g,"\n");

return $.trim(str); });

$.when(			mw.loader.using( [ 'mediawiki.toolbar' ] )			).then(function {				mw.toolbar.addButton( { imageFile: "//upload.wikimedia.org/wikipedia/commons/9/99/Toolbaricon_templatelink.png", speedTip: "Typo...", imageId: 'wsTypo', onClick: $.wtypo.exec });		});	}); }