User:AndyZ/peerreviewer.js

//User talk:AndyZ/peerreviewer.js

// ******************************************* //

// See User:AndyZ/peerreviewer for details //

// Quick installation - //

// Add to your monobook.js: //

// {{subst:js|User:AndyZ/peerreviewer.js}} //

// ******************************************* //

// Written by AndyZ, 2006 //

// ******************************************* //

//Semi-automatic javascript peer reviewer

// note that this is NOT a WP:BOT

// though it may be considered a semi-bot

// *-*-*-*-*-* start code *-*-*-*-*-*

// *-*-*-*-*-*-*-*-*-*- //

// configurable options //

// details on talk page //

// *-*-*-*-*-*-*-*-*-*- //

// input_PR is the source id for the input

// output_PR is the output id for the output

var input_PR, output_PR;

if(!input_PR) input_PR = "wpTextbox1";

if(!output_PR) output_PR = "theResponse";

//configurable options, see talk page for details

var allSpaces_PR, defaultView_PR, select_PR, popup_PR, sendTo_PR, toolbarLink_PR, toolbar_PR, directRef_PR, cat_PR, alpha_PR, userSandbox_PR, initMsg_PR, endMsg_PR, noXHR_PR, maintain_PR, maintain2_PR, spellcheck_PR, showHeading_PR, showInstaview_PR, instaview_PR, width_PR, imgCheck_PR, context_PR, simple_PR, expandContractions_PR;

if(!allSpaces_PR) allSpaces_PR = false; // if true, "peer review" link will appear on all article pages

if(!defaultView_PR) defaultView_PR = 0; // options: 0 - normal, in prose; 1 - template form; 2 - with references; (for now)

if(!select_PR) select_PR = false; // selects text

if(!popup_PR) popup_PR = false; // feature not available yet

if(!sendTo_PR) sendTo_PR = false; // if true, removes send to tab

if(!toolbarLink_PR) toolbarLink_PR = false; // accepted values = "personal", "cactions", "navigation", "tb"

if(!toolbar_PR) toolbar_PR = "personal";

if(!directRef_PR) directRef_PR = false;

if(!cat_PR) cat_PR = false;

if(!alpha_PR) alpha_PR = false;

if(!userSandbox_PR) userSandbox_PR = "User:" + mw.config.get('wgUserName') + "/sandbox";

if(!initMsg_PR) initMsg_PR = "{{#ifeq:{{{name}}}|" + mw.config.get('wgTitle') + "|~~~~}}" + "The following suggestions were generated by a semi-automatic javascript program, and might not be applicable for the article in question.";

if(!endMsg_PR) endMsg_PR = "\nYou may wish to browse through User:AndyZ/Suggestions for further ideas. Thanks, ~~"+"~~\n\n\n";

if(!noXHR_PR) noXHR_PR = false; // allow ajax (XMLHTTPrequest) or not

if(!maintain_PR) maintain_PR = false; //for maintainers of WP:PR/A and its subpages

if(!maintain2_PR) maintain2_PR = false; //for maintainers of WP:PR/A and its subpages

if(maintain2_PR) select_PR = true;

if(maintain2_PR) showHeading_PR = true;

if(!spellcheck_PR) spellcheck_PR = false; //spell checker, takes long time though

if(!showHeading_PR) showHeading_PR = false;

if(!showInstaview_PR) showInstaview_PR = false;

if(instaview_PR === undefined) instaview_PR = true; //instaview button!! released under BSD license by Pilaf

if(imgCheck_PR === undefined) imgCheck_PR = false;

if(context_PR === undefined) context_PR = false;

if(!width_PR) width_PR = 1200;

var width4_PR = width_PR + 4;

width_PR = width_PR.toString(); width4_PR = width4_PR.toString();

if(!simple_PR) simple_PR = false;

if(expandContractions_PR===undefined) expandContractions_PR = true;

//colors, style

var restoreText_PR, restoreStyle_PR, topBarColor_PR, botBarColor_PR;

if(!restoreText_PR) restoreText_PR = "[restore]"; // text for restoration button

if(!restoreStyle_PR) restoreStyle_PR = "background:yellow; position:absolute; margin-left:5px; margin-top:120px;";

if(!topBarColor_PR) topBarColor_PR = "red"; // color of top bar of suggestions

if(!botBarColor_PR) botBarColor_PR = "#cccccc"; // color of bottom bar of suggestions

// *-*-*-*-*-* end configurable options *-*-*-*-*-*

if(mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 4 || allSpaces_PR){ //only if namespace is main (or wp)

//the actual output location of the suggestions

//!!! needs cleanup for readability

//feedbackid = "theFeedback";

//drag_PR = 'onmousedown="StartDrag(document.getElementById('+feedbackid+'))" onmouseup="CancelDrag()" onmouseout="CancelDrag()"'

var instaview_button_txt;

if(instaview_PR)

instaview_button_txt = ''

else

instaview_button_txt = "";

$( peerreviewer_init );

}

function peerreviewer_init() {

//add new button for move to soon

var parent = document.getElementsByTagName( "BODY")[0];

var div = document.createElement( "DIV" );

div.innerHTML = '

'

+'

';

while (parent && div.hasChildNodes()) {

var child = div.childNodes[0];

parent.appendChild(child);

}

}

if(simple_PR) JSpeerreview_callingFunction = JSpeerreview_simple;

else JSpeerreview_callingFunction = JSpeerreview;

if(toolbar_PR == "personal" || toolbar_PR == "navigation" || toolbar_PR == "cactions" || toolbar_PR == "tb"){

if((mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 4 || allSpaces_PR) && !toolbarLink_PR){

//adds peer review link to top bar (with your user + talk pgs, prefs., watchlist, etc.)

$.when( mw.loader.using( ['mediawiki.util'] ), $.ready ).done( function () {

if(document.forms.editform) {

var link = mw.util.addPortletLink('p-'+toolbar_PR, , 'Peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', , '');

$(link).click( function(event) {

event.preventDefault();

JSpeerreview_callingFunction();

} );

}

});

}

if((mw.config.get('wgNamespaceNumber') === 0 || allSpaces_PR) && toolbarLink_PR){

$.when( mw.loader.using( ['mediawiki.util'] ), $.ready ).done( function () {

var link = mw.util.addPortletLink('p-'+toolbar_PR, , 'Peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', , '');

$(link).click( function(event) {

event.preventDefault();

toJSpeerreview()

} );

});

}

}

