User:Squirepants101/monobook.js

// User:Lupin/popups.js

importScript('User:Lupin/popups.js'); //

function winc(s) { s = s.replace(/^\[\[/, ).replace(/\]\]$/, ); document.write(' '); }

winc('User:Voice_of_All/Addtabs/monobook.js'); // Helper tools winc('User:Cactus.man/Scripts/MoreTabs.js');        // Additional tabs for user & project pages winc('User:Voice_of_All/Revert/monobook.js'); // Diff page links winc('User:Voice_of_All/Deletion/monobook.js'); // AfD/PfD/Copyvio and tagging tabs winc('User:VoA/monobook.js'); // Admin-like RC Patrol tools

//

popupFixRedirs = true;

popupNavLinks = true; //User talk:AndyZ/peerreviewer.js /*

//Semi-automatic javascript peer reviewer // note that this is NOT a WP:BOT // (though it may be considered a semi-bot)

///////////////////////////////////////////// // See talk page for details              // //                                        // // Quick installation -                    // // Add to your monobook.js:               // // User:AndyZ/peerreviewer.js // //                                        // //     Written by AndyZ                    // /////////////////////////////////////////////

//	start code

////// addlink script, from User:Omegatron // 	Script from User:Omegatron/monobook.js/addlink.js document.write(' ');

/////////////////////////            //configurable options // /////////////////////////            //details on talk page // ///////////////////////// //most, if they dont exist, are set to false //should be declared in a different fashion, but this is the only method //I can think of as of now ////variables for: functionality

//input and output (ids): //input_PR is the source id for the input //output_PR is the output id for the output var input_PR; if(!input_PR) input_PR = "wpTextbox1"; var output_PR; if(!output_PR) output_PR = "theResponse"; //other configurable options, see talk page for details var allSpaces_PR;            // if true, "peer review" link will appear on all article pages if(!allSpaces_PR) allSpaces_PR = false; var defaultView_PR;			 // options: 0 - normal, in prose;  1 - template form;  2 - with references;  (for now) if(!defaultView_PR) defaultView_PR = 0; var select_PR;                           // selects text if(!select_PR) select_PR = false; var popup_PR;					// feature not available yet if(!popup_PR) popup_PR = false; var noSendTo_PR;				// if true, removes send to tab if(!noSendTo_PR) noSendTo_PR = false; var toolbarLink_PR; if(!toolbarLink_PR) toolbarLink_PR = false; var toolbar_PR;				// accepted values = "personal", "cactions", "navigation" -- possibly later "toolbar" if(!toolbar_PR) toolbar_PR = "personal"; var directRef_PR; if(!directRef_PR) directRef_PR = false; var cat_PR; if(!cat_PR) cat_PR = false; var userSandbox_PR; if(!userSandbox_PR) userSandbox_PR = "User:" + wgUserName + "/sandbox" var initMsg_PR; if(!initMsg_PR) initMsg_PR = "The following suggestions were generated by a semi-automatic javascript program, and might not be applicable for the article in question." var endMsg_PR; if(!endMsg_PR) endMsg_PR = "\nYou may wish to browse through User:AndyZ/Suggestions for further ideas. Thanks, "+"\n\n\n"; var noXHR_PR;				// allow ajax (XMLHTTPrequest) or not if(!noXHR_PR) noXHR_PR = false; var maintain_PR;				//for maintainers of WP:PR/A and its subpages if(!maintain_PR) maintain_PR = false; var spellcheck_PR;			//spell checker, takes long time though if(!spellcheck_PR) spellcheck_PR = false; var showHeading_PR; if(!showHeading_PR) showHeading_PR = false;

////colors, style var restoreText_PR;				// text for restoration button if(!restoreText_PR) restoreText_PR = "[restore]"; var restoreStyle_PR;			// style for restoration button (background:yellow, fixed position, 5 px from left and 120 px from top if(!restoreStyle_PR) restoreStyle_PR = "background:yellow; position:absolute; margin-left:5px; margin-top:120px;"; var toolbarLink_PR;			// simple link to PR, from article mode var topBarColor_PR;			 // color of top bar of suggestions if(!topBarColor_PR) topBarColor_PR = "red"; var botBarColor_PR;			  // color of bottom bar of suggestions if(!botBarColor_PR) botBarColor_PR = "#cccccc";				//end configurable options

if(wgNamespaceNumber == 0 || wgNamespaceNumber == 4 || allSpaces_PR){		//only if namespace is main (or wp) //the actual output location of the suggestions //feedbackid = "theFeedback"; //drag_PR = 'onmousedown="StartDrag(document.getElementById('+feedbackid+'))" onmouseup="CancelDrag" onmouseout="CancelDrag"' //add new button for move to soon document.write('new window | close '+initMsg_PR+' '+	'  Questions/comments/errors?  '	+' '	+''+restoreText_PR+' ') }

if(toolbar_PR == "personal" || toolbar_PR == "navigation" || toolbar_PR == "cactions"){ if((wgNamespaceNumber == 0 || wgNamespaceNumber == 4 || allSpaces_PR) && !toolbarLink_PR){ //adds peer review link to top bar (with your username, talk page, preferences, watchlist, etc.) $(function {    if(document.forms.editform) {        addLink('p-'+toolbar_PR, 'javascript:review1', 'peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', , );    } }); }

if((wgNamespaceNumber == 0 || allSpaces_PR) && toolbarLink_PR){ $(function {	addLink('p-'+toolbar_PR, 'javascript:toReview1', 'peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', , ); }); } }

///////////////////////////////// Toolbar code failing /* addOnloadHook fails to work... else if(toolbar_PR == "toolbar" && document.getElementById("toolbar")){ //image file: http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG addOnloadHook(function {		alert("creating button");		//document.getElementById('toolbar').innerHTML = document.getElementById('toolbar').innerHTML + "<img src='http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG' alt='JavaScript peer reviewer' title='JS peer review' style='CURSOR: pointer' border=0></a>"		AZbutton_PR = document.createElement("img");		AZbutton_PR.setAttribute("src","http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG");		AZbutton_PR.setAttribute("width","23");		AZbutton_PR.setAttribute("height","22");		AZbutton_PR.setAttribute("alt","uses JavaScript to suggest corrections to the article");		AZbutton_PR.setAttribute("style","CURSOR: pointer");		AZbutton_PR.setAttribute("border",0);		AZbutton_PR.setAttribute("onclick","review1");		document.getElementById("toolbar").appendChild(AZbutton_PR);  		alert("done");	}) } ///////////////////////////////// end commented code

//global variable declarations, not configurable var temp_mem, foot_mem; var imgFU = false; var imgFUstr = ""; var imgNT = false; var imgNTstr = ""; var PRtemplateData; var tempPRdata;

//////////	// Note: variables tend to be declared: // check_??? are usually T/F // list_??? generally array for comparing (indexOf) //////////

function review1{ //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; theLength = wpTxt.length; } 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; }

// // determine title name theTitle = wgTitle;

if(wgPageName.indexOf(":") != -1) theTitle2 = wgPageName.replace(/\_/gi," ").split(":")[1];

if(document.getElementById(output_PR).value.indexOf("===")!=-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 document.getElementById(output_PR).value = initMsg_PR; }

//heading on output (at top) if(showHeading_PR) document.getElementById(output_PR).value = "==="+theTitle+"===\n"+document.getElementById(output_PR).value;

// // lead stuff // // determine the number of paragraphs in the lead //

wpTxtlead = wpTxt.substring(0,wpTxt.indexOf("==")) newLine = /\n[A-Z]/g

if(newLine.test(wpTxtlead)){ NumPara = wpTxtlead.match(newLine); theNumPara = NumPara.length; theNumPara++;		//count the first paragraph } else theNumPara=1

if(theNumPara==1) document.getElementById(output_PR).value+="\n" if((theNumPara==2) && (theLength>=30000)) document.getElementById(output_PR).value+="\n" if((theNumPara==3) && (theLength<=15000)) document.getElementById(output_PR).value+="\n" if((theNumPara==4) && (theLength<=30000)) document.getElementById(output_PR).value+="\n" if(theNumPara>=5){ document.getElementById(output_PR).value+="\n" document.getElementById(output_PR).value+="\n" }

// //checks linking in comparison to # of words (see WP:LINK suggestions) // words = wpTxt.split(" "); links = wpTxt.split("[["); if(.03 * words.length >= links.length)	document.getElementById(output_PR).value+="\n"; else if(.1* words.length <= links.length)	document.getElementById(output_PR).value+="\n";

// //checks if document follows WP:CONTEXT / WP:MOSDATE guidelines // var check_contxt = false;	//if it is changed to true, one of the date guidelines has been violated

//looks for year regex_yr = /[^,\]]\s\[\[\d{4}\]\]/gi;

//array for days of the week var list_day = new Array(/\[\[Monday\]\]/gi,/\[\[Tuesday\]\]/gi,/\[\[Wednesday\]\]/gi, /\[\[Thursday\]\]/gi,/\[\[Friday\]\]/gi,/\[\[Saturday\]\]/gi,/\[\[Sunday\]\]/gi);

//array for months var list_month = new Array(/\[\[January\]\]/gi,/\[\[February\]\]/gi,/\[\[March\]\]/gi,/\[\[April\]\]/gi,/\[\[May\]\]/gi,/\[\[June\]\]/gi,/\[\[July\]\]/gi,/\[\[August\]\]/gi,/\[\[September\]\]/gi,/\[\[October\]\]/gi,/\[\[November\]\]/gi,/\[\[December\]\]/gi);

if (regex_yr.test(wpTxt)) check_contxt = true; for(i=0;i<list_day.length;i++){if(list_day[i].test(wpTxt)) check_contxt = true;} for(i=0;i<list_month.length;i++){if(list_month[i].test(wpTxt)) check_contxt = true;}

if(check_contxt) document.getElementById(output_PR).value+="\n"

// //about WP:MOS // // needs // cleanup //

var mostime = new Array; var mostime2 = new Array; 	//declare WP:MOSTIME arrays mostimestring = ""						//to hold page parameters goodmostime = true;						//if false, give message mostime[0] = /recently/gi mostime2[0] = "recently" mostime[1] = /last month.[^o]/gi mostime2[1] = "last month" mostime[2] = /last year.[^o]/gi mostime2[2] = "last year" mostime[3] = /yesterday/gi mostime2[3] = "yesterday" mostime[4] = /\.\ssoon/gi mostime2[4] = "soon" mostime[5] = /last week.[^o]/gi mostime2[5] = "last week" mostime[6] = /previous (month|year|day|week)/gi mostime2[6] = "previous [day/week/month/year]" mostime[7] = /(\.\s|\n)next (week|month|year)/gi mostime2[7] = "next [week/month/year]"

for(i=0;i<mostime.length;i++){ if(mostime[i].test(wpTxt)){ goodmostime = false; mostimestring += "|" + mostime2[i];		//add parameters } }

if(!goodmostime) document.getElementById(output_PR).value+="\n"

// //searches for images // regex_img = /\[\[Image:/gi if(!regex_img.test(wpTxt)) document.getElementById(output_PR).value+="\n"

//sees if lead image exists (may not be accurate if template is at front if(!((wpTxt.substring(0,100).indexOf("[[Image")!=-1)||(wpTxt.substring(0,100).indexOf("[[image")!=-1)||(wpTxt.substring(0,2)=="{{")||(wpTxt.substring(0,2)=="<!")||(wpTxt.substring(0,3)==":''"))){ document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/leadimg}} " }

// //searches for images without captions // var list_cap = new Array(/\d{2}px\]\]/i,/\|none\]\]/i,/\|left\]\]/i,/\|center\]\]/i,/\|right\]\]/i,/\|thumb\]\]/i,/\|thumbnail\]\]/i,/\|frame\]\]/i,/\.jpg\]\]/i,/\.png\]\]/i,/\.svg\]\]/i) check_cap = false;		//if check_cap == true, then captions are needed

for(i=0;i<list_cap.length;i++){if(list_cap[i].test(wpTxt)) check_cap = true;}

if(check_cap) document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/caption}}";

// // image licensing: as of now, cannot check licensing of WikiMedia Commons images // assumes images on commons are properly sourced // var imgCode = /\[\[image:(.+?)(\||\])/gi var imgList = new Array; if(imgCode.test(wpTxt) && !noXHR_PR){ imgList = wpTxt.match(imgCode); for(i=0;i<imgList.length;i++) { imgList[i] = imgList[i].replace(/\[\[image:(.+?)(\||\])/gi,"Image:$1"); try{ wpajax.download({url:'http://en.wikipedia.org/w/index.php?title='+imgList[i]+'&action=raw',	                onSuccess: checkImgLicense, onFailure: wikiImg, message: "raw," + imgList[i] }); }       catch(e){ alert("Error: Unable to complete XMLHttpRequest\nfor image licensing tags check"); }	}		//output for image licensing prolems if(imgNT) document.getElementById(output_PR).value += "\n{{subst:User:AndyZ/PR/imgtag"+imgNTstr+"}} "; if(imgFU) document.getElementById(output_PR).value += "\n{{subst:User:AndyZ/PR/imgfu"+imgFUstr+"}} "; }

// //searches for infobox // var list_ibox = new Array(/\{\{infobox/gi,/\{\{taxobox/gi,/\{\{.{1,}infobox(\s|)\|/gi,/\{\{[^or]/i) check_ibox = false;

for(i=0;i<list_ibox.length;i++){ if(list_ibox[i].test(wpTxt)) check_ibox = true; }

if(!check_ibox) document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/infobox}} (Note that there might not be an applicable infobox; remember that these suggestions are not generated manually)"

// //searches for {{persondata}} // catbirth = /\[\[Category\:\d{1,}\s(BC\s|)births/gi							//category:xxxx births catdeath = /\[\[Category\:\d{1,}\s(BC\s|)deaths/gi							//category:xxxx deaths infobio = /\{\{Infobox(\_|\s)(biography|philosopher|Military\sPerson)/gi	//major person infoboxes persondata = /\{\{persondata/gi												//persondata template

if((catbirth.test(wpTxt) || catdeath.test(wpTxt) || infobio.test(wpTxt)) && (!persondata.test(wpTxt))) document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/persondata}}"

