User:JPxG/Unbreaker.js
// All this does is fix "br" tags that mess up the syntax highlighter, and replace them with correct "br /" tags.
function doUnbreak() {
//alert("This part works");
tbox = String(document.editform.wpTextbox1.value);
// Get the text from the edit box and store it as "tbox".
//alert("This part works too");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
tbox = tbox.replaceAll("
", "
");
//alert("This part works also also");
document.editform.wpTextbox1.value = tbox;
//alert("And this part");
} // function to replace the stuff with the other stuff
function doSyn() {
tbox = String(document.editform.wpTextbox1.value);
tbox = tbox.replaceAll(`
tbox = tbox.replaceAll(``, ``);
tbox = tbox.replaceAll(`
tbox = tbox.replaceAll(``, ``);
document.editform.wpTextbox1.value = tbox;
} // function to replace the stuff with the other stuff
addOnloadHook(function() {
if (document.editform) {
mw.util.addPortletLink("p-cactions", "javascript:doUnbreak()", "Unbreak", "ca-unbreak", "Unbreak line breaks", "");
mw.util.addPortletLink("p-cactions", "javascript:doSyn()", "syn", "ca-syn", "shighlight", "");
}
}); // onloadhook
//