Jump to content

User:Alpha Quadrant/autoed.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScriptURI('http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/core.js&action=raw&ctype=text/javascript'); //Imports the "framework" script needed to make this function
 
//Import individual modules for use
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodify.js&action=raw&ctype=text/javascript'); // autoEdUnicodify() converts HTML entities to WikiText
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/isbn.js&action=raw&ctype=text/javascript'); // autoEdISBN() fixes ISBN syntax so that WikiMagic can work
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/whitespace.js&action=raw&ctype=text/javascript'); // autoEdWhitespace() cleans up whitespace
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/wikilinks.js&action=raw&ctype=text/javascript'); // autoEdWikilinks() simplifies and shortens wikilinks where appropriate
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/htmltowikitext.js&action=raw&ctype=text/javascript'); // autoEdHTMLtoWikitext() converts HTML to wikitext
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/headlines.js&action=raw&ctype=text/javascript'); // autoEdHeadlines() fixes common headline errors and renames some headers
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodecontrolchars.js&action=raw&ctype=text/javascript'); // autoEdUnicodeControlChars() converts HTML to wikitext
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodehex.js&action=raw&ctype=text/javascript'); // autoEdUnicodeHex() converts hex encoded characters to unicode
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/templates.js&action=raw&ctype=text/javascript'); // autoEdTemplates() cleans up templates
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/tablestowikitext.js&action=raw&ctype=text/javascript'); // autoEdTablestoWikitext() replaces HTML tables with wikitables
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/extrabreaks.js&action=raw&ctype=text/javascript'); // autoEdExtraBreaks() removes extra BR tags
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/links.js&action=raw&ctype=text/javascript'); // autoEdLinks() cleans up common link errors

function autoEdFiles(str) { //MAIN FUNCTION describes list of fixes

    str = str.replace(/Image:/gi, "File:");

    return str;
}

function autoEdFunctions() { //Activates individual modules when "auto ed" tab is clicked
    var txt = document.editform.wpTextbox1;
    txt.value = autoEdUnicodify(txt.value);
    txt.value = autoEdISBN(txt.value);
    txt.value = autoEdWhitespace(txt.value);
    txt.value = autoEdUnicodeHex(txt.value);
    txt.value = autoEdWikilinks(txt.value);
    txt.value = autoEdHTMLtoWikitext(txt.value);
    txt.value = autoEdHeadlines(txt.value);
    txt.value = autoEdUnicodeControlChars(txt.value);
    txt.value = autoEdTemplates(txt.value);
    txt.value = autoEdTablestoWikitext(txt.value);
    txt.value = autoEdExtraBreaks(txt.value);
    txt.value = autoEdLinks(txt.value);
    txt.value = autoEdFiles(txt.value);
}