User:AFigureOfBlue/codefixer.js

// See User:Drilnoth/codefixer.js/doc for details. // Special thanks to User:Plastikspork and the creators of WikiProject User scripts/Scripts/Formatter for their help with coding // if( typeof( codefixerMinor ) == 'undefined' ) { //CONFIGURATION codefixerMinor = true; } function codefixer { //MAIN FUNCTION describes list of fixes var txt = document.editform.wpTextbox1; var page_name = mw.config.get('wgPageName').replace('_',' '); //replace //ISBNs txt.value = txt.value.replace(new RegExp('ISBN-10:|ISBN-13:|ISBN-10|ISBN-13|ISBN:', 'gi'), 'ISBN'); //HTML txt.value = txt.value.replace(/<(B|STRONG)[ ]*>([^<>]*)<\/\1[ ]*>/gi, "$2"); // Wikify  and  txt.value = txt.value.replace(/<(I|EM)[ ]*>([^<>]*)<\/\1[ ]*>/gi, "$2");       // Wikify  and  txt.value = txt.value.replace(/<[\\\/\.]+BR[\\\/\. ]*>/gi, ' '); // Tag starts with a slash or period txt.value = txt.value.replace(/<[\\\/\. ]*BR[ ]*[\\\/\.]+[ ]*>/gi, ' '); // Tag ends with a slash or period txt.value = txt.value.replace(/<[ ]*BR[ ]*>/gi, ' '); // Tag contains no slashes txt.value = txt.value.replace(/([\r\n])[\t ]*<[\\\/\. ]*HR[\\\/\. ]*>/gi, '$1'); txt.value = txt.value.replace(/(.)<[\\\/\. ]*HR[\\\/\. ]*>/gi, '$1\n'); txt.value = txt.value.replace(new RegExp(' ||', 'gi'), ' '); txt.value = txt.value.replace(/([^\r\n ])[\t ]*(]*>)/gim, '$1\n$2');  // Make sure , ...,  is after a newline txt.value = txt.value.replace(/(<\/H[1-6][^<>]*>)[\t ]*([^\r\n ])/gim, '$1\n$2'); // Make sure , ...,  is before a newline txt.value = txt.value.replace(/(^|[\r\n])[\t ]*]*>([^\r\n]*?)<\/H1[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1=$2=$3'); txt.value = txt.value.replace(/(^|[\r\n])[\t ]*]*>([^\r\n]*?)<\/H2[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1==$2==$3'); txt.value = txt.value.replace(/(^|[\r\n])[\t ]*]*>([^\r\n]*?)<\/H3[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1===$2===$3'); txt.value = txt.value.replace(/(^|[\r\n])[\t ]*]*>([^\r\n]*?)<\/H4[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1====$2====$3'); txt.value = txt.value.replace(/(^|[\r\n])[\t ]*]*>([^\r\n]*?)<\/H5[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1=====$2=====$3'); txt.value = txt.value.replace(/(^|[\r\n])[\t ]*<H6[^<>]*>([^\r\n]*?)<\/H6[\r\n\t ]*>[\t ]*([\r\n]|$)/gim, '$1======$2======$3'); //WikiText txt.value = txt.value.replace(new RegExp(':==|: ==', 'gi'), '=='); txt.value = txt.value.replace(new RegExp('==\'\'\'|\'\'\' ==|\'\'\'==|== \'\'\'', 'gi'), '=='); //   txt.value = txt.value.replace(new RegExp('\\[\\[IMAGE\:', 'gi'), '\[\[File\:'); NOTE: Consensus is unclear on this change, so I have commented it out to prevent confusion. txt.value = txt.value.replace(new RegExp('\\[\\[WIKTIONARY\:', 'gi'), '\[\[wikt\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKINEWS\:', 'gi'), '\[\[n\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKIBOOKS\:', 'gi'), '\[\[b\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKIQUOTE\:', 'gi'), '\[\[q\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKISOURCE\:', 'gi'), '\[\[s\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKISPECIES\:', 'gi'), '\[\[species\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKIVERSITY\:', 'gi'), '\[\[v\:'); txt.value = txt.value.replace(new RegExp('\\[\\[WIKIMEDIA\:|\\[\\[FOUNDATION\:', 'gi'), '\[\[wmf\:'); txt.value = txt.value.replace(new RegExp('\\[\\[METAWIKIPEDIA\:', 'gi'), '\[\[m\:'); //Templates txt.value = txt.value.replace(new RegExp('\{\{REFERENCE|\{\{REFS|\{\{REFERENCE LIST|\{\{REFERENCES-SMALL|\{\{REFLINK|\{\{LISTAREF|\{\{REFERENCE LIST|\{\{REF-LIST', 'gi'), '\{\{Reflist'); txt.value = txt.value.replace(new RegExp('<div class=\'references-small\'>\n<references \/>\n<\/div>|<div class=\'references-small\'>\n<references\/>\n<\/div>', 'gi'), '\{\{Reflist\}\}'); txt.value = txt.value.replace(new RegExp('\{\{TEMPLATE:', 'gi'), '\{\{'); //References txt.value = txt.value.replace(new RegExp(' ', 'gi'), ' '); //Unicode control characters txt.value = txt.value.replace(new RegExp('\u200E|\uFEFF|\u200B', 'gi'), ''); //Self-referential links txt.value = txt.value.replace(new RegExp('\\[\\[(' + page_name + ')\\]\\]', 'gi'), '$1'); txt.value = txt.value.replace(new RegExp('\\[\\[(?:' + page_name + '|' + mw.config.get('wgPageName') + ')\\|([^\\]\\|]*)\\]\\]', 'gi'), '$1'); //Correct some section header names, from WP:FORMATTER if( !txt.value.match(/= ?See also ?=/) ) txt.value = txt.value.replace(/(== ?)(see also:?|related topics:?|related articles:?|internal links:?|also see:?)( ?==)/gi, "$1See also$3"); txt.value = txt.value.replace(/(== ?)(external links?:?|outside links?|web ?links?:?|exterior links?:?)( ?==)/gi, "$1External links$3"); txt.value = txt.value.replace(/(== ?)(references?:?)( ?==)/gi, "$1References$3"); txt.value = txt.value.replace(/(== ?)(sources?:?)( ?==)/gi, "$1Sources$3"); txt.value = txt.value.replace(/(== ?)(further readings?:?)( ?==)/gi, "$1Further reading$3"); //Link simplifier, from WP:FORMATTER var m = txt.value.match(/\[\[([^[]*?)\|([^[]*?)\]\]/g); if (m) {     for (var i = 0; i < m.length; i++) {       var n_arr = m[i].toString.match(/\[\[([^[]*?)\|([^[]*?)\]\]/); var n = n_arr[0]; var a = n_arr[1]; var b = n_arr[2]; if (b.indexOf(a) == 0 || b.indexOf(TurnFirstToLower(a)) == 0) {         var k = n.replace(/\[\[([^\]\|]*?)\|(\1)([\w]*?)\]\]/i, "$2$3"); txt.value = txt.value.replace(n, k); }     }    }    txt.value = txt.value.replace(/\[\[([^\]\|]+)\|([^\]\|]+)\]\]([A-Za-z\'][A-Za-z]*)([\.\,\;\:\"\!\?\s\n])/g, "$2$3$4"); // ' // Help the syntax highlighter...    //Greek symbols (capitalization matters on all)    txt.value = txt.value.replace(new RegExp('\&Alpha\;', 'g'), 'Α');    txt.value = txt.value.replace(new RegExp('\&Beta\;', 'g'), 'Β');    txt.value = txt.value.replace(new RegExp('\&Gamma\;', 'g'), 'Γ');    txt.value = txt.value.replace(new RegExp('\&Delta\;', 'g'), 'Δ');    txt.value = txt.value.replace(new RegExp('\&Epsilon\;', 'g'), 'Ε');    txt.value = txt.value.replace(new RegExp('\&Zeta\;', 'g'), 'Ζ');    txt.value = txt.value.replace(new RegExp('\&Eta\;', 'g'), 'Η');    txt.value = txt.value.replace(new RegExp('\&Theta\;', 'g'), 'Θ');    txt.value = txt.value.replace(new RegExp('\&Ioeta\;', 'g'), 'Ι');    txt.value = txt.value.replace(new RegExp('\&Kappa\;', 'g'), 'Κ'); txt.value = txt.value.replace(new RegExp('\&Lambda\;', 'g'), 'Λ'); txt.value = txt.value.replace(new RegExp('\&Mu\;', 'g'), 'Μ'); txt.value = txt.value.replace(new RegExp('\&Nu\;', 'g'), 'Ν'); txt.value = txt.value.replace(new RegExp('\&Xi\;', 'g'), 'Ξ'); txt.value = txt.value.replace(new RegExp('\&Omicron\;', 'g'), 'Ο'); txt.value = txt.value.replace(new RegExp('\&Pi\;', 'g'), 'Π'); txt.value = txt.value.replace(new RegExp('\&Rho\;', 'g'), 'Ρ'); txt.value = txt.value.replace(new RegExp('\&Sigma\;', 'g'), 'Σ'); txt.value = txt.value.replace(new RegExp('\&Tau\;', 'g'), 'Τ'); txt.value = txt.value.replace(new RegExp('\&Upsilon\;', 'g'), 'Υ'); txt.value = txt.value.replace(new RegExp('\&Phi\;', 'g'), 'Φ'); txt.value = txt.value.replace(new RegExp('\&Chi\;', 'g'), 'Χ'); txt.value = txt.value.replace(new RegExp('\&Psi\;', 'g'), 'Ψ'); txt.value = txt.value.replace(new RegExp('\&Omega\;', 'g'), 'Ω'); txt.value = txt.value.replace(new RegExp('\&alpha\;', 'g'), 'α'); txt.value = txt.value.replace(new RegExp('\&beta\;', 'g'), 'β'); txt.value = txt.value.replace(new RegExp('\&gamma\;', 'g'), 'γ'); txt.value = txt.value.replace(new RegExp('\&delta\;', 'g'), 'δ'); txt.value = txt.value.replace(new RegExp('\&epsilon\;', 'g'), 'ε'); txt.value = txt.value.replace(new RegExp('\&zeta\;', 'g'), 'ζ'); txt.value = txt.value.replace(new RegExp('\&eta\;', 'g'), 'η'); txt.value = txt.value.replace(new RegExp('\&theta\;', 'g'), 'θ'); txt.value = txt.value.replace(new RegExp('\&ioeta\;', 'g'), 'ι'); txt.value = txt.value.replace(new RegExp('\&kappa\;', 'g'), 'κ'); txt.value = txt.value.replace(new RegExp('\&lambda\;', 'g'), 'λ'); txt.value = txt.value.replace(new RegExp('\&mu\;', 'g'), 'μ'); txt.value = txt.value.replace(new RegExp('\&nu\;', 'g'), 'ν'); txt.value = txt.value.replace(new RegExp('\&xi\;', 'g'), 'ξ'); txt.value = txt.value.replace(new RegExp('\&omicron\;', 'g'), 'ο'); txt.value = txt.value.replace(new RegExp('\&pi\;', 'g'), 'π'); txt.value = txt.value.replace(new RegExp('\&rho\;', 'g'), 'ρ'); txt.value = txt.value.replace(new RegExp('\&sigmaf\;', 'g'), 'ς'); txt.value = txt.value.replace(new RegExp('\&sigma\;', 'g'), 'σ'); txt.value = txt.value.replace(new RegExp('\&tau\;', 'g'), 'τ'); txt.value = txt.value.replace(new RegExp('\&upsilon\;', 'g'), 'υ'); txt.value = txt.value.replace(new RegExp('\&phi\;', 'g'), 'φ'); txt.value = txt.value.replace(new RegExp('\&chi\;', 'g'), 'χ'); txt.value = txt.value.replace(new RegExp('\&psi\;', 'g'), 'ψ'); txt.value = txt.value.replace(new RegExp('\&omega\;', 'g'), 'ω'); txt.value = txt.value.replace(new RegExp('\&thetasym\;', 'g'), 'ϑ'); txt.value = txt.value.replace(new RegExp('\&upsih\;', 'g'), 'ϒ'); txt.value = txt.value.replace(new RegExp('\&piv\;', 'g'), 'ϖ'); //Latin symbols (capitalization matters on all) txt.value = txt.value.replace(new RegExp('\&Agrave\;', 'g'), 'À'); txt.value = txt.value.replace(new RegExp('\&Aacute\;', 'g'), 'Á'); txt.value = txt.value.replace(new RegExp('\&Acirc\;', 'g'), 'Â'); txt.value = txt.value.replace(new RegExp('\&Atilde\;', 'g'), 'Ã'); txt.value = txt.value.replace(new RegExp('\&Auml\;', 'g'), 'Ä'); txt.value = txt.value.replace(new RegExp('\&Aring\;', 'g'), 'Å'); txt.value = txt.value.replace(new RegExp('\&AElig\;', 'g'), 'Æ'); txt.value = txt.value.replace(new RegExp('\&Ccedil\;', 'g'), 'Ç'); txt.value = txt.value.replace(new RegExp('\&Egrave\;', 'g'), 'È'); txt.value = txt.value.replace(new RegExp('\&Eacute\;', 'g'), 'É'); txt.value = txt.value.replace(new RegExp('\&Ecirc\;', 'g'), 'Ê'); txt.value = txt.value.replace(new RegExp('\&Euml\;', 'g'), 'Ë'); txt.value = txt.value.replace(new RegExp('\&Igrave\;', 'g'), 'Ì'); txt.value = txt.value.replace(new RegExp('\&Iacute\;', 'g'), 'Í'); txt.value = txt.value.replace(new RegExp('\&Icirc\;', 'g'), 'Î'); txt.value = txt.value.replace(new RegExp('\&Iuml\;', 'g'), 'Ï'); txt.value = txt.value.replace(new RegExp('\&Eth\;', 'g'), 'Ð'); txt.value = txt.value.replace(new RegExp('\&Ntilde\;', 'g'), 'Ñ'); txt.value = txt.value.replace(new RegExp('\&Ograve\;', 'g'), 'Ò'); txt.value = txt.value.replace(new RegExp('\&Oacute\;', 'g'), 'Ó'); txt.value = txt.value.replace(new RegExp('\&Ocirc\;', 'g'), 'Ô'); txt.value = txt.value.replace(new RegExp('\&Otilde\;', 'g'), 'Õ'); txt.value = txt.value.replace(new RegExp('\&Ouml\;', 'g'), 'Ö'); txt.value = txt.value.replace(new RegExp('\&Oslash\;', 'g'), 'Ø'); txt.value = txt.value.replace(new RegExp('\&Ugrave\;', 'g'), 'Ù'); txt.value = txt.value.replace(new RegExp('\&Uacute\;', 'g'), 'Ú'); txt.value = txt.value.replace(new RegExp('\&Ucirc\;', 'g'), 'Û'); txt.value = txt.value.replace(new RegExp('\&Uuml\;', 'g'), 'Ü'); txt.value = txt.value.replace(new RegExp('\&Yacute\;', 'g'), 'Ý'); txt.value = txt.value.replace(new RegExp('\&THORN\;', 'g'), 'Þ'); txt.value = txt.value.replace(new RegExp('\&szlig\;', 'g'), 'ß'); txt.value = txt.value.replace(new RegExp('\&agrave\;', 'g'), 'à'); txt.value = txt.value.replace(new RegExp('\&aacute\;', 'g'), 'á'); txt.value = txt.value.replace(new RegExp('\&acirc\;', 'g'), 'â'); txt.value = txt.value.replace(new RegExp('\&atilde\;', 'g'), 'ã'); txt.value = txt.value.replace(new RegExp('\&auml\;', 'g'), 'ä'); txt.value = txt.value.replace(new RegExp('\&aring\;', 'g'), 'å'); txt.value = txt.value.replace(new RegExp('\&aelig\;', 'g'), 'æ'); txt.value = txt.value.replace(new RegExp('\&ccedil\;', 'g'), 'ç'); txt.value = txt.value.replace(new RegExp('\&egrave\;', 'g'), 'è'); txt.value = txt.value.replace(new RegExp('\&eacute\;', 'g'), 'é'); txt.value = txt.value.replace(new RegExp('\&ecirc\;', 'g'), 'ê'); txt.value = txt.value.replace(new RegExp('\&euml\;', 'g'), 'ë'); txt.value = txt.value.replace(new RegExp('\&igrave\;', 'g'), 'ì'); txt.value = txt.value.replace(new RegExp('\&iacute\;', 'g'), 'í'); txt.value = txt.value.replace(new RegExp('\&icirc\;', 'g'), 'î'); txt.value = txt.value.replace(new RegExp('\&iuml\;', 'g'), 'ï'); txt.value = txt.value.replace(new RegExp('\&eth\;', 'g'), 'ð'); txt.value = txt.value.replace(new RegExp('\&ntilde\;', 'g'), 'ñ'); txt.value = txt.value.replace(new RegExp('\&ograve\;', 'g'), 'ò'); txt.value = txt.value.replace(new RegExp('\&oacute\;', 'g'), 'ó'); txt.value = txt.value.replace(new RegExp('\&ocirc\;', 'g'), 'ô'); txt.value = txt.value.replace(new RegExp('\&otilde\;', 'g'), 'õ'); txt.value = txt.value.replace(new RegExp('\&ouml\;', 'g'), 'ö'); txt.value = txt.value.replace(new RegExp('\&oslash\;', 'g'), 'ø'); txt.value = txt.value.replace(new RegExp('\&ugrave\;', 'g'), 'ù'); txt.value = txt.value.replace(new RegExp('\&uacute\;', 'g'), 'ú'); txt.value = txt.value.replace(new RegExp('\&ucirc\;', 'g'), 'û'); txt.value = txt.value.replace(new RegExp('\&uuml\;', 'g'), 'ü'); txt.value = txt.value.replace(new RegExp('\&yacute\;', 'g'), 'ý'); txt.value = txt.value.replace(new RegExp('\&thorn\;', 'g'), 'þ'); txt.value = txt.value.replace(new RegExp('\&yuml\;', 'g'), 'ÿ'); txt.value = txt.value.replace(new RegExp('\&OElig\;', 'g'), 'Œ'); txt.value = txt.value.replace(new RegExp('\&oelig\;', 'g'), 'œ'); txt.value = txt.value.replace(new RegExp('\&Scaron\;', 'g'), 'Š'); txt.value = txt.value.replace(new RegExp('\&scaron\;', 'g'), 'š'); txt.value = txt.value.replace(new RegExp('\&Yuml\;', 'g'), 'Ÿ'); txt.value = txt.value.replace(new RegExp('\&fnof\;', 'g'), 'ƒ'); //"Fake" Symbols txt.value = txt.value.replace(new RegExp('<==|<--', 'gi'), '←'); txt.value = txt.value.replace(new RegExp('==>', 'gi'), '→'); //XML and HTML Symbols txt.value = txt.value.replace(new RegExp('\&mdash\;', 'gi'), '—'); txt.value = txt.value.replace(new RegExp('\&ndash\;', 'gi'), '–'); txt.value = txt.value.replace(new RegExp('\&hellip\;', 'gi'), '...'); txt.value = txt.value.replace(new RegExp('\&dagger\;', 'g'), '†'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&Dagger\;', 'g'), '‡'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&plus\;', 'gi'), '+'); txt.value = txt.value.replace(new RegExp('\&plusmn\;', 'gi'), '±'); txt.value = txt.value.replace(new RegExp('\&minus\;', 'gi'), '−'); txt.value = txt.value.replace(new RegExp('\&times\;', 'gi'), '×'); txt.value = txt.value.replace(new RegExp('\&divide\;', 'gi'), '÷'); txt.value = txt.value.replace(new RegExp('\&ne\;', 'gi'), '≠'); txt.value = txt.value.replace(new RegExp('\&asymp\;', 'gi'), '≈'); //   txt.value = txt.value.replace(new RegExp('\&lt\;', 'gi'), '<'); NOTE: Along with &gt;, this has been commented out because it can break large amounts of code on some pages which discuss computer and web programming/scripting. txt.value = txt.value.replace(new RegExp('\&le\;', 'gi'), '≤'); //   txt.value = txt.value.replace(new RegExp('\&gt\;', 'gi'), '>'); NOTE: Along with &lt;, this has been commented out because it can break large amounts of code on some pages which discuss computer and web programming/scripting. txt.value = txt.value.replace(new RegExp('\&ge\;', 'gi'), '≥'); txt.value = txt.value.replace(new RegExp('\&quot\;', 'gi'), '"'); //   txt.value = txt.value.replace(new RegExp('\&amp\;', 'gi'), '&'); WAY too many false positives in external links and display of raw code using "hacks" like &amp;beta; to produce &beta; without making it appear as the unicode character.    txt.value = txt.value.replace(new RegExp('\&apos\;', 'gi'), '\'');    txt.value = txt.value.replace(new RegExp('\&iexcl\;', 'gi'), '¡');    txt.value = txt.value.replace(new RegExp('\&cent\;', 'gi'), '¢');    txt.value = txt.value.replace(new RegExp('\&pound\;', 'gi'), '£');    txt.value = txt.value.replace(new RegExp('\&curren\;', 'gi'), '¤');    txt.value = txt.value.replace(new RegExp('\&yen\;', 'gi'), '¥');    txt.value = txt.value.replace(new RegExp('\&brvbar\;', 'gi'), '¦');    txt.value = txt.value.replace(new RegExp('\&sect\;', 'gi'), '§');    txt.value = txt.value.replace(new RegExp('\&uml\;', 'gi'), '¨'); txt.value = txt.value.replace(new RegExp('\&copy\;', 'gi'), '©'); txt.value = txt.value.replace(new RegExp('\&ordf\;', 'gi'), 'ª'); txt.value = txt.value.replace(new RegExp('\&laquo\;', 'gi'), '«'); txt.value = txt.value.replace(new RegExp('\&not\;', 'gi'), '¬'); txt.value = txt.value.replace(new RegExp('\&reg\;', 'gi'), '®'); txt.value = txt.value.replace(new RegExp('\&macr\;', 'gi'), '¯'); txt.value = txt.value.replace(new RegExp('\&deg\;', 'gi'), '°'); txt.value = txt.value.replace(new RegExp('\&sup2\;', 'gi'), '²'); txt.value = txt.value.replace(new RegExp('\&sup3\;', 'gi'), '³'); txt.value = txt.value.replace(new RegExp('\&acute\;', 'gi'), '´'); txt.value = txt.value.replace(new RegExp('\&micro\;', 'gi'), 'µ'); txt.value = txt.value.replace(new RegExp('\&para\;', 'gi'), '¶'); txt.value = txt.value.replace(new RegExp('\&middot\;', 'gi'), '•'); txt.value = txt.value.replace(new RegExp('\&cedil\;', 'gi'), '¸'); txt.value = txt.value.replace(new RegExp('\&sup1\;', 'gi'), '¹'); txt.value = txt.value.replace(new RegExp('\&ordm\;', 'gi'), 'º'); txt.value = txt.value.replace(new RegExp('\&raquo\;', 'gi'), '»'); txt.value = txt.value.replace(new RegExp('\&frac14\;', 'gi'), '¼'); txt.value = txt.value.replace(new RegExp('\&frac12\;', 'gi'), '½'); txt.value = txt.value.replace(new RegExp('\&frac34\;', 'gi'), '¾'); txt.value = txt.value.replace(new RegExp('\&iquest\;', 'gi'), '¿'); txt.value = txt.value.replace(new RegExp('\&circ\;', 'gi'), 'ˆ'); txt.value = txt.value.replace(new RegExp('\&tilde\;', 'gi'), '˜'); txt.value = txt.value.replace(new RegExp('\&lsquo\;', 'gi'), '‘'); txt.value = txt.value.replace(new RegExp('\&rsquo\;', 'gi'), '’'); txt.value = txt.value.replace(new RegExp('\&sbquo\;', 'gi'), '‚'); txt.value = txt.value.replace(new RegExp('\&ldquo\;', 'gi'), '“'); txt.value = txt.value.replace(new RegExp('\&rdquo\;', 'gi'), '”'); txt.value = txt.value.replace(new RegExp('\&bdquo\;', 'gi'), '„'); txt.value = txt.value.replace(new RegExp('\&bull\;', 'gi'), '•'); txt.value = txt.value.replace(new RegExp('\&permil\;', 'gi'), '‰'); txt.value = txt.value.replace(new RegExp('\&prime\;', 'g'), '′'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&Prime\;', 'g'), '″'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&lsaquo\;', 'gi'), '‹'); txt.value = txt.value.replace(new RegExp('\&rsaquo\;', 'gi'), '›'); txt.value = txt.value.replace(new RegExp('\&oline\;', 'gi'), '‾'); txt.value = txt.value.replace(new RegExp('\&frasl\;', 'gi'), '⁄'); txt.value = txt.value.replace(new RegExp('\&euro\;', 'gi'), '€'); txt.value = txt.value.replace(new RegExp('\&image\;', 'gi'), 'ℑ'); txt.value = txt.value.replace(new RegExp('\&weierp\;', 'gi'), '℘'); txt.value = txt.value.replace(new RegExp('\&real\;', 'gi'), 'ℜ'); txt.value = txt.value.replace(new RegExp('\&trade\;', 'gi'), '™'); txt.value = txt.value.replace(new RegExp('\&alefsym\;', 'gi'), 'ℵ'); txt.value = txt.value.replace(new RegExp('\&larr\;', 'g'), '←'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&rarr\;', 'g'), '→'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&uarr\;', 'g'), '↑'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&darr\;', 'g'), '↓'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&lArr\;', 'g'), '⇐'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&rArr\;', 'g'), '⇒'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&uArr\;', 'g'), '⇑'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&dArr\;', 'g'), '⇓'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&harr\;', 'g'), '↔'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&hArr\;', 'g'), '⇔'); //Capitalization matters txt.value = txt.value.replace(new RegExp('\&crarr\;', 'gi'), '↵'); txt.value = txt.value.replace(new RegExp('\&forall\;', 'gi'), '∀'); txt.value = txt.value.replace(new RegExp('\&part\;', 'gi'), '∂'); txt.value = txt.value.replace(new RegExp('\&exist\;', 'gi'), '∃'); txt.value = txt.value.replace(new RegExp('\&empty\;', 'gi'), '∅'); txt.value = txt.value.replace(new RegExp('\&nabla\;', 'gi'), '∇'); txt.value = txt.value.replace(new RegExp('\&isin\;', 'gi'), '∈'); txt.value = txt.value.replace(new RegExp('\&notin\;', 'gi'), '∉'); txt.value = txt.value.replace(new RegExp('\&ni\;', 'gi'), '∋'); txt.value = txt.value.replace(new RegExp('\&prod\;', 'gi'), '∏'); txt.value = txt.value.replace(new RegExp('\&sum\;', 'gi'), '∑'); txt.value = txt.value.replace(new RegExp('\&lowast\;', 'gi'), '∗'); txt.value = txt.value.replace(new RegExp('\&radic\;', 'gi'), '√'); txt.value = txt.value.replace(new RegExp('\&prop\;', 'gi'), '∝'); txt.value = txt.value.replace(new RegExp('\&infin\;', 'gi'), '∞'); txt.value = txt.value.replace(new RegExp('\&ang\;', 'gi'), '∠'); txt.value = txt.value.replace(new RegExp('\&and\;', 'gi'), '∧'); txt.value = txt.value.replace(new RegExp('\&or\;', 'gi'), '∨'); txt.value = txt.value.replace(new RegExp('\&cap\;', 'gi'), '∩'); txt.value = txt.value.replace(new RegExp('\&cup\;', 'gi'), '∪'); txt.value = txt.value.replace(new RegExp('\&int\;', 'gi'), '∫'); txt.value = txt.value.replace(new RegExp('\&there4\;', 'gi'), '∴'); txt.value = txt.value.replace(new RegExp('\&sim\;', 'gi'), '∼'); txt.value = txt.value.replace(new RegExp('\&cong\;', 'gi'), '≅'); txt.value = txt.value.replace(new RegExp('\&sub\;', 'gi'), '⊂'); txt.value = txt.value.replace(new RegExp('\&sup\;', 'gi'), '⊃'); txt.value = txt.value.replace(new RegExp('\&nsub\;', 'gi'), '⊄'); txt.value = txt.value.replace(new RegExp('\&sube\;', 'gi'), '⊆'); txt.value = txt.value.replace(new RegExp('\&supe\;', 'gi'), '⊇'); txt.value = txt.value.replace(new RegExp('\&oplus\;', 'gi'), '⊕'); txt.value = txt.value.replace(new RegExp('\&otimes\;', 'gi'), '⊗'); txt.value = txt.value.replace(new RegExp('\&perp\;', 'gi'), '⊥'); txt.value = txt.value.replace(new RegExp('\&sdot\;', 'gi'), '⋅'); txt.value = txt.value.replace(new RegExp('\&lceil\;', 'gi'), '⌈'); txt.value = txt.value.replace(new RegExp('\&rceil\;', 'gi'), '⌉'); txt.value = txt.value.replace(new RegExp('\&lfloor\;', 'gi'), '⌊'); txt.value = txt.value.replace(new RegExp('\&rfloor\;', 'gi'), '⌋'); txt.value = txt.value.replace(new RegExp('\&lang\;', 'gi'), '〈'); txt.value = txt.value.replace(new RegExp('\&rang\;', 'gi'), '〉'); txt.value = txt.value.replace(new RegExp('\&loz\;', 'gi'), '◊'); txt.value = txt.value.replace(new RegExp('\&spades\;', 'gi'), '♠'); txt.value = txt.value.replace(new RegExp('\&clubs\;', 'gi'), '♣'); txt.value = txt.value.replace(new RegExp('\&hearts\;', 'gi'), '♥'); txt.value = txt.value.replace(new RegExp('\&diams\;', 'gi'), '♦'); } function codefixerplus { //ADVANCED FUNCTION describes list of fixes when using CodeFixerPlus var txt = document.editform.wpTextbox1; //replace //HTML tables, from PlastikSpork's script txt.value=txt.value.replace(/([\r\n])<[\\\/\. ]*BR[^<>]*>/gim, '$1*'); txt.value=txt.value.replace(/(<table|<\/tr|<\/td|<\/th)([^<>]*>)[ ]*([^\r\n])/gim, '$1$2\n$3'); txt.value=txt.value.replace(/<table([^<>]*)>([\r\n])/gim, '{|$1$2'); txt.value=txt.value.replace(/[ \r\n]*<\/table>/gi, '\n|}'); txt.value=txt.value.replace(/<\/td>[\r\n ]* /gim, '||'); txt.value=txt.value.replace(/<\/th>[\r\n ]* /gim, '!!'); txt.value=txt.value.replace(/<\/td>[\r\n ]*<td ([^<>]*)>/gim, '|| $1 |'); txt.value=txt.value.replace(/<\/th>[\r\n ]*<th ([^<>]*)>/gim, '!! $1 |'); txt.value=txt.value.replace(/ [ \r\n]*/gim, '|-\n'); txt.value=txt.value.replace(/<tr ([^<>]*)>[ \r\n]*/gim, '|- $1'); txt.value=txt.value.replace(/[ \r\n]* /gim, '\n|'); txt.value=txt.value.replace(/[ \r\n]*<td ([^<>]*)>/gim, '\n| $1 |'); txt.value=txt.value.replace(/[ \r\n]* /gim, '\n!'); txt.value=txt.value.replace(/[ \r\n]*<th ([^<>]*)>/gim, '\n! $1 |'); txt.value=txt.value.replace(/<\/(td|th)>[\r\n ]*<\/tr>[ ]*([\r\n])/gim, '$2'); }

