User:Frietjes/replace.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','#','Search/replace','t-search-replace'); $(portletlink).click(function(e) {			e.preventDefault;			wpTextboxReplace;		}); }); }

function wpTextboxReplace { var s = prompt("Search regexp:"); if(s){ var r = prompt("Replace /"+s+"/ with:"); if(!r && r !== '') return; r = r.replace(/\\n/g, '\n'); r = r.replace(/\\t/g, "\t"); var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "mg"), r); } }

});