Jump to content

Wikipedia:AutoEd/formatter.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Plastikspork (talk | contribs) at 21:04, 11 June 2020 (Per suggestion on the talk page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

//

var AutoEd_baseurl = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Wikipedia:AutoEd/';
if (location.protocol === 'https:') {
  AutoEd_baseurl = 'https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Wikipedia:AutoEd/';
}

//Sets variable configuration
autoEdTag = "Formatting using [[WP:AutoEd|AutoEd]]"; //Tweaks edit summary
autoEdLinkName = "Format"; //Changes the link name at the top of the page
autoEdLinkHover = "Run AutoEd to format page"; //When user hovers over link
 
//Import individual modules for use
importScriptURI(AutoEd_baseurl + 'unicodify.js'); // autoEdUnicodify() converts HTML entities to WikiText
importScriptURI(AutoEd_baseurl + 'whitespace.js'); // autoEdWhitespace() cleans up whitespace
importScriptURI(AutoEd_baseurl + 'wikilinks.js'); // autoEdWikilinks() simplifies and shortens wikilinks where appropriate
importScriptURI(AutoEd_baseurl + 'htmltowikitext.js'); // autoEdHTMLtoWikitext() converts HTML to wikitext
importScriptURI(AutoEd_baseurl + 'headlines.js'); // autoEdHeadlines() fixes common headline errors and renames some headers
importScriptURI(AutoEd_baseurl + 'unicodecontrolchars.js'); // autoEdUnicodeControlChars() converts HTML to wikitext
importScriptURI(AutoEd_baseurl + 'links.js'); // autoEdLinks() cleans up common link errors

function autoEdFunctions() { //Activates individual modules when "auto ed" tab is clicked
    var $textbox = $( '#wpTextbox1' );
    var txt = $textbox.textSelection('getContents');
    txt = autoEdUnicodify(txt);
    txt = autoEdWhitespace(txt);
    txt = autoEdWikilinks(txt);
    txt = autoEdHTMLtoWikitext(txt);
    txt = autoEdHeadlines(txt);
    txt = autoEdUnicodeControlChars(txt);
    txt = autoEdLinks(txt);
    $textbox.textSelection('setContents', txt);
}

$.when( $.ready, mw.loader.using( 'jquery.textSelection' ) ).then(function() {
importScriptURI(AutoEd_baseurl + 'core.js'); //Imports the "framework" script needed to make this function
});
//