//turns first character to lowercase, from WP:FORMATTER function TurnFirstToLower(input) { if (input != "") {   var temp = input.substr(0, 1); return temp.toLowerCase + input.substr(1, input.length); } else return ""; } function codefixerstartinedit { //Initiates CodeFixer if you are already in edit mode codefixer; // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Code cleaned up using CodeFixer"; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; }		txt.value += summary; }   document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpDiff.click } function codefixerplusstartinedit { //Initiates CodeFixer if you are already in edit mode codefixer; codefixerplus; // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Code cleaned up using CodeFixer (+)"; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; }		txt.value += summary; }   document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpDiff.click } if(queryString('codefixerstartfromview')) addOnloadHook(function { codefixerstartfromview; }) //Part of next function function codefixerstartfromview { //Initiates CodeFixer if you are viewing the article without currently editing it var txt = document.getElementById('wpTextbox1'); if(!txt) return; codefixer; document.getElementById('wpSummary').value += 'Code cleaned up using CodeFixer'; document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpDiff.click } if(queryString('codefixerplusstartfromview')) addOnloadHook(function { codefixerplusstartfromview; }) //Part of next function function codefixerplusstartfromview { //Initiates CodeFixerPlus if you are viewing the article without currently editing it var txt = document.getElementById('wpTextbox1'); if(!txt) return; codefixer; codefixerplus; document.getElementById('wpSummary').value += 'Code cleaned up using CodeFixer (+)'; document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpDiff.click } function queryString(p) { //Allows URI to be properly decoded so that codefixerstartfromview works properly var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; } $(function { //Adds "fix code" and "fix code (+)" tabs to page.    if(mw.config.get('wgCanonicalNamespace') == "" || mw.config.get('wgCanonicalNamespace') == "Image" || mw.config.get('wgCanonicalNamespace') == "File" || mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "Template" || mw.config.get('wgCanonicalNamespace') == "Project" || mw.config.get('wgCanonicalNamespace') == "Portal"){        if(document.forms.editform) {            mw.util.addPortletLink('p-cactions', 'javascript:codefixerstartinedit', 'fix code', 'ca-codefixeredit', 'Cleans up common errors in code and syntax', , document.getElementById('ca-move'));            mw.util.addPortletLink('p-cactions', 'javascript:codefixerplusstartinedit', 'fix code (+)', 'ca-codefixerplusedit', 'Cleans up more advanced errors in code and syntax', , document.getElementById('ca-move')); } //End editform if       if(mw.config.get('wgAction') == "view"){ var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit'; mw.util.addPortletLink('p-cactions',url + '&codefixerstartfromview=true', 'fix code','ca-codefixerview', 'Cleans up common errors in code and syntax', '', document.getElementById('ca-move')); mw.util.addPortletLink('p-cactions',url + '&codefixerplusstartfromview=true', 'fix code (+)','ca-codefixerplusview', 'Cleans up more advanced errors in code and syntax', '', document.getElementById('ca-move')); } //End pageview if   }//End namespace if }); //