// //WP:MOSNUM and WP:MOSDATE: // //   NOTE: Following sections need cleanup //   to become easily readable //

// //nbsp checker: distances //

//list of units, NEEDS CLEANUP!! + ADDITIONS!! list_unitnbsp = /((\d+)(\s|)(km|kilometer|kilometre|mi[\s\)]|mile|ft|foot|feet|yd|yard|in(ch|ches)|cm|centi|dm|decim|nm|nano|lb|pound|tons?\s|metric ton|g\s|gram|g\)|in 2<\/sup>|squared inches|ft 2<\/sup>|squared feet|m 2<\/sup>|squared meter|km 2<\/sup>|squared kilo|cm 2<\/sup>|squared centi|mi 2<\/sup>|squared mile|in 3<\/sup>|cubic inch|ft 3<\/sup>|cubic feet|m 3<\/sup>|cubic meter|km 3<\/sup>|cubic kilo|cm 3<\/sup>|cubic centi|mi 3<\/sup>|cubic mile))/gi;

if(list_unitnbsp.test(wpTxt)){ temp_unitnbsp = wpTxt.match(list_unitnbsp); document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/nbsp|"+RegExp.$1+"|"+RegExp.$2+" "+RegExp.$4+"|"+RegExp.$2+"&amp;nbsp;"+RegExp.$4+"}}"; }

// //checks for usage of standard abbreviations in parentheses (for conversions) // kmSA = /(kilometer|kilometer|kilometers|kilometres)\)/gi miSA = /mile(s|)\)/gi ftSA = /(foot|feet)\)/gi ydSA = /yard(s|)\)/gi inchSA = /(inch|inches)\)/gi cmSA = /centimeter(s|)\)/gi dmSA = /decimeter(s|)\)/gi nmSA = /nanometer(s|)\)/gi

//weights/mass lbSA = /(pound|pounds)\)/gi gramSA = /(gram|grams)\)/gi kgSA = /(kilogram|kilograms)\)/gi

//area sqinSA = /squared inch(es|)\)/gi sqftSA = /squared feet\)/gi sqmtSA = /squared meter(s|)\)/gi sqkmSA = /squared (kilometer|kilometer|kilometers|kilometres)\)/gi sqcmSA = /squared centimeter(s|)\)/gi sqmiSA = /squared mile(s|)\)/gi

//volume cuinSA = /cubic inch(es|)\)/gi cuftSA = /cubic (foot|feet)\)/gi cumtSA = /cubic meter(s|)\)/gi cukmSA = /cubic kilometer(s|)\)/gi cucmSA = /cubic centimeter(s|)\)/gi cumiSA = /cubic mile(s|)\)/gi

if(kmSA.test(wpTxt) || miSA.test(wpTxt) || ftSA.test(wpTxt) || ydSA.test(wpTxt) || cmSA.test(wpTxt) || nmSA.test(wpTxt) || inchSA.test(wpTxt) || dmSA.test(wpTxt) || lbSA.test(wpTxt) || gramSA.test(wpTxt) || kgSA.test(wpTxt) || sqinSA.test(wpTxt) || sqftSA.test(wpTxt) || sqmtSA.test(wpTxt) || sqkmSA.test(wpTxt) || sqcmSA.test(wpTxt) || sqmiSA.test(wpTxt) || cuinSA.test(wpTxt) || cuftSA.test(wpTxt) || cumtSA.test(wpTxt) || cukmSA.test(wpTxt) || cucmSA.test(wpTxt) || cumiSA.test(wpTxt)){ document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/abbrev}}" }

// //checks that units are spelled out in text // kmSN = /km\s/gi miSN = /\smi\s/gi ftSN = /\sft\s/gi ydSN = /yd\s/gi cmSN = /cm\s/gi dmSN = /dm\s/gi nmSN = /nm\s/gi

//weights/mass lbSN = /\slb\s/gi gramSN = /\d\sg\s/gi kgSN = /kg\s/gi

//area sqinSN = /in 2<\/sup>\s/gi sqftSN = /ft 2<\/sup>\s/gi sqmtSN = /m 2<\/sup>\s/gi sqkmSN = /km 2<\/sup>\s/gi sqcmSN = /cm 2<\/sup>\s/gi sqmiSN = /mi 2<\/sup>\s/gi

//volume cuinSN = /in 3<\/sup>\s/gi cuftSN = /ft 3<\/sup>\s/gi cumtSN = /mt 3<\/sup>\s/gi cukmSN = /km 3<\/sup>\s/gi cucmSN = /cm 3<\/sup>\s/gi cumiSN = /mi 3<\/sup>\s/gi

if(kmSN.test(wpTxt) || miSN.test(wpTxt) || ftSN.test(wpTxt) || ydSN.test(wpTxt) || cmSN.test(wpTxt) || nmSN.test(wpTxt) || dmSN.test(wpTxt) || lbSN.test(wpTxt) || gramSN.test(wpTxt) || kgSN.test(wpTxt) || sqinSN.test(wpTxt) || sqftSN.test(wpTxt) || sqmtSN.test(wpTxt) || sqkmSN.test(wpTxt) || sqcmSN.test(wpTxt) || sqmiSN.test(wpTxt) || cuinSN.test(wpTxt) || cuftSN.test(wpTxt) || cumtSN.test(wpTxt) || cukmSN.test(wpTxt) || cucmSN.test(wpTxt) || cumiSN.test(wpTxt)){ document.getElementById(output_PR).value+="\n{{subst:User:AndyZ/PR/spellnum}}" }

