User:Vildricianus/replace2.js

//

// my on-wiki replacement tool for things that need UTF-8

function textReplace { var oldtext = txt;

txt = txt.replace(/   /g, ""); txt = txt.replace(/\n/g, "]]\n"); txt = txt.replace(/\* /g, "*[[");

if (txt != oldtext) { document.editform.wpSummary.value = "replacement done"; } }

function autoFormat { pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue; if (pagetitle.search(/Editing /) == -1) return; pagetitle = pagetitle.replace(/Editing /g, ""); pageexternal = pagetitle.replace(/\ /g, "_");

if (pagetitle.search(/\:/) != -1) { return; }

txt = " " + document.editform.wpTextbox1.value; txt = txt.substr (1, txt.length-1); myoldtxt = txt; oldtxt = txt; if (txt.length < 2) txt = " " + txt;

textReplace;

if (txt==" ") txt = ""; document.editform.wpTextbox1.value = txt;

}

function reformatMyPage { autoFormat; }

window.myAddOnload=function(f) { if (window.addEventListener) window.addEventListener("load", f, false); else if (window.attachEvent) window.attachEvent("onload",f); }

myAddOnload(reformatMyPage);

//