templateData_PR = new Array(

["lead","*Please expand the lead to conform with guidelines at Wikipedia:Manual of Style/Lead section. The article should have an appropriate number of paragraphs as is shown on WP:LEAD, and should adequately summarize the article."],

["leadlong","*The lead of this article may be too long, or may contain too many paragraphs. Please follow guidelines at WP:LEAD; be aware that the lead should adequately summarize the article."],

["leaddetail","*The lead is for summarizing the rest of the article, and should not introduce new topics not discussed in the rest of the article, as per WP:LEAD. Please ensure that the lead adequately summarizes the article."],

["infobox","*You may wish to consider adding an appropriate infobox for this article, if one exists relating to the topic of the article. "],

["contxt","*Per Wikipedia:Context and Wikipedia:Manual of Style/Dates and numbers, months and days of the week generally should not be linked. Years, decades, and centuries can be linked if they provide context for the article."],

["linkdate","*Years (2008) and months (January) by themselves are typically not linked. Per Wikipedia:Manual of Style/Linking#Linking month-and-day or year, years and dates are generally not linked."],

["dateth","*As per Wikipedia:Manual of Style/Dates and numbers, dates shouldn't use th; for example, instead of (if such appeared in the article) using January 30th was a great day, use January 30 was a great day."],

["nbsp","*Per Wikipedia:Manual of Style/Dates and numbers#Unit names and symbols, there should be a non-breaking space -   between a number and the unit symbol. For example, instead of {{{1|18mm}}}, use {{{2|18 mm}}}, which when you are editing the page, should look like: {{{3|18 mm}}}."],

["spellnum","*Per Wikipedia:Manual of Style/Dates and numbers#Units of measurement, please spell out source units of measurements in text; for example, the Moon is 380,000 kilometres (240,000 mi) from Earth."],

["abbrev","*Per Wikipedia:Manual of Style/Dates and numbers#Units of measurement, when doing conversions, please use standard abbreviations: for example, miles -> mi, kilometers squared -> km2, and pounds -> lb."],

["headingthe","*Per Wikipedia:Manual of Style#Section headings, headings generally do not start with articles ('the', 'a(n)'). For example, if there was a section called ==The Biography==, it should be changed to ==Biography==."],

["headingre","*Per Wikipedia:Manual of Style#Section headings, headings generally should not repeat the title of the article. For example, if the article was Ferdinand Magellan, instead of using the heading ==Magellan's journey==, use ==Journey==."],

["headinglink","*Per Wikipedia:Manual of Style#Section headings, please do not link words in headings."],

["headingcap","*Per Wikipedia:Manual of Style#Section headings, avoid capitalizing words in section headings unless they are proper nouns or the first word of the heading."],

["gtl","*Please reorder/rename the last few sections to follow guidelines at Wikipedia:Manual of Style/Layout."],

["overlink","*Consider removing links that add little to the article or that have been repeated in close proximity to other links to the same article, as per Wikipedia:Manual of Style/Linking#Duplicate and repeat links and WP:CONTEXT. Guides recommend having greater than 3% words in links, but be sure not to overlink words just to add more links."],

["underlink","*Consider adding more links to the article; per Wikipedia:Manual of Style/Linking and Wikipedia:Build the web, create links to relevant articles."],

["footspace","*As detailed at Help:Footnotes and Wikipedia:Manual of Style#Punctuation and footnotes, footnotes are usually located immediately after a punctuation mark, such that there is no space in between. For example, the sun is larger than the moon [2]. is usually written as the sun is larger than the moon.[2]"],

// ["alpha|categories","*Please alphabetize the categories."],

// ["alpha|categories and interlanguage links","*Please alphabetize the categories and interlanguage links."],

["ref","*The article will need references. See WP:CITE and WP:V for more information."],

["foot","*This article needs footnotes, preferably in a consistent format recommended by WP:WIAFA. Simply, enclose inline citations, with WP:CITE or WP:CITE/ES information, with THE FOOTNOTE. At the bottom of the article, in a section named “References” or “Footnotes”, add

."],

["noimg","*This article has no or few images. Please see if there are any free use images that fall under the Wikipedia:Image use policy and fit under one of the Wikipedia:Image copyright tags that can be uploaded. To upload images on Wikipedia, go to Special:Upload; to upload non-fair use images on the Wikimedia Commons, go to commons:special:upload."],

["leadimg","*If there is not a free use image in the top right corner of the article, please try to find and include one."],

["caption","*Per MOS:CAPTION, Images should have concise captions."],

["toc","*Per criterion 2b of Wikipedia:Featured article criteria and Wikipedia:Manual of Style/Layout#Headings and sections, this article's table of contents (ToC) may be too long – consider shrinking it down by merging short sections or using a proper system of daughter pages as per Wikipedia:Summary style."],

["expand","*This article is a bit too short, and therefore may not be as comprehensive as Wikipedia:Featured article criterion 1b is looking for. Please see if anything can be expanded upon."],

["SS","*This article may need to undergo summary style, where a series of appropriate subpages are used. For example, if the article is United States, then an appropriate subpage would be History of the United States, such that a summary of the subpage exists on the mother article, while the subpage goes into more detail."],

["copyedit","*Please ensure that the article has gone through a thorough copyediting so that it exemplifies some of Wikipedia's best work. See also User:Tony1/How to satisfy Criterion 1a."],

["list","*This article may be a bit list-weighty; in other words, some of the lists should be converted to prose (paragraph form)."],

["trivia","*Generally, trivia sections are looked down upon; please either remove the trivia section or incorporate any important facts into the rest of the article."],

["how","*Please avoid including instruction manuals, tutorials, etc. or other 'how-to's per WP:NOT."],

["ig","*Generally, avoid including galleries in articles. Common solutions to this problem include moving the gallery to [//commons.wikimedia.org/wiki/Main_Page wikicommons] or integrating images with the text."],

["fact","*Please provide citations for all of the {{fact}}s."]

);

for(i=0;i

templateData_PR[i][1] += "[?]"; //appending footnotes

// *-*-*-*-*-* non-configurable global variable declarations *-*-*-*-*-*

var temp_mem, foot_mem;

var imgFU = false, imgFUstr = "";

var imgNT = false, imgNTstr = "";

var PRtemplateData, tempPRdata; // !!!

var outputText_PR = initMsg_PR; //actual output text

var spellcheck_output = "";

function JSpeerreview(){

//wpTxt is the variable for the text of a document, input_PR is the id

if(document.getElementById(input_PR))

wpTxt = document.getElementById(input_PR).value;

else{

alert("Error: Could not locate text\n" + input_PR); return;

}

if(!document.getElementById(output_PR)){

alert("Error: Unable to access output location\n" + output_PR); return;

}

//current date variables

var current_date = new Date(), cur_month = current_date.getMonth(), cur_year = current_date.getFullYear();

var y_abbrev = cur_year.toString().substring(2,4);

var m_abbrev = new Array("J","F","M","A","MY","JN","JL","AU","S","O","N","D");

var m_full = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

// --------------------

// Messages on WP:PR

// --------------------

if(mw.config.get('wgTitle').indexOf("Peer review") != -1 && mw.config.get('wgTitle').indexOf("/Automated") == -1

&& mw.config.get('wgNamespaceNumber') === 4 //WP namespace

&& document.editform.wpTextbox1.value.indexOf("User:AndyZ/peerreviewer") == -1){

document.editform.wpTextbox1.value +=

"\n*A script has been used to generate a semi-automated"

+" review of the article for issues relating to grammar and house style. If you would find such a review helpful, please click [[Wikipedia:Peer review/Automated/"

+m_full[cur_month]+" "+cur_year+"#"+ mw.config.get('wgTitle').split("Peer review/")[1].split("/archive")[0] +"|here]]. Thanks, ~~~~";

// Add a tag to the summary box - stolen from User:Bobblewik

var txt = document.editform.wpSummary;

var summary = "Automated peer review at WP:PRA/"+m_abbrev[cur_month]+y_abbrev+"#"+mw.config.get('wgTitle').split("Peer review/")[1].split("/archive")[0]+"";

if (txt.value.indexOf(summary) == -1) {

if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {

txt.value += " | ";

}

txt.value += summary;

}

return;

} //

// |%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%| //

// |%|%|%|%|%| START OUTPUT |%|%|%|%|%| //

// |%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%|%| //

document.getElementById(output_PR).value = JSpeerreview_body(document.getElementById(input_PR).value,document.getElementById(output_PR).value);

//----------* replacing template format with actual words

temp_mem = document.getElementById(output_PR).value;

if(defaultView_PR == 0)

replaceTemp();

document.getElementById('instaview_button').style.width = 150;

document.theForm.switch_readonly.style.width = 150;

//----------*

//show feedback

document.getElementById("theFeedback").style.display = "block";

if(select_PR) //selects suggestions, for easy copy+pasting

document.getElementById(output_PR).select();

// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

}// ending brace for function %%

// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function JSpeerreview_simple(){

output_PR = "wpTextbox1";

document.getElementById('wpTextbox1').value = JSpeerreview_body(document.getElementById('wpTextbox1').value,"");

replaceTemp();

}

function JSpeerreview_body(inputText_PR,outputText_PR){

if(outputText_PR.indexOf("Thanks")!=-1){

var existingPR = confirm("There are already suggestions here.\nContinuing will cause the old suggestions to be overwritten.\nDo you wish to proceed?");

if(!existingPR) return;

else{

outputText_PR = initMsg_PR; //reset global variables

imgFU = false; imgFUstr = ""; imgNT = false; imgNTstr = "";

}

}

if(outputText_PR == "") outputText_PR = initMsg_PR;

if(showHeading_PR) //heading on output (at top)

outputText_PR = "==="+mw.config.get('wgTitle')+"===\n"+outputText_PR;

//----------* lead - determine number of paragraphs

inputText_PR_lead = inputText_PR.substring(0,inputText_PR.indexOf("=="))

if(/^([A-Z]|'{3})/gm.test(inputText_PR_lead))

NumPara = inputText_PR_lead.match(/^([A-Z]|'{3})/gm).length;

else NumPara=1;

if(NumPara == 1)

outputText_PR+="\n{{subst:User:AndyZ/PR/lead}}";

if(NumPara == 2 && inputText_PR.length>=30000)

outputText_PR+="\n{{subst:User:AndyZ/PR/lead}}";

if(NumPara == 3 && inputText_PR.length<=15000)

outputText_PR+="\n{{subst:User:AndyZ/PR/leadlong}}";

if(NumPara == 4 && inputText_PR.length<=30000)

outputText_PR+="\n{{subst:User:AndyZ/PR/leadlong}}";

if(NumPara >= 5){

outputText_PR+="\n{{subst:User:AndyZ/PR/leadlong}}";

outputText_PR+="\n{{subst:User:AndyZ/PR/leaddetail}}";

}

//----------* Links compared to # of words (see WP:MOS-L)

words = inputText_PR.split(" ").length; links = inputText_PR.split("[[").length;

if(.03 * words >= links) outputText_PR+="\n{{subst:User:AndyZ/PR/underlink}}";

if(.10 * words <= links) outputText_PR+="\n{{subst:User:AndyZ/PR/overlink}}";

//----------* WP:CONTEXT / WP:MOSDATE

//looks for linked years, days of weeks, or months

if(/[^,\]]\s\[\[\d{4}\]\]/.test(inputText_PR)

|| /\[\[((Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day|January|February|March|April|May|June|July|August|September|October|November|December)\]\]/.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/contxt}}"

//----------* WP:MOS#Time !!!

/*

var mostime = new Array(["recently", /recently/gi], ["soon", /\ssoon\s/g]); check_mostime = true; mostimestring = "";

for(i=0;i

if(mostime[i][1].test(inputText_PR)){

check_mostime = false; mostimestring += "|" + mostime[i][0]; //add parameters

}

}

if(!check_mostime) outputText_PR+="\n{{subst:User:AndyZ/PR/time"+mostimestring+"}}";

  • /

//----------* Images (in article/lead)

if(!/\[\[(image|file):/gi.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/noimg}}";

if(!/(image|file):/gi.test(inputText_PR.substring(0,1000))

&& !/\.(jpg|png|svg|gif|jpeg)\W/gi.test(inputText_PR.substring(0,1000))) outputText_PR+="\n{{subst:User:AndyZ/PR/leadimg}}";

//----------* Images without captions

if(/\|(\d{2,3}px|none|left|center|right|thumb|thumbnail|frame|\.(jpg|gif|png|svg))\]\]/i

.test(inputText_PR.replace(/\n\s*\|.+/gi,""))) outputText_PR+="\n{{subst:User:AndyZ/PR/caption}}";

//----------* Discourage galleries, per WP:IG

if(/<\/?gallery>/i.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/ig}}";

//----------* Discourage

syntax ->
Help:Table

if(/<\/table>/.test(inputText_PR)) outputText_PR+="\n*Please convert tables from HTML syntax to Help:Table wiki-markup.";

//----------* Image licensing: cannot check licensing of WikiMedia Commons images

var imgCode = /\[\[(image|file):(.+?)(\||\])/gi

var imgList = new Array();

if(imgCode.test(inputText_PR) && !noXHR_PR && imgCheck_PR){

imgList = inputText_PR.match(imgCode);

for(i=0;i

imgList[i] = imgList[i].replace(/\[\[(image|file):(.+?)(\||\])/gi,"Image:$1");

wpajax.download({url:'//en.wikipedia.org/w/index.php?title='+imgList[i]+'&action=raw',

onSuccess: checkImgLicense, onFailure: wikiImg, message: "raw," + imgList[i] });

}

}

//output for image licensing prolems

if(imgNT) outputText_PR+="\n{{subst:User:AndyZ/PR/imgtag"+imgNTstr+"}} ";

if(imgFU) outputText_PR+="\n{{subst:User:AndyZ/PR/imgfu"+imgFUstr+"}} ";

//----------* Searches for infobox

if(!/\{\{.*(taxo|geo|info)box/gi.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/infobox}} (Note that there might not be an applicable infobox; remember that these suggestions are not generated manually)";

// -------------------- --------------------

// WP:MOSNUM and WP:MOSDATE:

// -------------------- --------------------

//----------* checks for & nbsp;

list_unitnbsp = /((\d+)\s?((kilo|hecta|deca|deci|centi|milli|micro|nano)?(meter|metre|liter|litre|gram)s?|(k|d|c|m|n|µ)(g|l|m)|inch(es)?|f(oo|ee)?t\s|y(ar)?ds?|mi(les?)?\s|lbs?\s|pounds?|tons?|ounces?|ozs?\s|pints?|quarts?|gallons?|in2<\/sup>|squared inches|ft2<\/sup>|squared feet|m2<\/sup>|squared meter|km2<\/sup>|squared kilo|cm2<\/sup>|squared centi|mi2<\/sup>|squared mile|in3<\/sup>|cubic inch|ft3<\/sup>|cubic feet|m3<\/sup>|cubic meter|km3<\/sup>|cubic kilo|cm3<\/sup>|cubic centi|mi3<\/sup>|cubic mile))\W/gi;

if(list_unitnbsp.test(inputText_PR)){

temp_unitnbsp = inputText_PR.match(list_unitnbsp);

outputText_PR+="\n{{subst:User:AndyZ/PR/nbsp|"+RegExp.$1+"|"+RegExp.$2+" "+RegExp.$3+"|"+RegExp.$2+"&nbsp;"+RegExp.$3+"}}";

}

//----------* Checks for usage of standard abbreviations in parentheses (for conversions)

if(/((kilo|hecta|deca|deci|centi|milli|micro|nano)?(meter|metre|liter|litre|gram)s?|inch(es)?|f(oo|ee)t|yards?|miles?)\)/gi

.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/abbrev}}";

//----------* Checks that units are spelled out in text

var list_SN_PR = /([\d\.]+\s(kms?|mi|yds?|fts?|in\.|cms?|dms?|nms?|oz|lbs?|kgs?|mgs?|dag|dg|ng|(in|ft|yd|mi|m|km|cm|mm|dm|nm)[23]<\/sup>|ha|hl|dl|cl|ml)\s)/gi;

if(list_SN_PR.test(inputText_PR)){

temp_SN = inputText_PR.match(list_SN_PR);

outputText_PR+="\n{{subst:User:AndyZ/PR/spellnum}} " + "Specifically, an example is " + RegExp.$1.substring(0,RegExp.$1.length-1) + ".";

}

//----------* Checks for usage of standard abbreviations in parentheses (without 's') (for conversions) !!!

if(/(\s|nbsp;)((k|d|c|m|n|µ)(g|l|m)|ft|yd|mi|lb|oz)s(\W)/gi.test(inputText_PR))

outputText_PR+="\n*When writing standard abbreviations, the abbreviations should not have a 's' to demark plurality (for example, change kms to km and lbs to lb).";

//----------* Does not work; may fix soon - looks for conversions

//original logic: follow pattern: /(\d* )(\s| )?(UNIT)[^\}\s][^\(]//i

/* !!! ex

area2 = /\d(\s|)((in|ft|mi|(|k|c|m)m)2<\/sup>|squared (inches|feet|meter|(|kilo|centi|milli)(meter|metre)|mile))[^\}\s][^\(]/gi

vol2 = /\d(\s|)((in|ft|mi|(|m|c|k)m)3<\/sup>|cubic (inch|feet|meter|(|kilo|centi|milli)(metre|meter)))[^\}\s][^\(]/gi

if(area2.test(inputText_PR) || vol2.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/convert}}";*/

//----------* Unlinked dates

/*if(/\s(january|february|march|april|may|june|july|august|september|october|november|december)\s(\d\d?\D)/gi

.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/linkdate}}";*/

//----------* Dateth

var dateth = new Array(2); var check_th = false;

dateth[0] = /(\[\[)?(january|february|march|april|may|june|july|august|september|october|november|december)\s\d\d?(\]\])?()?(th|st|nd|rd)/gi

dateth[1] = /\d\d?()?(th|st|nd|rd)(<\/sup>)?\s(of\s)?(january|february|march|april|may|june|july|august|september|october|november|december)/gi

for(i=0;i

if(check_th) outputText_PR+="\n{{subst:User:AndyZ/PR/dateth}}";

// -------------------- --------------------

// checks for correct MOS heading styles (WP:MSH)

// -------------------- --------------------

//----------* Articles ("the", "a", "an") at beginning of heading

if(inputText_PR.indexOf("==The ") != -1 || inputText_PR.indexOf("== The ") != -1 || inputText_PR.indexOf("==the ") != -1 || inputText_PR.indexOf("== the ") != -1 ||

inputText_PR.indexOf("== A ") != -1 || inputText_PR.indexOf("==A ") != -1 || inputText_PR.indexOf("==a ") != -1 || inputText_PR.indexOf("==a ") != -1 ||

inputText_PR.indexOf("==An ") != -1 || inputText_PR.indexOf("== An ") != -1 || inputText_PR.indexOf("==an ") != -1 || inputText_PR.indexOf("== an ") != -1)

outputText_PR+="\n{{subst:User:AndyZ/PR/headingthe}}";

//----------* Link in headings

if(/==.{0,}\[\[.{1,}\]\].{0,}==/gi.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/headinglink}}";

//----------* Title repeated in headings

var regex_headre = new RegExp("==.{0,}" + mw.config.get('wgTitle').replace(/\s\(.*\)/,"") + ".{0,}==","gi")

if(regex_headre.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/headingre}}";

//----------* Special characters in headings

if(/==.*([^\[]\[^\\][^\]]|&|\+|\{|\}).*==/gi.test(inputText_PR))

outputText_PR+="\n*Per Wikipedia:Manual of Style (headings), avoid using special characters (ex: &+{}[]) in headings.";

//----------* Capitalization for common headings

if(/==\s?(See\sAlso|External\sLinks?|Works?\sCited|Further\sReadings?|History\sOf\s.{2,}|.{2,}\sAnd\s.{2,})\s?==/g

.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/headingcap}}";

//----------* How to, Trivia section

if(/==\s?(how[\s\-]to\s.*)\s?==/gi.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/how}}";

if(/==\s?(trivia|other\sfact|miscellaneous|interesting\s)/gi.test(inputText_PR)) outputText_PR+="\n{{subst:User:AndyZ/PR/trivia}}";

//----------* Order of last sections (WP:LAYOUT) (see also - references - external links)

var refsection_s = new Array("==Reference","==Source","==Footnote","==Cit","==Note","== Reference","== Source","== Footnote","== Cit","== Note"),

extlink_s = new Array("==External link","==External Link","== External Link","== External link"),

seealso_s = new Array("==See also","== See also","==See Also","== See Also"),

refsection = 0, extlink = 0, seealso = 0, check_gtl = true;

//find sections

for(i=0;i

for(i=0;i

for(i=0;i

if(seealso && refsection && (refsection < seealso)) check_gtl = false;

if(seealso && extlink && (extlink < seealso)) check_gtl = false;

if(refsection && extlink && (extlink < refsection)) check_gtl = false;

if(!check_gtl) outputText_PR+="\n{{subst:User:AndyZ/PR/gtl}}"

// categories

if(! /\[\[Category:.{1,}\]\]/gi.test(inputText_PR))

outputText_PR += "\n*This article does not have any categories. Please categorize it with relevant Category:Categories.";

/*

//----------* "List of..." //not in use due to inaccuracy

if(/==\s?list/gi.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/list}}";

//----------* Checks if categories are in alphabetical order !!!

self_alphabetic = [

'aa','af','ak','als','am','ang','ab','ar','an','roa-rup','frp','as','ast','gn',

'av','ay','az','bm','bn','zh-min-nan','map-bms','ba','be','bh','bi','bar','bo',

'bs','br','bg','bxr','ca','cv','ceb','cs','ch','cbk-zam','ny','sn','tum','cho',

'co','za','cy','da','pdc','de','dv','arc','nv','dz','mh','et','el','eml','en',

'es','eo','eu','ee','fa','fo','fr','fy','ff','fur','ga','gv','gd','gl','ki',

'glk','gu','got','zh-classical','xal','ko','ha','haw','hy','hi','ho','hsb','hr',

'io','ig','ilo','bpy','id','ia','ie','iu','ik','os','xh','zu','is','it','he',

'jv','kl','kn','kr','ka','ks','csb','kk','kw','rw','ky','rn','sw','kv','kg',

'ht','kj','ku','lad','lbe','lo','la','lv','lb','lt','lij','li','ln','jbo','lg',

'lmo','hu','mk','mg','ml','mt','mi','mr','mzn','ms','cdo','mo','mn','mus','my',

'nah','na','fj','nl','nds-nl','cr','ne','new','ja','nap','ce','pih','no','nn',

'nrm','nov','oc','or','om','ng','hz','ug','pa','pi','pam','pag','pap','ps','km',

'pms','nds','pl','pt','ty','ksh','ro','rmy','rm','qu','ru','war','se','sm','sa',

'sg','sc','sco','st','tn','sq','ru-sib','scn','si','simple','sd','ss','sk','cu',

'sl','so','sr','sh','su','fi','sv','tl','ta','roa-tara','tt','te','tet','th',

'vi','ti','tg','tpi','to','chr','chy','ve','tr','tk','tw','udm','bug','uk','ur',

'uz','vec','vo','fiu-vro','wa','vls','wo','wuu','ts','ii','yi','yo','zh-yue',

'diq','zea','bat-smg','zh','zh-tw','zh-cn']

cat1 = /\[\[Category:.{1,}\]\]/gi

alphed = true; check_il = true; //first for WP:CATs, WP:ILs

if(cat1.test(inputText_PR)){

theCats = inputText_PR.match(cat1) //array to hold categories

for(i=0;i

theCats[i]=theCats[i].toLowerCase(); //moves categories to lower case

//compares all cats to see if in alphabetical order

for(i=0;i

if(!(theCats[i+1]>theCats[i]))

alphed = false //if any categories out of order

} //set variable to false

}

list_il = /\[\[(aa|af|ak|als|am|ang|ab|ar|an|roa\-rup|frp|as|ast|gn|av|ay|az|bm|bn|zh\-min\-nan|map\-bms|ba|be|bh|bi|bar|bo|bs|br|bg|bxr|ca|cv|ceb|cs|ch|cbk\-zam|ny|sn|tum|cho|co|za|cy|da|pdc|de|dv|arc|nv|dz|mh|et|el|eml|en|es|eo|eu|ee|fa|fo|fr|fy|ff|fur|ga|gv|gd|gl|ki|glk|gu|got|zh\-classical|xal|ko|ha|haw|hy|hi|ho|hsb|hr|io|ig|ilo|bpy|id|ia|ie|iu|ik|os|xh|zu|is|it|he|jv|kl|kn|kr|ka|ks|csb|kk|kw|rw|ky|rn|sw|kv|kg|ht|kj|ku|lad|lbe|lo|la|lv|lb|lt|lij|li|ln|jbo|lg|lmo|hu|mk|mg|ml|mt|mi|mr|mzn|ms|cdo|mo|mn|mus|my|nah|na|fj|nl|nds\-nl|cr|ne|new|ja|nap|ce|pih|no|nn|nrm|nov|oc|or|om|ng|hz|ug|pa|pi|pam|pag|pap|ps|km|pms|nds|pl|pt|ty|ksh|ro|rmy|rm|qu|ru|war|se|sm|sa|sg|sc|sco|st|tn|sq|ru\-sib|scn|si|simple|sd|ss|sk|cu|sl|so|sr|sh|su|fi|sv|tl|ta|roa\-tara|tt|te|tet|th|vi|ti|tg|tpi|to|chr|chy|ve|tr|tk|tw|udm|bug|uk|ur|uz|vec|vo|fiu\-vro|wa|vls|wo|wuu|ts|ii|yi|yo|zh\-yue|diq|zea|bat\-smg|zh|zh\-tw|zh\-cn):/gi //interlanguage links

if(list_il.test(inputText_PR)){

theIL = inputText_PR.match(list_il) //array to hold ILs

for(i=0;i

if(theIL[i+1] <= theIL[i]) //compares all categories

check_il = false

}

}

if(!alphed && alphed2 && cat_PR)

outputText_PR+="\n{{subst:User:AndyZ/PR/alpha|categories}}"

if(!alphed2 && alphed && alpha_PR)

outputText_PR+="\n{{subst:User:AndyZ/PR/alpha}}"

if(!alphed && !alphed2 && !cat_PR && alpha_PR)

outputText_PR+="\n{{subst:User:AndyZ/PR/alpha}}"

if(!alphed && !alphed2 && cat_PR && !alpha_PR)

outputText_PR+="\n{{subst:User:AndyZ/PR/alpha|categories"+" and interlanguage links"+"}}"

if(!alphed && !alphed2 && cat_PR && alpha_PR)

outputText_PR+="\n{{subst:User:AndyZ/PR/alpha|categories and interlanguage links}}"

  • /

//----------* Summary style -ToC and entire article-

if(/\n==/g.test(inputText_PR)) theSections = inputText_PR.match(/\n==/g).length;

else theSections = 0;

if(theSections <= 5 || inputText_PR.length <= 7500)

outputText_PR+="\n{{subst:User:AndyZ/PR/expand}}";

if(theSections >= 24)

outputText_PR+="\n{{subst:User:AndyZ/PR/toc}}";

if(!/\{\{main/gi.test(inputText_PR)){ if(inputText_PR.length >= 50000)

outputText_PR+="\n{{subst:User:AndyZ/PR/SS}}";}

else if(inputText_PR.match(/\{\{main/gi).length <= 2 && inputText_PR.length >= 50000)

outputText_PR+="\n{{subst:User:AndyZ/PR/SS}}";

//----------* Section-stub template

if(/\{\{(sect(ion)?(\-|\s)?stub|stub(\-|\s)?section)\}\}/i.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/sectexpand}}";

//

var inputText_PR_noquotes = inputText_PR.replace(/"(.+?)"/gi,"").replace(/\[\[.{4,50}?\|/gi,"")

//----------* Weasel words

var ww = new Array("some people sa","it has been","many people have","many scientists believe","allege","many people sa","many people believe","arguably","it is claimed","correctly","apparently","people considered","many considered","is considered","are considered"); var ww2 = new Array();

isww = false; awtstring = ""; inputText_PRawt = inputText_PR_noquotes; wwref = 500;

for(i=0;i

for(i=0;i

while(ww2[i].test(inputText_PRawt)){

inputText_PRawt = inputText_PRawt.substring(inputText_PRawt.indexOf(ww[i])+1,inputText_PRawt.length);

if(!(/(

isww = true;

if(awtstring.indexOf(ww[i]) == -1) awtstring=awtstring+"|"+ww[i]+""

}

}

}

if(isww)

outputText_PR+="\n{{subst:User:AndyZ/PR/awt"+awtstring+"}} "

//----------* American/British English spellings (ize/ise, ization/isation, or/our, er/re, etc)

// ?!!!

var check_amer = 0, check_brit = 0, ab_ex = "";

AmSpell = new Array("flavor","honor","armor","behavior","harbor","neighbor","favorite","aluminum","mustache","tidbit","meter","fiber","saber","defense","offense","pretense","organize","recognize","realize","colonize","criticize","categorize","ization","analyze","catalyze","hydrolyze","paralyze","anemia","anesthesia","cesium","diarrhea","gynecology","hemophilia","leukemia","esophagus","estrogen","orthopedic","pediatric","counterattack","counselor","equaling","modeling","quarreled","signaling","traveled","enrollment","fulfillment","installment","skillful"," aging","routing","anymore","paycheck","cozy"," gray","jewelry","curb","licorice","mold","molt","pajamas","program ","skeptic","sulfur");

BrSpell = new Array("flavour","honour","armour","behaviour","harbour","neighbour","favourite","aluminium","moustache","titbit","metre","fibre","sabre","defence","offence","pretence","organise","recognise","realise","colonise","criticise","categorise","isation","analyse","catalyse","hydrolyse","paralyse","anaemia","anaesthesia","caesium","diarrhoea","gynaecology","haemophilia","leukaemia","oesophagus","oestrogen","orthopaedic","paediatric","counter-attack","counsellor","equalling","modelling","quarrelled","signalling","travelled","enrolment","fulfilment","instalment","skilful"," ageing","routeing"," any more","pay cheque","cosy"," grey","jewellery","kerb","liquorice","mould","moult","pyjamas","programme","sceptic","sulphur");

for(i=0;i

if(inputText_PR_noquotes.indexOf(AmSpell[i]) != -1 && mw.config.get('wgTitle').indexOf(AmSpell[i]) == -1){

check_amer++;

ab_ex += "" + AmSpell[i] + " (A) (British: " + BrSpell[i] + "), ";

}

if(inputText_PR_noquotes.indexOf(BrSpell[i]) != -1 && mw.config.get('wgTitle').indexOf(BrSpell[i]) == -1){

check_brit++;

ab_ex += "" + BrSpell[i] + " (B) (American: " + AmSpell[i] + "), ";

}

}

if(check_amer >= 2 && check_brit >= 2) outputText_PR+="\n*Please make the spelling of English words consistent with either American or British spelling, depending upon the subject of the article. Examples include: " + ab_ex.substring(0,ab_ex.length-2) + ".";

//----------* Spellcheck - load Wikipedia:Lists of common misspellings/For machines

if(!noXHR_PR && spellcheck_PR && mw.config.get('wgTitle').indexOf("Peer review") == -1){

wpajax.download({url:'//en.wikipedia.org/w/index.php?title=Wikipedia:Lists_of_common_misspellings/For_machines&action=raw',

onSuccess: spellCheckReview, OnFailure: spellCheckReview_fail, message: 'Wikipedia:Lists of common misspellings/For machines'});

outputText_PR += spellcheck_output;

}

//----------* Common redundancies - based on User:Tony1/How_to_satisfy_Criterion_1a#Redundancy

// !!! more if possible, also general cleanup

redun_PR = new Array(0,0,0,0,0)

redun_regex = /(\salso\s|in\saddition|additionally|moreover|furthermore)/gi

if(redun_regex.test(inputText_PR_noquotes)){

theaddnum = inputText_PR_noquotes.match(redun_regex)

if((theaddnum.length>=8)&&(theaddnum.length >= inputText_PR.length/1800)) redun_PR[0] = 1;

}

redun_regex = /(some\s|a\svariety\sof|a\snumber\sof|a\smajority\sof|several|a\sfew|\smany|\sany\s|\sall\s)/gi

if(redun_regex.test(inputText_PR_noquotes)){

thevsnum = inputText_PR_noquotes.match(redun_regex)

if((thevsnum.length>=8)&&(thevsnum.length >= inputText_PR.length/1800)) redun_PR[1] = 1;

}

redun_regex = /(over\sthe\syears|currently|\snow\s|from\stime\sto\stime)/gi

if(redun_regex.test(inputText_PR_noquotes)){

thetempnum = inputText_PR_noquotes.match(redun_regex)

if(thetempnum.length>=6 && thetempnum.length >= inputText_PR.length/2300) redun_PR[2] = 1;

}

redun_regex = /(in\sthe\syear|in\sthe\syear\sof)\s(\[\[|)(\d\d\d\d)/gi

if(redun_regex.test(inputText_PR_noquotes)){inputText_PR_noquotes.match(redun_regex); exyear = RegExp.$3; redun_PR[3] = 1;}

redun_regex = /(thereupon|thereupon|notwithstanding|in\sorder\s(to|for))/gi

if(redun_regex.test(inputText_PR_noquotes)){

if(inputText_PR_noquotes.match(redun_regex).length > 2) redun_PR[4] = 1;

}

if(redun_PR[0] || redun_PR[1] || redun_PR[2] || redun_PR[3]){

outputText_PR+="\n*Watch for redundancies that make the article too wordy instead of being crisp and concise. (You may wish to try Tony1's redundancy exercises.)";

if(redun_PR[0])

outputText_PR+="\n**While additive terms like “also”, “in addition”, “additionally”, “moreover”, and “furthermore” may sometimes be useful, overusing them when they aren't necessary can instead detract from the brilliancy of the article. This article has "+theaddnum.length+" additive terms, a bit too much.";

if(redun_PR[1])

outputText_PR+="\n**Vague terms of size often are unnecessary and redundant - “some”, “a variety/number/majority of”, “several”, “a few”, “many”, “any”, and “all”. For example, “All pigs are pink, so we thought of a number of ways to turn them green.”";

if(redun_PR[2])

outputText_PR+="\n**Temporal terms like “over the years”, “currently”, “now”, and “from time to time” often are too vague to be useful, but occasionally may be helpful. “I am now using a semi-bot to generate your peer review.”";

if(redun_PR[3])

outputText_PR+="\n**“In the year [of] "+exyear+"”";

if(redun_PR[4])

outputText_PR+="\n**Avoid misplaced formality: “in order to/for” (-> to/for), “thereupon”, “notwithstanding”, etc.";

}

//----------* Contractions

if(/((is|are|was|were|have|has|had|wo|would|do|does|did|ca|could|should|might|must)n't|(would|should|could|might|must)'ve)/gi

.test(inputText_PR_noquotes)){

list_contraction = inputText_PR_noquotes.match(/((is|are|was|were|have|has|had|wo|would|do|does|did|ca|could|should|might|must)n't|(would|should|could|might|must)'ve)/gi).join(", ");

outputText_PR+="\n*The script has spotted the following contractions: " + list_contraction + ", if these are outside of quotations, they should be expanded.";

}

//----------* Footnotes

var check_ref = 0;

if (/

else if (/\{\{(ref|fn|harv)/gi.test(inputText_PR)) check_ref=2;

if (!check_ref) // no footnotes

outputText_PR+="\n{{subst:User:AndyZ/PR/foot}}"

else if (check_ref==2) //a method outside of the cite.php

outputText_PR+="\n*You may wish to convert your form of references to the cite.php footnote system that WP:WIAFA 1(c) highly recommends."

//----------* Footnote spacing following a period

var list_sref = new Array(/(<\/ref>|\{\{(fn|ref)(\|.+)?\}\})\s?\./, /\.\s(|{\{(ref|fn))/, /<\/ref>(\s|\n)

for(i=0;i

if(list_sref[i].test(inputText_PR)){check_sref=true; break;}

}

if(check_sref) outputText_PR+="\n{{subst:User:AndyZ/PR/footspace}}"

//----------* Reference section

if(!/==\s?(reference|source|cit|works cit|footnote|note)/gi.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/ref}}"

//----------* [citation needed]

if(/\{\{(fact|citation\sneeded|cn)\}\}/gi.test(inputText_PR))

outputText_PR+="\n{{subst:User:AndyZ/PR/fact}}";

//----------* Copyediting reminder (default):

outputText_PR+="\n{{subst:User:AndyZ/PR/copyedit}}"

//----------* closing + signature

outputText_PR+=endMsg_PR;

return outputText_PR;

} // %%%%%%%%% END REVIEW %%%%%%%%%%

// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

// image licensing check functions:

// --------------------

// XMLHTTPrequest function by User:Zocky, on WP:US

wpajax={

download:function(bundle) {

// mandatory: bundle.url || optional: bundle.onSuccess (xmlhttprequest, bundle), bundle.onFailure (xmlhttprequest, bundle), bundle.otherStuff OK too, passed to onSuccess and onFailure

var x = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false;

if (x) {

x.onreadystatechange=function() {

x.readyState==4 && wpajax.downloadComplete(x,bundle);

};

x.open("GET",bundle.url,true);

x.send(null);

}

return x;

},

downloadComplete:function(x,bundle) {

x.status==200 && (bundle.onSuccess && bundle.onSuccess(x,bundle) || true)

|| ( bundle.onFailure && bundle.onFailure(x,bundle) || checkpage(x,bundle));

}

};

function wikiImg(xmlreq,data){} //empty function

function checkImgLicense(xmlreq, data) {

var imgTxt = xmlreq.responseText;

imgData = data.message.split(",");

if(imgData.length > 2){

for(i=2;i

}

if(imgData[0] == "raw"){

imgNTtemplates = /\{\{(nolicense|nosource|no\ssource|no\slicense|nld|nsd|untagged)/gi

if(imgTxt.indexOf("{{") == -1 || imgNTtemplates.test(imgTxt)){

imgNT = true; imgNTstr += "|" + imgData[1];

}

templFU = /\{\{.{0,}(Music sample|Speech|Sheet music|Albumcover|Boardgamecover|Book cover|Comiccover|DVDcover|Gamecover|Softwarecover|Magazinecover|Time|Newspapercover|Video tape cover|Logo|Computer hardware logo|Disneylogo|PreK12\-logo|Restaurant|Radiologo|Schoolboard\-logo|Scoutlogo|Sports\-logo|Hqfl logo|Olympics\-logo|Tv\-logo|Tv\-program\-logo|Univ\-logo|Symbol|Seal|Icon|Game\-icon|Wayfinding|Stamp|USPSstamp|Money|Promotional|DisneyAttractionPoster|Eventposter|Sportsposter|Movie poster|Political poster|Film\-screenshot|Machinima\-screenshot|Musicpromo\-screenshot|Tv\-screenshot|Video\-screenshot|Game\-screenshot|Cvg\-titlescreen|screen|photo|sign|cover|artwork|Digimonimage|DisneyCharacter|Pokeimage|Yugiohimage|Comicpanel|comicscene|Public Library images|Otto Perry image|Robert Richardson image|Parody|Smithsonian|Standard test|Fair use in|Fairusein\d|no\srationale|nrd|Replaceable\sfair\suse|refu|orfud|or\-fu\-re)/gi

FUrat = /(rationale|fair\suse)/gi

if(templFU.test(imgTxt) && !FUrat.test(imgTxt)){

imgFU = true; imgFUstr += "|" + imgData[1];

}

}

else if(imgData[0] == "htm"){

if(imgTxt.indexOf("Template:") == -1){

alert(imgData[1] + "\n" + "\nNo licensing information (HTML check)");

}

}

}

function checkpage(xmlreq, data){

if(xmlreq.statusText != "Not Found")

alert(xmlreq.statusText + "\n" + data.url);

}

// --------------------

// END img license checking

// --------------------

// START spellcheck, based on Wikipedia:Lists of common misspellings/For machines

// --------------------

function spellCheckReview(xmlreq, data){

spellcheck_output = "";

var spell_string = "";

list_wordpairs = xmlreq.responseText.substring(0,xmlreq.responseText.lastIndexOf("zebra")+5) // remove category

list_wordpairs = list_wordpairs.split("\n"); // find all pairs of mispellings + actual words

var misspelled_words = new Array(); var spellchecked_words = new Array();

for(i=0;i

list_wordpairs[i] = list_wordpairs[i].substring(1,list_wordpairs[i].length);

// remove spaces

try{

temp_spellarray = list_wordpairs[i].split("->");

misspelled_words[i] = temp_spellarray[0];

spellchecked_words[i] = temp_spellarray[1];

}

catch(e){

misspelled_words[i] = list_wordpairs[i].substring(0,list_wordpairs[i].indexOf("->"));

spellchecked_words[i] = list_wordpairs[i].substring(list_wordpairs[i].indexOf("->")+2,list_wordpairs[i].length);

}

if(document.getElementById(input_PR).value.indexOf(" " + misspelled_words[i] + " ") != -1){

spell_string += "" + misspelled_words[i] + " (" + spellchecked_words[i] + ")" + ",";

}

}

if(spell_string.length > 2) //if mispelled_list exists

spellcheck_output+="\n*Please check through the article for possible misspellings (see WP:SPELL). Examples of possible misspellings include: " + spell_string.substring(0,spell_string.length-1) + ".";

}

function spellCheckReview_fail(xmlreq,data){

alert("Error: Unable to start spellcheck");

}

// --------------------

// END spellcheck

// --------------------

// START output configuring (template <-> prose, readonly, instaview, etc.)

// --------------------

function replaceTemp(){// ----------* replace templates with actual contents (use ajax?)

for(i = 0; i < templateData_PR.length; i++){ //templates are listed above with global variables

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/"+templateData_PR[i][0]+"}}","g"),templateData_PR[i][1]);

}

if(/\{\{subst:User:AndyZ\/PR\/.*\}\}/i.test(document.getElementById(output_PR).value))

replaceTemplatesWithParams(); //continue by replacing templates w/ parameters

}

function replaceTemplatesWithParams(){

output_txt = document.getElementById(output_PR).value;

list_utemps = output_txt.match(/\{\{subst:User:AndyZ\/PR\/(.*)\}\}/gi);

var list_params = new Array();

for(i=0;i

list_utemps[i] = list_utemps[i].substring(22,list_utemps[i].length-2);

list_params = list_utemps[i].split("|");

if(list_params.length == 1) continue;

uTN_PR = list_params[0];

list_paramsStr = "";

for(j=1;j

if(j==list_params.length-1) list_paramsStr += list_params[j];

else list_paramsStr += list_params[j] + ",,";

}

//if statements

if(uTN_PR == "time")

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/\{\{subst:User:AndyZ\/PR\/time.*\}\}/gi,"*Per WP:MOS, avoid using words/phrases that indicate time periods relative to the current day. For example, " + list_paramsStr.replace(/\,\,/g,", ") + " might be terms that should be replaced with specific dates/times.[?]");

if(uTN_PR == "awt")

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/\{\{subst:User:AndyZ\/PR\/awt.*\}\}/gi,"*There are a few occurrences of weasel words in this article- please observe WP:WEASEL. Certain phrases should specify exactly who supports, considers, believes, etc., such a view.\n**" + list_paramsStr.replace(/\,\,/g,"\n**") + "\n**might be weasel words, and should be provided with proper citations (if they already do, or are not weasel terms, please strike this comment).[?]");

if(uTN_PR == "nbsp")

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/\{\{subst:User:AndyZ\/PR\/nbsp.*\}\}/gi,"*Per Wikipedia:Manual of Style/Dates and numbers#Units of measurement, there should be a non-breaking space - &nbsp; between a number and the unit of measurement. For example, instead of "+list_params[1]+", use "+list_params[2]+", which when you are editing the page, should look like: "+list_params[3]+".[?]");

/*if(uTN_PR == "imgfu")

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/\{\{subst:User:AndyZ\/PR\/imgfu.*\}\}/gi,"*Images with fair use tags need fair use rationales - please see WP:FUC. Specifically, :" + list_paramsStr.replace(/\,\,/gi,", :") + " need(s) proper fair use rationales.");

if(uTN_PR == "imgtag")

document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/\{\{subst:User:AndyZ\/PR\/imgtag.*\}\}/gi,"*Images need proper image copyright tags and source information. Specifically, :" + list_paramsStr.replace(/\,\,/gi,", :") + " need(s) proper image copyright tags.");

*/

}

}

function determineReadonly(){ //readonly, to prevent accidental editing of the text

if(document.getElementById(output_PR).readOnly) {

document.getElementById(output_PR).readOnly = false;

document.theForm.switch_readonly.value = "Readonly"; //button properties

document.theForm.switch_readonly.style.width = 150;

}

else {

document.getElementById(output_PR).readOnly = true;

document.theForm.switch_readonly.value = "Edit-able"; //button properties

document.theForm.switch_readonly.style.width = 150;

}

}

function popreview(){

PRresult = "