// //checks for usage of standard abbreviations in parentheses (for conversions) // kmSN2 = /kms(\s|\))/gi miSN2 = /mis(\s|\))/gi ftSN2 = /\sfts(\s|\))/gi ydSN2 = /yds(\s|\))/gi inchSN2 = /\sins(\s|\))/gi cmSN2 = /cms(\s|\))/gi dmSN2 = /dms(\s|\))/gi nmSN2 = /nms(\s|\))/gi

//weights/mass lbSN2 = /lbs(\s|\))/gi gramSN2 = /\sgs(\s|\))/gi kgSN2 = /kgs(\s|\))/gi

if(kmSN2.test(wpTxt) || miSN2.test(wpTxt) || ftSN2.test(wpTxt) || ydSN2.test(wpTxt) || cmSN2.test(wpTxt) || nmSN2.test(wpTxt) || inchSN2.test(wpTxt) || dmSN2.test(wpTxt) || lbSN2.test(wpTxt) || gramSN2.test(wpTxt) || kgSN2.test(wpTxt)){ document.getElementById(output_PR).value+="\n*When writing standard abbreviations, the abbreviations should not have a 's' to demark plurality (change kms to km and lbs to lb)." }

// // does not work; currently fixing // /* km2 = /\d(\s|)(km|kilometer|kilometre)[^\}\s][^\(]/gi mi2 = /\d(\s|)(mi|mile)[^\}\s][^\(]/gi ft2 = /\d(\s|)(ft|foot|feet)[^\}\s][^\(]/gi yd2 = /\d(\s|)(yd|yard)[^\}\s][^\(]/gi //in2 = /\d(\s|)in[^\}\s][^\(]/gi inch2 = /\d(\s|)in[^\}\s][^\(]/gi cm2 = /\d(\s|)(cm|centi)[^\}\s][^\(]/gi dm2 = /\d(\s|)(dm|decim)[^\}\s][^\(]/gi nm2 = /\d(\s|)(nm|nano)[^\}\s][^\(]/gi

//weights/mass lb2 = /\d(\s|)(lb|pound)[^\}\s][^\(]/gi ton2 = /\d(\s|)(ton)[^\}\s][^\(]/gi mton2 = /\d(\s|)(metric ton)[^\}\s][^\(]/gi gram2 = /\d(\s|)(g\s|gram|g\))[^\}\s][^\(]/gi

//area sqin2 = /\d(\s|)(in 2<\/sup>|squared inches)[^\}\s][^\(]/gi sqft2 = /\d(\s|)(ft 2<\/sup>|squared feet)[^\}\s][^\(]/gi sqmt2 = /\d(\s|)(m 2<\/sup>|squared meter)[^\}\s][^\(]/gi sqkm2 = /\d(\s|)(km 2<\/sup>|squared kilo)[^\}\s][^\(]/gi sqcm2 = /\d(\s|)(cm 2<\/sup>|squared centi)[^\}\s][^\(]/gi sqmi2 = /\d(\s|)(mi 2<\/sup>|squared mile)[^\}\s][^\(]/gi

//volume cuin2 = /\d(\s|)(in 3<\/sup>|cubic inch)[^\}\s][^\(]/gi cuft2 = /\d(\s|)(ft 3<\/sup>|cubic feet)[^\}\s][^\(]/gi cumt2 = /\d(\s|)(m 3<\/sup>|cubic meter)[^\}\s][^\(]/gi cukm2 = /\d(\s|)(km 3<\/sup>|cubic kilo)[^\}\s][^\(]/gi cucm2 = /\d(\s|)(cm 3<\/sup>|cubic centi)[^\}\s][^\(]/gi cumi2 = /\d(\s|)(mi 3<\/sup>|cubic mile)[^\}\s][^\(]/gi

if(km2.test(wpTxt) || mi2.test(wpTxt) || ft2.test(wpTxt) || yd2.test(wpTxt) || cm2.test(wpTxt) || nm2.test(wpTxt) || inch2.test(wpTxt) || dm2.test(wpTxt) || lb2.test(wpTxt) || ton2.test(wpTxt) || gram2.test(wpTxt) || mton2.test(wpTxt) || sqin2.test(wpTxt) || sqft2.test(wpTxt) || sqmt2.test(wpTxt) || sqkm2.test(wpTxt) || sqcm2.test(wpTxt) || sqmi2.test(wpTxt) || cuin2.test(wpTxt) || cuft2.test(wpTxt) || cumt2.test(wpTxt) || cukm2.test(wpTxt) || cucm2.test(wpTxt) || cumi2.test(wpTxt)){ document.getElementById(output_PR).value+="\n" }

// //looks for unlinked dates // jan2= /\sJanuary\s(\d)(\d|)\D/gi feb2= /\sFebruary\s(\d)(\d|)\D/gi mar2= /\sMarch\s(\d)(\d|)\D/gi apr2= /\sApril\s(\d)(\d|)\D/gi may2= /\sMay\s(\d)(\d|)\D/gi jun2= /\sJune\s(\d)(\d|)\D/gi jul2= /\sJuly\s(\d)(\d|)\D/gi aug2= /\sAugust\s(\d)(\d|)\D/gi sep2= /\sSeptember\s(\d)(\d|)\D/gi oct2= /\sOctober\s(\d)(\d|)\D/gi nov2= /\sNovember\s(\d)(\d|)\D/gi dec2= /\sDecember\s(\d)(\d|)\D/gi if(jan2.test(wpTxt) || feb2.test(wpTxt) || mar2.test(wpTxt) || apr2.test(wpTxt) || may2.test(wpTxt) || jun2.test(wpTxt) || jul2.test(wpTxt) || aug2.test(wpTxt) || sep2.test(wpTxt) || oct2.test(wpTxt) || nov2.test(wpTxt) || dec2.test(wpTxt)){ document.getElementById(output_PR).value+="\n" }

// // date-th // var dateth = new Array; 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] = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\](th|st|nd|rd)/gi dateth[2] = /(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|) (th|st|nd|rd)<\/sup>/gi dateth[3] = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\] (th|st|nd|rd)<\/sup>/gi dateth[4] = /\d(\d|) (th|st|nd|rd)<\/sup>\s(of\s|)(january|february|march|april|may|june|july|august|september|october|november|december)/gi dateth[5] = /\d(\d|)(th|st|nd|rd)\s(january|february|march|april|may|june|july|august|september|october|november|december)/gi for(i=0;i<dateth.length;i++){		//searches for above RegExps in document if(dateth[i].test(wpTxt)) check_th = true; }

if(check_th) document.getElementById(output_PR).value+="\n";

// //checks for correct MOS heading styles //

// //occurence of "the" at beginning // if(wpTxt.indexOf("==The ")!= -1 || wpTxt.indexOf("== The ")!= -1) document.getElementById(output_PR).value+="\n";

// //existence of link in heading // regex_headlink = /==.{0,}\[\[.{1,}\]\].{0,}==/gi if(regex_headlink.test(wpTxt)) document.getElementById(output_PR).value+="\n";

// //checks if title is repeated in headings // wgT = wgTitle.replace(/\s\(.*\)/,"")								//remove parenthesis from title var regex_headre = new RegExp("==.{0,}"+wgT+".{0,}==","gi")			//wgTitle is defined already as title of page if(regex_headre.test(wpTxt)) document.getElementById(output_PR).value+="\n"

// //looks for ==trivia==, ==other facts==, ==miscellaneous==, etc. // var list_triv = new Array(/==(\s|)Trivia/gi,/==(\s|)Other\sf/gi,/==(\s|)Miscellaneous/gi,/==(\s|)Interesting\s/gi); var check_triv = false;		//if true, found trivia section

for(i=0;i<list_triv.length;i++){if(list_triv[i].test(wpTxt)) check_triv = true;}	//for loop to ensure that each of the trivia if(check_triv)																		//headings exist/don't exist document.getElementById(output_PR).value+="\n";

// //double checks if last sections follow WP:GTL in terms of order (see also - references - external links) // isgtl = true

var Refsection = new Array("==Reference","==Source","==Footnote","==Cit","==Note","== Reference","== Source","== Footnote","== Cit","== Note") //array to hold different possible names of the "references" section

var extlink_s = new Array("External link","External Link"); var extlink; for(i=0;i<extlink_s.length;i++){ if(wpTxt.indexOf(extlink_s[i])!=-1) extlink = extlink_s[i]; }

var seealso_s = new Array("==See also","== See also","==See Also","== See Also");	//names for see also section var seealso; for(i=0;i<seealso_s.length;i++){ if(wpTxt.indexOf(seealso_s[i])!=-1) seealso = seealso_s[i];						//find section see also }

//searching for headings against WP:GTL if((wpTxt.indexOf(seealso) > wpTxt.indexOf(extlink)) && seealso && extlink) isgtl = false for(i=0;i<Refsection.length;i++){ if(wpTxt.indexOf(seealso) > wpTxt.indexOf(Refsection[i]) && wpTxt.indexOf(Refsection[i])!=-1 && seealso) isgtl = false if(wpTxt.indexOf(extlink) < wpTxt.indexOf(Refsection[i]) && extlink) isgtl = false }

if(isgtl==false) document.getElementById(output_PR).value+="\n"

// //looks for section named "List of..." //not in use due to inaccuracy // 	/* list = /==(\s|)List/gi if(list.test(wpTxt)) document.getElementById(output_PR).value+="\n"

// 	//Checks if categories are in alphabetical order // 	cat1 = /\[\[Category:.{1,}\]\]/gi alphed = true; alphed2 = true;				 //first for WP:CATs, WP:ILs if(cat1.test(wpTxt)){ theCats = wpTxt.match(cat1)				 //array to hold categories for(i=0;i<theCats.length;i++) theCats[i]=theCats[i].toLowerCase; //moves categories to lower case //compares all cats to see if in alphabetical order for(i=0;i<theCats.length-1;i++){	    //compares all of the categories if(!(theCats[i+1]>theCats[i])) alphed = false					 //if any categories out of order }										 //set variable to false } else{ document.getElementById(output_PR).value+="\n*This article does not have any categories. Please categorize it with relevant ." //if no categories } il1 = /\[\[(.{2}|als|ang|frp|ast|zh-min-nan|pdc|ilo|jbo|nah|nrm|nds|sco|scn|simple|tpi|chr|vec|zh-yue):.{1,}\]\]/gi		//interlanguage links with //more than 2 letters; please add more if anymore exist

if(il1.test(wpTxt)){ theIL = wpTxt.match(il1)				 //array to hold ILs for(i=0;i<theIL.length-1;i++){ if(!(theIL[i+1]>theIL[i]))			 //compares all categories alphed2 = false } }		//alphabetizing template (category template will only appear for those who desire it) //configurable variable: cat_PR (1/0) if(!alphed && alphed2 && cat_PR) document.getElementById(output_PR).value+="\ncategories" if(!alphed2 && alphed) document.getElementById(output_PR).value+="\n" if(!alphed && !alphed2 && !cat_PR) document.getElementById(output_PR).value+="\n" if(!alphed && !alphed2 && cat_PR) document.getElementById(output_PR).value+="\ncategories and interlanguage links"

// 	//looks at length of article: //

// 	//summary style -ToC and entire article- // 	theLength = wpTxt.length newHeading = /\n==/g if(newHeading.test(wpTxt)){ theSections = wpTxt.match(/\n==/g) if(theSections.length<=5) document.getElementById(output_PR).value+="\n"; if(theSections.length>=24) document.getElementById(output_PR).value+="\n"; if(theLength <= 7500 && theSections.length>5) document.getElementById(output_PR).value+="\n"; } else theSections = "none"

if(theLength<=7500 && theSections=="none") document.getElementById(output_PR).value+="\n"

if(theLength>=50000) document.getElementById(output_PR).value+="\n"

// 	//looks for section-stub template // 	//Template:sectstub, section stub, section-stub, sect-stub, stub-section nosectstub = true; var tempsectstub = new Array(/\{\{sectstub\}\}/gi,/\{\{sect-stub\}\}/gi,/\{\{section stub\}\}/gi,/\{\{section-stub\}\}/gi,/\{\{stub-section\}\}/gi);

for(s=0;s<tempsectstub.length;s++){ if(tempsectstub[s].test(wpTxt)) nosectstub = false; }

if(nosectstub==false) document.getElementById(output_PR).value+="\n";

// 	//looks for weasel words // 	var ww = new Array; var ww2 = new Array; isww = false; awtstring = ""; ww[0] = "some people sa" ww[1] = "it has been" ww[2] = "many people have" ww[3] = "many scientists believe" ww[4] = "allege" ww[5] = "many people sa" ww[6] = "many people believe" ww[7] = "arguably" ww[8] = "it is claimed" ww[9] = "correctly" ww[10] = "apparently" ww[11] = "people considered" ww[12] = "many considered" ww[13] = "is considered" ww[14] = "are considered"

for(i=0;i<ww.length;i++) ww2[i] = new RegExp(ww[i],"gi")

Ref0 = /<ref/gi Ref1 = /\{\{ref/gi Ref2 = /\{\{fn/gi Ref3 = /\{\{harv/gi Ref4 = /\{\{Harv/gi

wpTxtawt = wpTxt; 	wwref = 300;	//wwref refers to the max. distance to search for a citation

for(i=0;i<ww.length;i++){ while(ww2[i].test(wpTxtawt)){ wpTxtawt = wpTxtawt.substring(wpTxtawt.indexOf(ww[i])+1,wpTxtawt.length); if(!(Ref0.test(wpTxtawt.substring(0,wwref)) || Ref1.test(wpTxtawt.substring(0,wwref)) || Ref2.test(wpTxtawt.substring(0,wwref)) || Ref3.test(wpTxtawt.substring(0,wwref)) || Ref4.test(wpTxtawt.substring(0,wwref)))){ isww = true; if(awtstring.indexOf(ww[i]) == -1) awtstring=awtstring+"|"+ww[i]+"" }	} }

if(isww==true){ document.getElementById(output_PR).value+="\n " }

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

var check_amer = 0, check_brit = 0; var 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","check","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","cheque","cosy","grey","jewellery","kerb","liquorice","mould","moult","pyjamas","programme","sceptic","sulphur");

for(i=0;i<AmSpell.length;i++){ if(wpTxt.indexOf(AmSpell[i]) != -1 && wgTitle.indexOf(AmSpell[i]) == -1){ check_amer++; ab_ex += "" + AmSpell[i] + " (A) (British: " + BrSpell[i] + "), "; }	if(wpTxt.indexOf(BrSpell[i]) != -1 && wgTitle.indexOf(BrSpell[i]) == -1){ check_brit++; ab_ex += "" + BrSpell[i] + " (B) (American: " + AmSpell[i] + "), "; } }

if(check_amer >= 2 && check_brit >= 2) document.getElementById(output_PR).value += "\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) + ".";

// 	// spell check function - load Lists of common misspellings/For machines // 	if(!noXHR_PR && spellcheck_PR && wgTitle.indexOf("Peer review") == -1){ wpajax.download({url:'http://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'}); }

// 	//checks for redundancies - based on User:Tony1/How_to_satisfy_Criterion_2a //			--more should be added if possible //

redun1 = new Array redun1[0] = ""; redun1[1] = ""; redun1[2] = ""; redun1[3] = "";

additive = /(also|in\saddition|additionally|moreover|furthermore)/gi if(additive.test(wpTxt)){ theaddnum = wpTxt.match(additive) if((theaddnum.length>=8)&&(theaddnum.length >= wpTxt.length/2000)) redun1[0] = "1" }

vaguesize = /(some\s|a\svariety\sof|a\snumber\sof|a\smajority\sof|several|a\sfew|\smany|\sany\s|\sall\s)/gi if(vaguesize.test(wpTxt)){ thevsnum = wpTxt.match(vaguesize) if((thevsnum.length>=8)&&(thevsnum.length >= wpTxt.length/2000)) redun1[1] = "1" }

temporal = /(over\sthe\syears|currently|\snow\s|from\stime\sto\stime)/gi if(temporal.test(wpTxt)){ thetempnum = wpTxt.match(temporal) if(thetempnum.length>=6 && thetempnum.length >= wpTxt.length/2500) redun1[2] = "1" }

intheyear = /(in\sthe\syear|in\sthe\syear\sof)\s(\[\[|)(\d\d\d\d)/gi if(intheyear.test(wpTxt)) redun1[3] = "1"; //exyear = RegExp.$3

if((redun1[0]=="1") || (redun1[1]=="1") || (redun1[2]=="1") || (redun1[3]=="1")){ document.getElementById(output_PR).value+="\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(redun1[0]=="1") document.getElementById(output_PR).value+="\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(redun1[1]=="1") document.getElementById(output_PR).value+="\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, “<font color='red'> All pigs are pink, so we thought of <font color='red'> a number of ways to turn them green.”"

if(redun1[2]=="1") document.getElementById(output_PR).value+="\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 <font color='red'> now using a semi-bot to generate your peer review.”"

if(redun1[3]=="1") document.getElementById(output_PR).value+="\n**“In <font color='red'> the year [of] 1990”" }

// 	//searches for footnotes // 	var list_ref = new Array(/\<ref/gi,/\<ref/gi,/<ref/gi,/\{\{ref/gi,/\{\{fn/gi,/\{\{harv/gi,/\{\{Harv/gi); var check_ref = 0;

if(list_ref[0].test(wpTxt) || list_ref[1].test(wpTxt)) check_ref=1; else if(list_ref[2].test(wpTxt) || list_ref[3].test(wpTxt) || list_ref[4].test(wpTxt) || list_ref[5].test(wpTxt)) check_ref=2; else check_ref=0

if(!check_ref)						// no footnotes document.getElementById(output_PR).value+="\n" else if(check_ref==2)				//a method outside of the cite.php document.getElementById(output_PR).value+="\n*You may wish to convert your form of references to the cite.php footnote system that WP:WIAFA 2(c) highly recommends."

// 	//checks footnote spacing following a period // 	var list_sref = new Array(/<\/ref>\./gi,/\.\s /gi,/\{\{ref\|.{1,}\}\}\./gi,/\.\s\{\{ref\|.{1,}\}\}/gi,/\.\s\{\{fn\|.{1,}\}\}/gi,/\{\{fn\|.{1,}\}\}\./gi); var check_sref = false;

for(i=0;i<list_sref.length;i++){ if(list_sref[i].test(wpTxt)){check_sref=true; break;} }

if(check_sref) document.getElementById(output_PR).value+="\n"

// 	//searches for reference section // 	var list_refsect = new Array(/==(\s|)Reference/gi,/==(\s|)Source/gi,/==(\s|)Footnote/gi,/==(\s|)Cit/gi,/==(\s|)Note/gi); var check_refsect = false;		//if check_refsect == true, then a reference section exists

for(i=0;i<list_refsect.length;i++){ if(list_refsect[i].test(wpTxt)){check_refsect = true; break;} }

if(!check_refsect) document.getElementById(output_PR).value+="\n"

// 	// looks for and // 	var list_fact = new Array(/\{\{fact\}\}/gi,/\{\{citation needed\}\}/gi); var check_fact = false;

for(i=0;i<list_fact.length;i++){ if(list_fact[i].test(wpTxt)){check_fact = true; break;} }

if(check_fact) document.getElementById(output_PR).value += "\n*Please provide citations for all of the s.";

//all articles can always use copyediting: document.getElementById(output_PR).value+="\n"

//closing + signature document.getElementById(output_PR).value+=endMsg_PR;

// // replacing template format with actual words; still in progress. // replacing footnotes, still in progress temp_mem = document.getElementById(output_PR).value; if(wgUserName != "AZPR"){ if(defaultView_PR == 0){ replaceTemp; replaceFoot; }	else if(defaultView_PR == 2) replaceTemp; } //

//show feedback document.getElementById("theFeedback").style.visibility = "visible";

if(select_PR)				//selects suggestions, for easy copy+pasting document.getElementById(output_PR).select;

//current date variables var current_date = new Date; var cur_month = current_date.getMonth; var 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");

// 	// Summary on WP:PR/ //

if((theTitle.indexOf("Peer review")!=-1 || theTitle.indexOf("WikiProject Military history/Peer review/")!=-1)&&(document.location.href.indexOf("/Automated")==-1)&&(document.editform.wpTextbox1.value.indexOf("User:AndyZ/peerreviewer")==-1)) { document.editform.wpTextbox1.value += "\n*Please see automated peer review suggestions 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+""; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; }		txt.value += summary; }

thehide; }

//

//// NO LONGER NEEDED (but kept here to continue archiving WP:PR/A) PRheader = /\{\{PR\-/gi theArchive = ""

// - archiving of automated peer reviews if(document.location.href=="http://en.wikipedia.org/w/index.php?title=Wikipedia:Peer_review/Automated&action=edit"){ if(PRheader.test(document.getElementById(output_PR).value)){ thePRarticle = wpTxt.match(/===\[\[(.{1,})\]\]===/gi) for(i=0;i<thePRarticle.length;i++){ if(document.getElementById(output_PR).value.indexOf(thePRarticle[i].substring(5,thePRarticle[i].length-5))==-1){ loc1 = wpTxt.indexOf(thePRarticle[i]) wpTxt2 = wpTxt.substring(loc1+5,wpTxt.length) loc2 = ((wpTxt2.indexOf("===| (wpTxt2.indexOf("==Requests")==-1)) ? wpTxt2.indexOf("===[[") : wpTxt2.indexOf("==Requests")				theArchive+="\n===[["				theArchive+=wpTxt2.substring(0,loc2)				document.editform.wpTextbox1.value = wpTxt.substring(0,loc1) + wpTxt2.substring(loc2,wpTxt2.length) 				wpTxt = document.editform.wpTextbox1.value			}	}	document.getElementById(output_PR).value = theArchive	// Add a tag to the summary box - stolen from [[User:Bobblewik    var txt = document.editform.wpSummary;    var summary = "JS - archiving closed peer reviews";	if (txt.value.indexOf(summary) == -1) {		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {			txt.value += " | ";		}		txt.value += summary;	} }			}	//// END UNNEEDED ARCHIVING CODE

//

// --ending brace for first function } // --

// // image licensing check functions: // // XMLHTTPrequest function by User:Zocky, on WP:US

wpajax={ download:function(bundle) { // mandatory: bundle.url // optional: bundle.onSuccess (xmlhttprequest, bundle) // optional: bundle.onFailure (xmlhttprequest, bundle) // optional: 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)); } };

// Example: //wpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', //                  onSuccess: dlComplete, message: "Here's what we got:\n\n" });

function wikiImg(xmlreq,data){ // Generally for images in Wikimedia Commons, still looking for method to fix //	wpajax.download({url:'http://en.wikpedia.org/wiki/'+imgName, //					onSuccess: checkImgLicense, message: "htm," + imgName}); //	alert("Error in loading " + data.message.substring(4,data.message.length) + "\n" + xmlreq.responseText); }

function checkImgLicense(xmlreq, data) { //  alert(data.message + xmlreq.responseText); var imgTxt = xmlreq.responseText; imgData = data.message.split(","); if(imgData.length > 2){ for(i=2;i<imgData.length;i++) imgData[1] += imgData[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 spell check, based on Lists of common misspellings/For machines //

function spellCheckReview(xmlreq, data){ 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.length;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 document.getElementById(output_PR).value += "\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 spell check //

// 	// the following functions determine the // presentation of the suggestions (template/prose, w/(o) footnotes, popups, etc.) //

var temporprose = 0;    //if 0, convert to template, else, convert to prose function determineReplace{ if(!temporprose) replaceProse; else replaceTemp; temporprose = !temporprose; }

var footorremove = 0;     //if 0, add footnote, else remove them function determineFoot{ if(!footorremove) replaceNoFoot; else replaceFoot; footorremove = !footorremove; }

function replaceTemp{			//replacing the textbox with the actual content of the templates, not just User:AndyZ/PR form //temp_mem = document.getElementById(output_PR).value; // format: //document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/}}","g"),"{{subst:User:AndyZ/PR/}}"); //

//all templates containing parser functions have been commented temporarily

// 	// replace templates (using ajax if allowed) //

/* if(!noXHR_PR && !PRtemplateData){ PRtemplateData = new Array; prtemp_regex = /\{\{subst:(User:AndyZ\/PR\/.*)\}\}/gi if(prtemp_regex.test(document.getElementById(output_PR))){ var PRtemplates = document.getElementById(output_PR).value.match(prtemp_regex); for(i=0;i<PRtemplates.length;i++){ PRtemplates[i] = PRtemplates[i].replace(prtemp_regex,"$1"); wpajax.download({url:'http://en.wikipedia.org/w/index.php?title=' + PRtemplates[i] + '&action=raw',					 onSuccess: replacesubstInOutput, onFailure: errorInReplaceSubst, message: PRtemplates[i]}); PRtemplateData[i] = PRtemplates[i] + ",,," + tempPRdata; }	}	} else if(PRtemplateData){ var PRtemplateName, PRtemplateContent; for(i=0;i<PRtemplateData.length;i++){ PRtemplateName = PRtemplateData[i].split(',,,')[0]; PRtemplateContent = PRtemplateData[i].split(',,,')[1]; document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace("{{"+PRtemplateName+"}}",PRtemplateContent); } } else if(noXHR_PR){                    */ document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/lead}}","g"),"*Please expand the lead to conform with guidelines at WP:LEAD. The article should have an appropriate number of paragraphs as is shown on WP:LEAD, and should adequately summarize the article."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leadlong}}","g"),"*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."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leaddetail}}","g"),"*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."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/infobox}}","g"),"*There may be an applicable infobox for this article. For example, see Template:Infobox Biography, Template:Infobox School, or Template:Infobox City."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/contxt}}","g"),"*Per WP:CONTEXT and WP:MOSDATE, 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."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/linkdate}}","g"),"*Per WP:CONTEXT and WP:BTW, years with full dates should be linked; for example, link January 15, 2006, but do not link January 2006."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/dateth}}","g"),"*As per WP:MOSDATE, dates shouldn't use {{sup|th}}; for example, instead of using January 30{{sup|th}} was a great day, use January 30 was a great day."); //document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/time}}","g"),"*Per WP:MOS, avoid using words/phrases that indicate time periods relative to the current day. {{#if:{{{1|}}}|For example, {{{1}}}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}| ,| and}} {{{2}}}}}{{#if:{{{3|}}}|{{#if:{{{4|}}}|,|, and}} {{{3}}}}}{{#if:{{{4|}}}|{{#if:{{{5|}}}|,|, and}} {{{4}}}}}{{#if:{{{5|}}}|{{#if:{{{6|}}}|,|, and}} {{{5}}}}}{{#if:{{{6|}}}|, and {{{6}}}}} {{#if:{{{1|}}}|might be terms that should be replaced with specific dates/times.}} "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/nbsp}}","g"),"*Per WP:MOSNUM, there should be a non-breaking space -  between a number and the unit of measurement. For example, instead of 18mm, use 18 mm, which when you are editing the page, should look like: <tt>18&amp;nbsp;mm</tt>. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/spellnum}}","g"),"*Per WP:MOSNUM, please spell out source units of measurements in text; for example, the Moon is 380,000 kilometres (240,000 mi) from Earth. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/abbrev}}","g"),"*Per WP:MOSNUM, when doing conversions, please use standard abbreviations: for example, miles -> mi, kilometers squared -> km{{sup|2}}, and pounds -> lb."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headingthe}}","g"),"*Per WP:MOS, headings generally do not start with the word 'The'. For example,  ==The Biography==  would be changed to  ==Biography== ."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headingre}}","g"),"*Per WP:MOS, 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== ."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headinglink}}","g"),"*As per WP:MOS, please do not link words in headings."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/gtl}}","g"),"*Please reorder/rename the last few sections to follow guidelines at WP:GTL."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/overlink}}","g"),"*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 WP:MOS-L and WP:CONTEXT."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/underlink}}","g"),"*Consider adding more links to the article; per WP:MOS-L and WP:BTW, create links to relevant articles."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/footspace}}","g"),"*As done in WP:FOOTNOTE, footnotes usually are located right after a punctuation mark (as recommended by the CMS, but not mandatory), such that there is no space inbetween. For example, the sun is larger than the moon [2]. is usually written as the sun is larger than the moon.[2]"); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha}}","g"),"*Please alphabetize the interlanguage links. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha|categories}}","g"),"*Please alphabetize the categories. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha|categories and interlanguage links}}","g"),"*Please alphabetize the categories and interlanguage links. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/ref}}","g"),"*The article will need references. See WP:CITE and WP:V for more information."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/foot}}","g"),"*This article needs footnotes, preferably in the cite.php format recommended by WP:WIAFA. Simply, enclose inline citations, with WP:CITE or WP:CITE/ES information, with . At the bottom of the article, in a section named “References” or “Footnotes”, add . "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/noimg}}","g"),"*This article has no images. Please see if there are any free use images that fall under WP:IUP and WP:IT 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. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leadimg}}","g"),"*See if possible if there is a free use image that can go on the top right corner of this article. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/caption}}","g"),"*Per WP:WIAFA, Images should have concise captions. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/toc}}","g"),"*Per WP:WIAFA, 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 WP:SS. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/expand}}","g"),"*This article is a bit too short, and therefore may not be as comprehensive as WP:WIAFA critera 1(b) is looking for. Please see if anything can be expanded upon."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/SS}}","g"),"*This article may need to undergo summary style, where a series of appropriate subpages are used. For example, if the article is United States, than 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."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/copyedit}}","g"),"*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. "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/list}}","g"),"*This article may be a bit list-weighty; in other words, some of the lists should be converted to prose (paragraph form). "); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/trivia}}","g"),"*Generally, trivia sections are looked down upon; please either remove the trivia section or incorporate any important facts into the rest of the article."); document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/persondata}}","g"),"*If this article is about a person, please add  along with the required parameters to the article - see Persondata for more information.");

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

//}

//for footnote showing/hiding function: foot_mem = document.getElementById(output_PR).value;

// change the button's value document.theForm.switch_temp.value = "Template form"; document.theForm.switch_temp.style.width = 150; }

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.length;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<list_params.length;j++){ if(j==list_params.length-1) list_paramsStr += list_params[j]; else list_paramsStr += list_params[j] + ",,"; }		//nested if-else 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:AWT. 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 WP:MOSNUM, there should be a non-breaking space -  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: <tt>"+list_params[3]+"</tt>. "); } }	}

function replaceProse{ document.getElementById(output_PR).value = temp_mem; document.theForm.switch_temp.value = "Prose form"; document.theForm.switch_temp.style.width = 150; }

function replaceSubstInOutput(xmlreq,data){ document.getElementById(output_PR).replace("{{subst:" + data.message + "}}",xmlreq.responseText.replace(/ .*<\/noinclude>/gi,"").replace(/<(\/|)includeonly>/gi,"")); tempPRdata = xmlreq.responseText; } function errorInReplaceSubst(xmlreq,data){ alert("Error: Unable to locate information at " + data.message); }

function replaceFoot{					// removes the footnotes //temp_mem = document.getElementById(output_PR).value; // document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/<ref name='(\w{1,})'>See footnote<\/ref>/gi,"").replace(/ \[\[User:AndyZ\/PRnotes#_note-(.{1,})\|(.{1,})\]\]<\/sup>/gi,""); ////																																										// use link to WP:PR/A's footnotes: "{{sup|$1}}" //// // document.theForm.switch_foot.value = "Show footnotes"; document.theForm.switch_foot.style.width = 150; }

function replaceNoFoot{				// shows the footnotes if(wgUserName != "AZPR" || directRef_PR)				// will make into a configurable option document.getElementById(output_PR).value = foot_mem.replace(/<ref name='(\w{1,})'>See footnote<\/ref>/gi,"{{sup|$1}}"); else document.getElementById(output_PR).value = foot_mem; document.theForm.switch_foot.value = "Remove footnotes"; document.theForm.switch_foot.style.width = 150; }

var readonlystatus = 0;	//if 0, make readonly; else make non-readonly

function determineReadonly{ if(!readonlystatus){document.getElementById(output_PR).readOnly = true; document.theForm.switch_readonly.value = "Edit-able"; document.theForm.switch_readonly.style.width = 150;} else {document.getElementById(output_PR).readOnly = false; document.theForm.switch_readonly.value = "Readonly"; document.theForm.switch_readonly.style.width = 150;} readonlystatus = !readonlystatus; }

function popreview{ PRresult = "<script type='text/javascript' src='http://en.wikipedia.org/w/index.php?title=User:AndyZ/peerreviewer.js&action=raw&ctype=text/javascript&dontcountme=s'>wgUserName = \"" + wgUserName + "\"; temp_mem = \"" + temp_mem + "\"; Return to <a href='http://en.wikipedia.org/wiki/" + wgPageName + "'>" + wgTitle + "</a> (<a href='http://en.wikipedia.org/w/index.php?title="+wgPageName+"&action=edit'>edit</a> | <a href='http://en.wikipedia.org/w/index.php?title="+wgPageName+"&action=history'>history</a>) <form name='theForm'><input type='button' value='Readonly' name='switch_readonly' onclick='determineReadonly' style='width:150'> <textarea id='theResponse' name='theResponse' cols='120' rows='50'>" + document.getElementById(output_PR).value + "  "; var newPage_PR = window.open("http://en.wikipedia.org/","winName"); newPage_PR.document.write(PRresult) newPage_PR.document.close }

// 	// show and hide results //

function thehide{ document.getElementById("theFeedback").style.visibility = "hidden" document.getElementById("restore").style.visibility = "visible" }

function theshow{ document.getElementById("theFeedback").style.visibility = "visible" document.getElementById("restore").style.visibility = "hidden" }

/* not in use now // // dragging PR box around //

var IE = (navigator.appName == "Microsoft Internet Explorer") ? true : false

if(wgNamespaceNumber == 0 || allSpaces_PR){ if(!IE) document.captureEvents(Event.MOUSEMOVE) document.onmousemove = getMouseXY; }

var posX, posY, elemPosX, elemPosY, difX, difY, cur_drag = false, theSpotX = 0, theSpotY = 0;

function getMouseXY(e){ if(IE){ posX = event.clientX + document.body.scrollLeft; posY = event.clientY + document.body.scrollTop; }	else { posX = e.pageX; posY = e.pageY; }	return true; }

function getObjectXY(theElement){ try{ elemPosX = 40; }	catch(e){ alert("X - error"); }	try{ elemPosY = 150; }	catch(e){ alert("Y - error"); }	try{ theElement = document.getElementsByTagName("HTML")[0]; }	catch(e){ alert("Error2"); }

while(theElement != null){ elemPosX += theElement.offsetLeft; elemPosY += theElement.offsetTop; theElement = theElement.offsetParent; } }

function StartDrag(elem){ getObjectXY(elem); difX = elemPosX - posX; difY = elemPosY - posY; cur_drag = setInterval("DragIt(" + elem.id + ")",1); }

function DragIt(elem){				//new position of element elem.style.left = posX + difX; elem.style.top = posY + difY; }

function CancelDrag{				//stop the dragging if(cur_drag) window.clearInterval(cur_drag); }

// 	// not in usage: allows user to move results to a different page // fails to work (unable to access popup?) //

//ideally the following function can be replaced by a menu function addToPage{ replaceProse; var faketarget;	// results_PR = document.getElementById(output_PR).value; results_PR = results_PR.match(/\{\{subst:User:AndyZ\/PR\/(.*)\}\}/gi); for(i=0;i<results_PR.length;i++) results_PR[i] = results_PR[i].replace(/\{\{subst:User:AndyZ\/PR\/(.*)\}\}/gi,"$1"); // 	var newPageName; var moveToPrompt = prompt("Move PR to: 1 - talk page 2 - article's peer review page  3 - personal sandbox  0 - Auto-PR page\tOr enter pagename","Enter the destination page name or a menu option") if(moveToPrompt.length == 1){ faketarget = moveToPrompt + "," + wgTitle + "," + results_PR.join(","); fakeaction = "movePR"; }	else if(moveToPrompt.length > 1){ faketarget = "9," + wgTitle + "," + results_PR.join(","); }	if(moveToPrompt == "0"){		//add it to WP:PRA/?0? var cur_d = new Date; var cur_yr = d.getFullYear; var cur_m = d.getMonth;			//date elements newPageName = "Wikipedia:Peer_review/Automated/" + cur_m + "_" + cur_yr + "&section=2&fakeaction=movePR&faketarget="+faketarget; }	else if(moveToPrompt == "1") newPageName = "Talk:" + wgPageName +"&section=new&fakeaction=movePR&faketarget="+faketarget; else if(moveToPrompt == "2") newPageName = "Wikipedia:Peer review/" + wgPageName + "&fakeaction=movePR&faketarget="+faketarget; else if(moveToPrompt == "3") newPageName = userSandbox_PR + "&fakeaction=movePR&faketarget="+faketarget; else if(moveToPrompt == null || moveToPrompt == "" || moveToPrompt == " " || moveToPrompt == "Enter the destination page name or a menu option") return; else newPageName = moveToPrompt + "&fakeaction=movePR&faketarget=" + faketarget; var newPage = window.open("http://en.wikipedia.org/w/index.php?title="+newPageName+"&action=edit") //do stuff on new pages /*	if(moveToPrompt == "0"){ newPage.document.getElementById('wpTextbox1').value = document.getElementById(input_PR).value + newPage.document.getElementById('wpTextbox1').value; newPage.document.editform.wpSummary.value += " "+wgTitle+"" }	else if(moveToPrompt == "1"){ newPage.document.getElementById('wpTextbox1').value = document.getElementById(input_PR).value.replace(/===.*===/gi,""); newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions"; }	else if(moveToPrompt == "2"){ newPage.document.getElementById('wpTextbox1').value += document.getElementById(input_PR).value.replace(/===.*===/gi,"===JavaScript suggestions==="); newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions"; }	else if(moveToPrompt == "3"){ newPage.document.getElementById('wpTextbox1').value += document.getElementById(input_PR).value; newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions"; }	else{ if(wgNamespaceNumber!=0){ newPage.document.getElementById('wpTextbox1').value += document.getElementById(input_PR).value; newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions"; }		else alert("These suggestions should not be on an article page; please move them to a discussion page."); }	*/ }

function toReview1{ if(document.title.indexOf("Editing ") == 0) review1; else window.open('http://en.wikipedia.org/w/index.php?title='+wgPageName+'&action=edit&fakeaction=displayPR','Edit'); }

// 	// these functions auto-submit articles for WP:PR, modified from AutoVFD script //

function pr { var pagename = document.editform.action.substring(pagename.indexOf('title=') + 6,pagename.lastIndexOf('&action=submit'));

window.open('http://en.wikipedia.org/w/index.php?title=Talk:' + unescape(pagename) + '&action=edit&fakeaction=prtemp','Talk', 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Peer_review/' + unescape(pagename) + '&action=edit&fakeaction=prsub&faketarget=' + unescape(pagename),'PRnom', 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Peer_review&action=edit&fakeaction=prlist&faketarget=' + unescape(pagename), 'PRlisting', 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); }

function autopr { if (document.title.indexOf('Editing ') == 0) {     var theaction = ''; var target = ''; if (location.search) {         var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) {             var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') theaction = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); }       }      if (theaction == 'prlist') {         req = document.editform.wpTextbox1.value.indexOf("{{Wikipedia:Peer review/"); document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.substring(0,req) + '{{Wikipedia:Peer review/' + target + '}}\n' + document.editform.wpTextbox1.value.substring(req,document.editform.wpTextbox1.value.length); document.editform.wpSummary.value = 'Peer review/' + target + ''; }     else if (theaction == 'prsub'){ if (document.editform.wpTextbox1.value.length > 0) window.alert("There's an old peer review at the default location already.\n\n" +                          'Please either move it out of the way (and update existing links to it), or file the PR by hand in another location (such as Peer review/' + wgTitle.split("/")[1] + ' 2).'); else document.editform.wpTextbox1.value += '===' + target + '===\n' + ' ' + '';     }      else if (theaction == 'prtemp'){ if (document.editform.wpTextbox1.value.indexOf('{{peerreview}}') != -1) window.alert("There has already been a peer review."); else{ document.editform.wpTextbox1.value = '{{peerreview}}\n\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'peer reviewing - Peer review/' + target + ''; }       }      else if (theaction == 'displayPR') review1; else if (theaction == 'movePR'){ /*list_PR = target.split(","); if(list_PR[0] == 0){ cur_txt = document.getElementById('wpTextbox1').value; document.getElementById('wpTextbox1').value = "===" + list_PR[1] + "===\n" + initMsg_PR + "\n"; for(i=2;i<list_PR.length;i++)	// document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n" // 				document.getElementById('wpTextbox1').value += document.getElementById(output_PR).value+=endMsg_PR; document.getElementById('wpTextbox1').value += cur_txt; document.getElementById('wpSummary').value += "+ "+list_PR[1]+"" }	 			else if(list_PR[0] == 1){ document.getElementById('wpTextbox1').value = "===" + list_PR[1] + "===\n" + initMsg_PR + "\n"; for(i=2;i<list_PR.length;i++)	// document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n" // 				document.getElementById('wpTextbox1').value +=endMsg_PR; document.getElementById('wpSummary').value = "JavaScript peer review suggestions" }			else if(list_PR[0] == 2){ document.getElementById('wpTextbox1').value += "\n\n===" + list_PR[1] + "===\n" + initMsg_PR + "\n"; for(i=2;i<list_PR.length;i++)	// document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n" // 				document.getElementById('wpTextbox1').value +=endMsg_PR; document.getElementById('wpSummary').value += "JavaScript-generated suggestions" }			else if(list_PR[0] == 3){ document.getElementById('wpTextbox1').value += "\n\n===" + list_PR[1] + "===\n" + initMsg_PR + "\n"; for(i=2;i<list_PR.length;i++)	// document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n" // 				document.getElementById('wpTextbox1').value += endMsg_PR; document.getElementById('wpSummary').value += "JavaScript-generated suggestions for " + list_PR[1] + ""; }			else if(list_PR[0] == 9){ if(wgNamespaceNumber == 0) alert("Please do not add these comments to an article; move them instead to a discussion page"); else { document.getElementById('wpTextbox1').value += "\n\n===" + list_PR[1] + "===\n" + initMsg_PR + "\n"; for(i=2;i<list_PR.length;i++)	// document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n" // 					document.getElementById('wpTextbox1').value += endMsg_PR; document.getElementById('wpSummary').value += "JavaScript-generated suggestions for " + list_PR[1] + ""; }				}*/	 }      else pr; } }

if(!noSendTo_PR){ addOnloadHook(function {	    if(document.forms.editform) {	        addLink('p-cactions', 'javascript:autopr', 'send to WP:PR', 'ca-peerreview', 'Submits article for peer review', , );	    }	}); }

if(document.location.href.indexOf("fakeaction") != -1) addOnloadHook(autopr);

// end

//////////////////////////////////////// /*List of things to do: // Determine the usage of commas with dates // Determine the length of a lead (number of paragraphs) // Figure out if the lead is too short (1 paragraph) or too long (>=4 paragraphs), depending upon size of article // Determine if no-break spaces are used // Determine if conversions are included // Determine if standard abbreviations are used for conversions // Determine if units are spelled out in text // Determine if last few sections (see also, references, notes, external links) follow WP:GTL //- not necessary to check - Determine if extraneous bolding is used // Determine if categories and interlanguage links are alphabetized //- not able to do (w/ JS) Determine if quotes have sources // Prove that images have proper image copyright tags // Show that all fair use images have proper fair use rationales // Determine if all images have captions // Find out the number of sections //- not able to do (w/ JS) Determine if sections or paragraphs are too short //- not able to do (w/ JS) Determine if a list is used // Determine if footnote spacing standards are used (as in WP:FOOTNOTE) //- not able to do (w/ JS) Determine if words in headings are capitalized // Find common redunancies // Time/future issues // Check w/ U:SUGG to see if any other things are missing // Automatic archiving // British/American English spellings // Help out with WP:FL // Maybe WP:FPO? // simple links for easy copy+paste into sandboxes, talk pages, or WP:PR/A ** // instaview version (somewhat like User:Pilaf's, possibly) ** // improving look // embedding solutions beneath text, possibly (using innerHTML, etc., property) ** // more configurable options that will be helpful to users

Second priority issues: // Add to list of units (for units, conversions, and standard abbreviations) // Add to list of weasel words // Improve the headingre function to exclude "the" and words in parentheses // infoboxes...

// -- Specific to: User:AZPR (this simplifies the process of maintaining WP:PR/A - // to use this, inquire on User talk:AndyZ/peerreviewer.js) var mem;

if(wgUserName == "AZPR" || maintain_PR){ if((document.location.href.indexOf("http://en.wikipedia.org/w/index.php?title=Wikipedia:Peer_review/")!=-1) && (document.location.href.indexOf("section=1")!=-1) && (document.location.href.indexOf("Automated")==-1)){ $(function {	    mem = document.getElementById("wpTextbox1").value;	    review1;	    if(mem != document.getElementById("wpTextbox1").value) document.getElementById('wpSave').click;	}); }

if((document.location.href.indexOf("action=edit")!=-1) && (wgNamespaceNumber == 0)){ $(review1); } }

/* /////////////////    // Note: // I am quite aware // that the layout and documentation // of my coding is pretty terrible; // feel free to edit this page // and help clean it up   // -- // (for non-admins, leave a note on the talk page) // --   // Please be aware that changes // may affect many users // AS OF LAST COUNT: -- 114 -- users use this script /////////////////

// //cut out code can be found at User:AndyZ/peerreviewer.js/comment

// see http://paperlined.org/apps/wikipedia/Tool2/ for instructions on adding this to your monobook.js

// To run this tool on other servers: //	1. copy this script to the target server (this is required because of javascript cross-site security restrictions)

//	2. update the following URL //		for example: "User:Interiot/Tool2/code.js" var tool2_url = "User:Interiot/Tool2/code.js";

//	3. update this namespace list, extracted from something like http://en.wikiquote.org/wiki/Special:Export// //			These *should not* have colons after them. var namespaces = [ "Talk", "User", "User talk", "Wikiquote", "Wikiquote talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk", // 3b. these two project project entries are not added by Special:Export, and might or might not need to be updated "Wikipedia", "Wikipedia talk" ];

namespaces[100] = "Portal"; namespaces[101] = "Portal talk";

//	4. update this date-parser to match the format and language of your specific wiki. Feel free to contact Interiot regarding this, if you can't find another //		copy of this script that uses the same language. // input: a text string from Special:Contributions. output: a javascript Date object // documentation: http://www.quirksmode.org/js/introdate.html#parse, http://www.elated.com/tutorials/programming/javascript/dates/ function date_parse(text) { var matches = text.match(/^([0-9:]+), +([0-9]+) +([a-z]+) +([0-9]+)$/i); if (!matches) { //dump_text("XXX");			// for debugging return matches; }

parseme = matches[3] + ", " + matches[2] + " " + matches[4] + " " + matches[1] + ":00";

//dump_text(parseme);				// for debugging

var dt = new Date; dt.setTime( Date.parse(parseme));

//dump_text(dt.toLocaleString);		// for debugging

return dt; }

// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end of server-specific configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// TODO: //	- the current document.location method doesn't work when the page is accessed sans-mod_rewrite //	- test with non-ASCII characters //		- non-ascii usernames //		- ??

var prefix = ""; var params = parse_params;

addOnloadFunction(function { var path_len = document.location.pathname.length;  // trigger once we view the right page  if (document.location.pathname.substring(path_len - tool2_url.length, path_len) == tool2_url) {    // get the prefix (needs to be fixed to work sans-mod_rewrite prefix = document.location.protocol + "//" + document.location.host + "/" + document.location.pathname.substring(1, path_len - tool2_url.length);

// blank the inner contents of the page var bodyContent = document.getElementById("bodyContent"); while (bodyContent.childNodes.length > 0) bodyContent.removeChild(bodyContent.lastChild);

if (document.location.search.length == 0) { generate_input_form(bodyContent); } else { generate_main_report(bodyContent); } } });

function generate_input_form(bodyContent) { if (navigator.userAgent.toLowerCase.indexOf('msie')+1) { bodyContent.innerHTML = "This counter does not currently work in Internet Explorer.  Please <a href='http://www.getfirefox.com'>get Firefox</a> or use <a href='http://en.wikipedia.org/wiki/Wikipedia:WikiProject_edit_counters/Flcelloguy%27s_Tool'>Flcelloguy's Tool</a> instead."; } else { bodyContent.innerHTML = " ";

var form = bodyContent.getElementsByTagName("form")[0]; form.method = "get"; form.action = document.location;

document.getElementById("username").focus; } }

function generate_main_report { fetch_data(params["username"].replace(/\+/g, " "),		"", output_main_report, 0, []); }

function add_stats_row(left_col, right_col) { var row = document.createElement("tr"); var left = document.createElement("td"); var right = document.createElement("td"); document.getElementById("basic_stats").appendChild(row); row.appendChild(left); row.appendChild(right); //left.innerHTML = left_col; left.appendChild( document.createTextNode(left_col) ); right.appendChild( document.createTextNode(right_col) ); return row; }

function output_main_report(history) { // -- generate summary statistics var unique_articles = new Array; var namespace_numedits = new Array; for (var i=0; i<namespaces.length; i++) { namespace_numedits[ namespaces[i] ] = 0; }	namespace_numedits[""] = 0; for (var i=0; i<history.length; i++) { var h = history[i]; unique_articles[ h["title"] ]++; namespace_numedits[ h["namespace"] ]++; }	var unique_articles_keys = keys(unique_articles);

// -- output report var table = document.createElement("table"); table.id = "basic_stats"; document.getElementById("bodyContent").appendChild(table);

add_stats_row("Username", params["username"].replace(/\+/g, " ")); add_stats_row("Total edits", history.length); add_stats_row("Distinct pages edited", unique_articles_keys.length); add_stats_row("Average edits/page", new Number(history.length / unique_articles_keys.length).toFixed(3)); add_stats_row("First edit", history[ history.length-1 ]["date_text"] );

// add a blank row add_stats_row("", "").childNodes[0].style.height = "1em";

add_stats_row("(main)", namespace_numedits[""]); for (var i=0; i<namespaces.length; i++) { var nmspc = namespaces[i]; if (namespace_numedits[nmspc]) { add_stats_row(nmspc, namespace_numedits[nmspc]); }	} }

// ===================================== HTML-scraping backend =========================================

function add_loading_notice { if (document.getElementById("loading_notice")) return; var loading = document.createElement("div"); loading.id = "loading_notice"; loading.innerHTML = " Retrieving data ... "; document.getElementById("bodyContent").appendChild(loading); } function remove_loading_notice { var loading = document.getElementById("loading_notice"); if (!loading) return; loading.parentNode.removeChild(loading); }

var offset_regexp = /href="[^"]+:Contributions[^"]+offset=(\d+)/gi; function fetch_data(username, end_date, handler, offset, page_list) {	add_loading_notice;	var url = prefix + "Special:Contributions/" + username + "?offset=" + offset + "&limit=5000";	loadXMLDoc(url, 		function (request) {			var next_offset = 0;			if (request.readyState != 4)  return;			if (request.status == 200) {				page_list.push(request.responseText);				//dump_text(request.responseText);

// see if there's another pageful to get var matches = map( function(p){						return p.match( /(\d+)$/ )[0];					}, request.responseText.match( offset_regexp ) ); for (var i=0; i<matches.length; i++) { var v = matches[i] * 1; if (v != 0 && (offset == 0 || v < offset)) { next_offset = v;						break; }				}			}

//next_offset = 0;			// for testing only, retrieve just the first page of results

if (next_offset == 0) { parse_data(page_list, handler); } else { // tail recurse fetch_data(username, end_date, handler, next_offset, page_list); }		}); }

// input: a list of strings, each string containing the HTML from a single page // output: a list, where each individual entry is a specific edit from history function parse_data(page_list, handler) { //var total_len = 0; //for (var i=0; i<page_list.length; i++) total_len += page_list[i].length; //alert("parsing " + page_list.length + " pages comprising " + total_len + " total bytes");

var last_history_ent = []; last_history_ent["title"] = ""; last_history_ent["oldid"] = "";

var edit_history = new Array; for (var pagecnt=0; pagecnt<page_list.length; pagecnt++) { var matches = page_list[pagecnt].match( /^<li>[^(]+\(<a href="[^"]+action=history.*/gim ); //dump_lines(matches); for (var matchcnt=0; matchcnt<matches.length; matchcnt++) { var history_text = matches[matchcnt];

var history_entry = new Array; history_entry["date_text"] = history_text.match( /^<li>([^(<]+)/i )[1]					.replace( / +$/, "");			history_entry["date"] = date_parse( history_entry["date_text"] );			history_entry["title"] = history_text.match( /title="([^"]+)"/i )[1]					.replace( /&quot;/g, "\"")					.replace( /&amp;/g, "&");			var find_comment = history_text.replace(/ .*?<\/span> ?/, "");			history_entry["comment"] = ifmatch(find_comment.match( / (.*?)<\/span>/ ))					.replace(/^\((.*)\)$/, "$1");			history_entry["minor"] = /<span class="minor"/.test(history_text);			history_entry["oldid"] = ifmatch(history_text.match(/oldid=([0-9]+)/i));

history_entry["namespace"] = ""; for (var nmspc_ctr=0; nmspc_ctr<namespaces.length; nmspc_ctr++) { var nmspc = namespaces[nmspc_ctr] + ":"; if (history_entry["title"].substring(0, nmspc.length) == nmspc) { history_entry["namespace"] = namespaces[nmspc_ctr]; break; }			}

//dump_object(history_entry);

if (history_entry["title"] != last_history_ent["title"] || history_entry["oldid"] != last_history_ent["oldid"]) edit_history.push(history_entry); last_history_ent = history_entry; }	}

remove_loading_notice;

handler(edit_history); }

// ===================================== test/debug functions =========================================

function dump_text(text) { //alert("dump_text, with text of size " + text.length);

var pre = document.createElement("pre");

var div = document.createElement("div"); div.style.width = "60em"; div.style.maxHeight = "40em"; div.style.overflow = "auto";

pre.appendChild(document.createTextNode(text)); div.appendChild(pre); document.getElementById("bodyContent").appendChild(div); }

function dump_lines(ary) { dump_text("--> " + ary.join("\n--> ")); }

function dump_object(obj) { var toString = ""; for (var prop in obj) { toString += prop + ": " + obj[prop] + "\n"; }	dump_text(toString); }

// ===================================== utility functions =========================================

function addOnloadFunction(f) { if (window.addEventListener) window.addEventListener("load",f,false); else if (window.attachEvent) window.attachEvent("onload",f); else { var oldOnload='_old_onload_'+addOnloadFunction.uid; addOnloadFunction[oldOnload] = window.onload ? window.onload : function {}; window.onload = function { addOnloadFunction[oldOnload]; f; } ++addOnloadFunction.uid; } }

function parse_params { var pairs = document.location.search.substring(1).split("&"); var ret = []; for (var i=0; i < pairs.length; i++) { var values = pairs[i].split("="); ret[values[0]] = unescape(values[1]); } return ret; }

function loadXMLDoc(url, handler) {   // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest; req.onreadystatechange = function {handler(req)}; req.open("GET", url, true); req.send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function {handler(req)}; req.open("GET", url, true); req.send; }   } }

// see http://search.cpan.org/dist/perl/pod/perlfunc.pod#map function map (handler, list) { var ret = new Array; for (var i=0; i<list.length; i++) { ret[i] = handler( list[i] ); // ret.push( handler( list[i] ) ); } return ret; }

// see http://search.cpan.org/dist/perl/pod/perlfunc.pod#keys function keys (obj) { var ret = new Array; for (var key in obj) { ret.push(key); }	return ret; }

function ifmatch(ary) { if (ary && ary.length >= 2) { return ary[1]; } else { return ""; } }

//

//Please leave the following line //user:Where/easy db //Start db script

$(function { //check if called from deletion request  if (document.title.indexOf("Editing ") != -1)  {    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)      return;    if (document.URL.lastIndexOf("&reason=off") != -1)    {      var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3");      var f = document.editform, t = f.wpTextbox1;      t.value = "\n" + t.value;      f.wpSummary.value = "JS: Requesting speedy deletion (CSD " + type + ")";      f.wpSave.click;      return;    }    else if (document.URL.lastIndexOf("&reason=on") != -1)    {      var type = prompt("Enter reason for speedy deletion");      var f = document.editform, t = f.wpTextbox1;      t.value = "\n" + t.value;      f.wpSummary.value = "JS: Requesting speedy deletion";      f.wpSave.click;      return;    }  }  if (wgCanonicalNamespace == "Special")    return;

mw.util.addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", ""); mw.util.addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", ""); }); function easyDb(n) { if (n == 0)  {    //edit page

location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=huff&reason=off"); }   if (n == 1) {   //edit page

location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=huff&reason=on"); } }

//End db script //

// importScript('User:AzaToth/morebits.js'); importScript('User:AzaToth/twinklefluff.js');