User:Imoeng/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
importScript('User:AzaToth/twinkle.js');
 
//<nowiki>
function inc (file) {
  var lt = String.fromCharCode(60);
  var gt = String.fromCharCode(62);
  if (file.indexOf(".js") > -1) {
    document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"'+gt+lt+'/script'+gt);
  } else if (file.indexOf(".css") > -1) {
    document.writeln(lt+'link rel="stylesheet" type="text/css" href="/w/index.php?title='+file+'&amp;action=raw&amp;ctype=text/css" /'+gt);
  }
}
function loadmonobook(user) {
  inc("User:"+user+"/monobook.css");
  inc("User:"+user+"/monobook.js");
}
 
inc("User:Topaz/init.js");
inc("User:Topaz/util.js");
inc("User:Topaz/sectionsplitter.js");
inc("User:Topaz/editcountutil.js");
inc("User:Topaz/comm.js");
inc("User:Topaz/wputil.js");
inc("User:Topaz/usermessagechanger.js");
inc("User:Topaz/statuschanger.js");
 
// Add date and time to your monobook "personal menu" list at the very top of the page.
// Created by [[User:Mathwiz2020]]
 
// Indicate where you would like the time to appear:
// 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link)
insertBeforeNum = 7;
 
// Do NOT edit below this line unless you're experiened in javascript
insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore = insertBeforeArr[insertBeforeNum];
 
function makeTime()
{
  var li = document.createElement( 'li' );
  li.id = 'pt-time';
 
  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( 'date and time' ) );
 
  li.appendChild( mySpan );
 
  if ( insertBefore )
  {
    var before = document.getElementById( insertBefore );
    before.appendChild( li, before );
  }
  else // append to end (right) of list
  {
    document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
  }
 
  getTime();
}
 
if      ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false );
else if ( window.attachEvent      ) window.attachEvent      ( 'onload', makeTime      );
 
function getTime()
{
    var time    = new Date();
    var date    = time.getUTCDate();
    var months  = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
        month   = months[time.getUTCMonth()];
    var year    = time.getUTCFullYear();
    var hours   = '0' + time.getUTCHours();
        hours   = hours.substr(hours.length-2, hours.length);
    var minutes = '0' + time.getUTCMinutes();
        minutes = minutes.substr(minutes.length-2, minutes.length);
    var seconds = '0' + time.getUTCSeconds();
        seconds = seconds.substr(seconds.length-2, seconds.length);
    var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)";
    datePlace   = document.getElementById('pt-time').childNodes[0].childNodes[0];
                  datePlace.replaceData(0, datePlace.length, curTime);
    doTime      = window.setTimeout("getTime()", 1000);
}
//
 
//Conflicts with force edit summary script!
 
var scIndex = 0;
var scKeys = new Array();
var scValues = new Array();
 
function scFormSubmit() {
   var i=0
   var textArea = document.getElementById("wpTextbox1");
   var text = textArea.value;
   while (i<scIndex) {
      text = text.replace(scKeys[i], scValues[i]);
      ++i;
   }
   textArea.value = text;
}
 
addOnloadHook(function() {
   if (document.title.indexOf("Editing ") != 0) {return;}
   document.getElementById("wpSave").onclick = scFormSubmit;
   document.getElementById("wpPreview").onclick = scFormSubmit;
   document.getElementById("wpDiff").onclick = scFormSubmit;
   //TODO: make it work with previews too!
});
 
 
addOnloadHook(function() {
   if (document.title.indexOf("Editing ") != 0) {return;}
   var textArea = document.getElementById("wpTextbox1");
   var text = textArea.value;
   var re = /<!--\[\[User:Where\/sigContract\]\];(.*)-->.*<!--ESC:(.*)-->/g;
   var lastIndex = 0;
/*   while (1) {
      var textSubstr = text.substr(lastIndex);
      alert(lastIndex);
      alert(textSubstr); //TODO: remove
      var newIndex = textSubstr.search(re);
      alert("newindex:" + newIndex);
      if (newIndex == -1) {
	 break;
      }
      lastIndex += newIndex+1;*/
      text = text.replace(re,
	 function(str, p1, p2, offset, s) {
//	    alert("In replacement function");
	    if (p1 == p2) {
	       var newString = "-[[User:" + p1 + "|" + p1 + "]]";
	       scKeys[scIndex] = newString;
	       scValues[scIndex] = str;
	       ++scIndex;
	       return newString;
	    }
	    else {
	       return str;
	    }
	 });
   //}
   textArea.value = text;
});
 
//Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  document.write('<script type="text/javascript" src="' 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }
 
/* 
 
Semi-automatic javascript peer reviewer - note that this is NOT a [[WP:BOT]] (but it may be a [[WP:SBOTS|semi-bot]]) 
 
*/ 
 
/*
 
 // See talk page for details  
 
*/
 
//<pre> start code
 
function review1(){
//theText is the variable for the text of a document
theText = document.editform.wpTextbox1.value
 
theTitle = document.location.href
 
if(theTitle.indexOf("section=")!=-1){
theTitle = document.location.href.substring(42,document.location.href.length-22)
}
else{
theTitle = document.location.href.substring(42,document.location.href.length-12)
}
 
theTitle2 = theTitle.replace(/\_/gi," ")
 
theTitle = unescape(theTitle).replace(/\_/gi," ")
 
document.theForm.theResponse.value = "===[["+theTitle+"]]===\n"+document.theForm.theResponse.value
 
//lead stuff
//determine the number of paragraphs in the lead
 
theTextlead = theText.substring(0,theText.indexOf("=="))
newLine = /\n[A-Z]/g
if(newLine.test(theTextlead)){
NumPara = theTextlead.match(newLine)
theLength = theText.length
theNumPara = NumPara.length
theNumPara++
}
else{
theNumPara=1
}
if(theNumPara==1){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/lead}}"
}
if((theNumPara==2)&&(theLength>=30000)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/lead}}"
}
if((theNumPara==3)&&(theLength<=15000)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
}
if((theNumPara==4)&&(theLength<=30000)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
}
if(theNumPara>=5){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leaddetail}}"
}
 
//checks linking in comparison to # of words
words = theText.split(" ");
links = theText.split("[[");
if(.03 * words.length >= links.length)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/underlink}}";
else if(.1* words.length <= links.length)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/overlink}}";
 
/*
//looks for redundant links
theTextlink = theText;
sectExp = /\n==/gi;
titleExp = /\n==(.{1,})==/gi
commonlinkstr = "";
linkmatch = false;
 
while(sectExp.test(theTextlink))
{
	theTextlink = theTextlink.substring(theTextlink.indexOf("\n=="),theTextlink.length);
	if(sectExp.test(theTextlink)) sectTitle = RegExp.$1
	else sectTitle = "\0";
	theTextlink.substring(5,theTextlink.length);
	theTextlink2 = theTextlink.substring(0,theTextlink.indexOf("\n=="))
 
	linkarray = theTextlink2.match(/\[\[.{1,}[\|\]]/g);	//linkarray is array of links in a section
        if(!linkarray) continue; 
	var linkarray2 = new Array();
	for(i = 0; i < linkarray.length; i++)
		linkarray2[i] = linkarray[i].substring(2,linkarray[i].length-1)
 
	for(i = 0; i < linkarray2.length; i++)
	{
		for(j = i+1; j < linkarray2.length; j++) 
		{
			if(linkarray2[i] == linkarray2[j])
			{
				linkmatch = true;
				if(sectTitle != "\0")
					commonlinkstr += "|" + linkarray2[i] + " in " + sectTitle;	
				else
					commonlinkstr += "|" + linkarray2[i];
			}
		}
	}
}
 
if(linkmatch)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/redunlink"+commonlinkstr+"}}"
*/
//checks if document follows WP:CONTEXT guidelines
regExContxt = /[^,\]]\s\[\[\d{4}\]\]/gi
contxt = regExContxt.test(theText)
if (contxt==true){document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/contxt}}"}
if (contxt==false){
//days of the week
mon= /\[\[Monday\]\]/gi
tue = /\[\[Tuesday\]\]/gi
wed = /\[\[Wednesday\]\]/gi
thu = /\[\[Thursday\]\]/gi
fri= /\[\[Friday\]\]/gi
sat= /\[\[Saturday\]\]/gi
sun= /\[\[Sunday\]\]/gi
 
//months
jan= /\[\[January\]\]/gi
feb= /\[\[February\]\]/gi
mar= /\[\[March\]\]/gi
apr= /\[\[April\]\]/gi
may= /\[\[May\]\]/gi
jun= /\[\[June\]\]/gi
jul= /\[\[July\]\]/gi
aug= /\[\[August\]\]/gi
sep= /\[\[September\]\]/gi
oct= /\[\[October\]\]/gi
nov= /\[\[November\]\]/gi
dec= /\[\[December\]\]/gi
 
if(mon.test(theText) || mon.test(theText) || tue.test(theText) || wed.test(theText) || thu.test(theText) || fri.test(theText) || sat.test(theText) || sun.test(theText) || jan.test(theText) || feb.test(theText) || mar.test(theText) || apr.test(theText) || may.test(theText) || jun.test(theText) || jul.test(theText) || aug.test(theText) || sep.test(theText) || oct.test(theText) || nov.test(theText) || dec.test(theText)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/contxt}}"
}
}
 
//about [[WP:MOS#Time]]
var mostime = new Array()
var mostime2 = new Array()
mostimestring = ""
goodmostime = true
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(t=0;t<mostime.length;t++){
if(mostime[t].test(theText)){
goodmostime = false
mostimestring = mostimestring+"|"+mostime2[t]
}
}
 
if(goodmostime==false){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/time"+mostimestring+"}}"
}
 
//searches for images
regExImg = /\[\[Image/gi
regExImg2 = /\[\[image/gi
thereisanimage = regExImg.test(theText)
if(thereisanimage==false){
thereisanimage=regExImg2.test(theText)
if(thereisanimage==false){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/noimg}}"
}
}
 
//sees if lead image exists (may not be accurate if template is at front
if((theText.substring(0,7)=="[[Image")||(theText.substring(0,6)=="[[image")||(theText.substring(0,2)=="{{")||(theText.substring(0,2)=="<!")||(theText.substring(0,3)==":''")){}
else{
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadimg}} <!--Note that if something is in front of a lead image, it will not render by this javascript suggestion peer reviewer (like a disambig link or a lead comment-->"
}
 
var imgcap = new Array()
nocap = false
imgcap[0] = /\d{2}px\]\]/i
imgcap[1] = /\|none\]\]/i
imgcap[2] = /\|left\]\]/i
imgcap[3] = /\|center\]\]/i
imgcap[4] = /\|right\]\]/i
imgcap[5] = /\|thumb\]\]/i
imgcap[6] = /\|thumbnail\]\]/i
imgcap[7] = /\|frame\]\]/i
imgcap[8] = /\.jpg\]\]/i
imgcap[9] = /\.png\]\]/i
imgcap[10] = /\.svg\]\]/i
for(i=0;i<imgcap.length;i++){
if(imgcap[i].test(theText)){
nocap = true
}
}
if(nocap==true){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/caption}}"
}
 
//imgtest()
 
//searches for infobox
infobox = /\{\{infobox/gi
infobox2 = /\{\{taxobox/gi
infobox3 = /\{\{.{1,}infobox(\s|)\|/gi
infobox4 = /\{\{[^or]/i
if(!(infobox.test(theText) || infobox2.test(theText) || infobox3.test(theText) || infobox4.test(theText.substring(0,200)))){
document.theForm.theResponse.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 <nowiki> {{persondata}} </nowiki>
catbirth = /\[\[Category\:\d{1,}\s(BC\s|)births/gi
catdeath = /\[\[Category\:\d{1,}\s(BC\s|)deaths/gi
infobio = /\{\{Infobox(\_|\s)(biography|philosopher|Military\sPerson)/gi
persondata = /\{\{persondata/gi
 
if((catbirth.test(theText) || catdeath.test(theText) || infobio.test(theText)) && (!persondata.test(theText))){
document.theForm.theResponse.value+="\n
*If this article is about a person, please add <code><nowiki>{{persondata}}</nowiki></code> along with the required parameters to the article - see [[Wikipedia:Persondata]] for more information."
} 
 
//[[WP:MOSNUM]] and [[WP:MOSDATE]]:
//nbsp checker: distances
 
km = /\d(\s|)(km|kilometer|kilometre)/gi
mi = /\d(\s|)(mi[\s\)]|mile)/gi
ft = /\d(\s|)(ft|foot|feet)/gi
yd = /\d(\s|)(yd|yard)/gi
//in = /\d(\s|)in/gi
inch = /\d(\s|)in(ch|ches|\s)/gi
cm = /\d(\s|)(cm|centi)/gi
dm = /\d(\s|)(dm|decim)/gi
nm = /\d(\s|)(nm|nano)/gi
 
//weights/mass
lb = /\d(\s|)(lb|pound)/gi
ton = /\d(\s|)ton[s\s]/gi
mton = /\d(\s|)(metric ton)/gi
gram = /\d(\s|)(g\s|gram|g\))/gi
 
//area
sqin = /\d(\s|)(in<sup>2<\/sup>|squared inches)/gi
sqft = /\d(\s|)(ft<sup>2<\/sup>|squared feet)/gi
sqmt = /\d(\s|)(m<sup>2<\/sup>|squared meter)/gi
sqkm = /\d(\s|)(km<sup>2<\/sup>|squared kilo)/gi
sqcm = /\d(\s|)(cm<sup>2<\/sup>|squared centi)/gi
sqmi = /\d(\s|)(mi<sup>2<\/sup>|squared mile)/gi
 
//volume
cuin = /\d(\s|)(in<sup>3<\/sup>|cubic inch)/gi
cuft = /\d(\s|)(ft<sup>3<\/sup>|cubic feet)/gi
cumt = /\d(\s|)(m<sup>3<\/sup>|cubic meter)/gi
cukm = /\d(\s|)(km<sup>3<\/sup>|cubic kilo)/gi
cucm = /\d(\s|)(cm<sup>3<\/sup>|cubic centi)/gi
cumi = /\d(\s|)(mi<sup>3<\/sup>|cubic mile)/gi
 
if(km.test(theText) || mi.test(theText) || ft.test(theText) || yd.test(theText) || cm.test(theText) || nm.test(theText) || inch.test(theText) || dm.test(theText) || lb.test(theText) || ton.test(theText) || gram.test(theText) || mton.test(theText) || sqin.test(theText) || sqft.test(theText) || sqmt.test(theText) || sqkm.test(theText) || sqcm.test(theText) || sqmi.test(theText) || cuin.test(theText) || cuft.test(theText) || cumt.test(theText) || cukm.test(theText) || cucm.test(theText) || cumi.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Manual of Style (dates and numbers)#Units of measurement|Wikipedia:Manual of Style (numbers)]], there should be a non-breaking space - <code>&amp;nbsp;</code> between a number and the unit of measurement. For example, instead of ''{{{1|18mm}}}'', use ''{{{2|18&nbsp;mm}}}'', which when you are editing the page, should look like: <tt>{{{3|18&amp;nbsp;mm}}}</tt>.<ref name="nbsp">See footnote</ref>"
}
 
//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(theText) || miSA.test(theText) || ftSA.test(theText) || ydSA.test(theText) || cmSA.test(theText) || nmSA.test(theText) || inchSA.test(theText) || dmSA.test(theText) || lbSA.test(theText) || gramSA.test(theText) || kgSA.test(theText) || sqinSA.test(theText) || sqftSA.test(theText) || sqmtSA.test(theText) || sqkmSA.test(theText) || sqcmSA.test(theText) || sqmiSA.test(theText) || cuinSA.test(theText) || cuftSA.test(theText) || cumtSA.test(theText) || cukmSA.test(theText) || cucmSA.test(theText) || cumiSA.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Manual of Style (dates and numbers)#Units of measurement|Wikipedia:Manual of Style (numbers)]], when doing conversions, please use standard abbreviations: for example, miles -> mi, kilometers squared -> km<sup>2</sup>, and pounds -> lb."
}
 
//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<sup>2<\/sup>\s/gi
sqftSN = /ft<sup>2<\/sup>\s/gi
sqmtSN = /m<sup>2<\/sup>\s/gi
sqkmSN = /km<sup>2<\/sup>\s/gi
sqcmSN = /cm<sup>2<\/sup>\s/gi
sqmiSN = /mi<sup>2<\/sup>\s/gi
 
//volume
cuinSN = /in<sup>3<\/sup>\s/gi
cuftSN = /ft<sup>3<\/sup>\s/gi
cumtSN = /mt<sup>3<\/sup>\s/gi
cukmSN = /km<sup>3<\/sup>\s/gi
cucmSN = /cm<sup>3<\/sup>\s/gi
cumiSN = /mi<sup>3<\/sup>\s/gi
 
if(kmSN.test(theText) || miSN.test(theText) || ftSN.test(theText) || ydSN.test(theText) || cmSN.test(theText) || nmSN.test(theText) || dmSN.test(theText) || lbSN.test(theText) || gramSN.test(theText) || kgSN.test(theText) || sqinSN.test(theText) || sqftSN.test(theText) || sqmtSN.test(theText) || sqkmSN.test(theText) || sqcmSN.test(theText) || sqmiSN.test(theText) || cuinSN.test(theText) || cuftSN.test(theText) || cumtSN.test(theText) || cukmSN.test(theText) || cucmSN.test(theText) || cumiSN.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Manual of Style (dates and numbers)#Units of measurement|Wikipedia:Manual of Style (numbers)]], please spell out source units of measurements in text; for example, ''"the Moon is 380,000 kilometres (240,000 mi) from Earth''.<ref name="spellnum">See footnote</ref>"
}
 
//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(theText) || miSN2.test(theText) || ftSN2.test(theText) || ydSN2.test(theText) || cmSN2.test(theText) || nmSN2.test(theText) || inchSN2.test(theText) || dmSN2.test(theText) || lbSN2.test(theText) || gramSN2.test(theText) || kgSN2.test(theText)){
document.theForm.theResponse.value+="\n*When writing standard abbreviations, the abbreviations should not have a 's' to demark plurality (change kms to km and lbs to lb)."
}
 
/*
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<sup>2<\/sup>|squared inches)[^\}\s][^\(]/gi
sqft2 = /\d(\s|)(ft<sup>2<\/sup>|squared feet)[^\}\s][^\(]/gi
sqmt2 = /\d(\s|)(m<sup>2<\/sup>|squared meter)[^\}\s][^\(]/gi
sqkm2 = /\d(\s|)(km<sup>2<\/sup>|squared kilo)[^\}\s][^\(]/gi
sqcm2 = /\d(\s|)(cm<sup>2<\/sup>|squared centi)[^\}\s][^\(]/gi
sqmi2 = /\d(\s|)(mi<sup>2<\/sup>|squared mile)[^\}\s][^\(]/gi
 
//volume
cuin2 = /\d(\s|)(in<sup>3<\/sup>|cubic inch)[^\}\s][^\(]/gi
cuft2 = /\d(\s|)(ft<sup>3<\/sup>|cubic feet)[^\}\s][^\(]/gi
cumt2 = /\d(\s|)(m<sup>3<\/sup>|cubic meter)[^\}\s][^\(]/gi
cukm2 = /\d(\s|)(km<sup>3<\/sup>|cubic kilo)[^\}\s][^\(]/gi
cucm2 = /\d(\s|)(cm<sup>3<\/sup>|cubic centi)[^\}\s][^\(]/gi
cumi2 = /\d(\s|)(mi<sup>3<\/sup>|cubic mile)[^\}\s][^\(]/gi
 
if(km2.test(theText) || mi2.test(theText) || ft2.test(theText) || yd2.test(theText) || cm2.test(theText) || nm2.test(theText) || inch2.test(theText) || dm2.test(theText) || lb2.test(theText) || ton2.test(theText) || gram2.test(theText) || mton2.test(theText) || sqin2.test(theText) || sqft2.test(theText) || sqmt2.test(theText) || sqkm2.test(theText) || sqcm2.test(theText) || sqmi2.test(theText) || cuin2.test(theText) || cuft2.test(theText) || cumt2.test(theText) || cukm2.test(theText) || cucm2.test(theText) || cumi2.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[WP:MOSNUM]], at [[WP:MOSNUM#Units of measurement|Units of measurement]], numbers with [[SI units]] of measure should have conversions in [[US customary units]] and vice versa. These conversions should keep to similar values of precision. For example, "the Moon is 380,000&nbsp;kilometres (240,000&nbsp;mi) from Earth". Note that the converted unit of measure uses a standard abbreviation, while the source unit is spelled out in the text."
}
*/
 
//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(theText) || feb2.test(theText) || mar2.test(theText) || apr2.test(theText) || may2.test(theText) || jun2.test(theText) || jul2.test(theText) || aug2.test(theText) || sep2.test(theText) || oct2.test(theText) || nov2.test(theText) || dec2.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Only make links that are relevant to the context|Wikipedia:Context]] and [[Wikipedia:Build the web]], years with full dates should be linked; for example, link {{{1|[[January 15]], [[2006]]}}}.<ref name="linkdate">See footnote</ref>"
}
 
//date-th
dateth = /(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)(th|st|nd|rd)/gi
dateth1 = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\](th|st|nd|rd)/gi
dateth2 = /(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)<sup>(th|st|nd|rd)<\/sup>/gi
dateth2 = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\]<sup>(th|st|nd|rd)<\/sup>/gi
dateth3 = /\d(\d|)<sup>(th|st|nd|rd)<\/sup>\s(of\s|)(january|february|march|april|may|june|july|august|september|october|november|december)/gi
dateth4 = /\d(\d|)(th|st|nd|rd)\s(january|february|march|april|may|june|july|august|september|october|november|december)/gi
 
if(dateth.test(theText) || dateth1.test(theText) || dateth2.test(theText) || dateth3.test(theText) || dateth4.test(theText)){
document.theForm.theResponse.value+="\n
*As per [[Wikipedia:Manual of Style (dates and numbers)|Wikipedia:Manual of Style (dates)]], dates shouldn't use <sup>th</sup>; for example, instead of using ''[[January 30|January 30<sup>th</sup>]] was a great day'', use ''[[January 30]] was a great day''."	
}
 
//checks for correct MOS heading styles
//occurence of "the" at beginning
if(theText.indexOf("==The ")!= -1 || theText.indexOf("== The ")!= -1) document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Manual of Style (headings)]], headings generally do not start with the word "The". For example, ''<nowiki>==The Biography==</nowiki>'' would be changed to ''<nowiki>==Biography==</nowiki>''."
 
//existence of link in heading
headinglink1 = /==.{0,}\[\[.{1,}\]\].{0,}==/gi
if(headinglink1.test(theText)){
document.theForm.theResponse.value+="\n
*As per [[Wikipedia:Manual of Style (headings)]], please do not [[WP:LINK|link]] words in headings."
}
 
//sets variable thePRTitle equal to the title of the article
thePRTitle = document.location.href.substring(42,document.location.href.length-12)
thePRTitle = thePRTitle.replace(/_/g," ")
 
//checks if title is repeated in headings
 
var regHeadingRe = new RegExp("==.{0,}"+thePRTitle+".{0,}==","gi")
if(regHeadingRe.test(theText)){
document.theForm.theResponse.value+="\n
*Per [[Wikipedia:Manual of Style (headings)]], headings generally should not repeat the title of the article. For example, if the article was [[Ferdinand Magellan]], instead of using the heading ''<nowiki>==Magellan's journey==</nowiki>'', use ''<nowiki>==Journey==</nowiki>''."
}
 
//looks for ==trivia==, ==other facts==, ==miscellaneous==, etc.
triv = /==(\s|)Trivia==/gi
triv2 = /==(\s|)Other f/gi
triv3 = /==(\s|)Miscellaneous/gi
triv4 = /==(\s|)Interesting/gi
if(triv.test(theText) || triv2.test(theText) || triv3.test(theText) || triv4.test(theText)){
document.theForm.theResponse.value+="\n
*Generally, trivia sections are looked down upon; please either remove the trivia section or incorporate any important facts into the rest of the article."
}
 
//double checks if last sections follow WP:GTL in terms of order (see also - references - external links)
 
isgtl = true 
 
seealso = "==See also"
extlink = "External link"
 
var Refsection = new Array()
Refsection[0] = "==Reference"
Refsection[1] = "==Source"
Refsection[2] = "==Footnote"
Refsection[3] = "==Cit"
Refsection[4] = "==Note"
 
Refsection[5] = "==Reference"
Refsection[6] = "==Source"
Refsection[7] = "==Footnote"
Refsection[8] = "==Cit"
Refsection[9] = "==Note"
 
Refsection[10] = "== Reference"
Refsection[11] = "== Source"
Refsection[12] = "== Footnote"
Refsection[13] = "== Cit"
Refsection[14] = "== Note"
 
Refsection[15] = "== Reference"
Refsection[16] = "== Source"
Refsection[17] = "== Footnote"
Refsection[18] = "== Cit"
Refsection[19] = "== Note"
 
if(theText.indexOf(seealso)==-1){
if(theText.indexOf("== See also")!=-1){
seealso = "== See also"
} 
}
 
if((theText.indexOf(seealso)>theText.indexOf(extlink)) && (theText.indexOf(extlink)!=-1)){
isgtl = false
}
for(i=0;i<Refsection.length;i++){
if((theText.indexOf(seealso)>theText.indexOf(Refsection[i])) && (theText.indexOf(Refsection[i])!=-1)){
isgtl = false
}
if((theText.indexOf(extlink)<theText.indexOf(Refsection[i])) && (theText.indexOf(extlink)!=-1)){
isgtl = false
}
}
 
if(isgtl==false){
document.theForm.theResponse.value+="\n
*Please reorder/rename the last few sections to follow guidelines at [[Wikipedia:Guide to layout]]. {{{1|}}}"
}
 
//looks for section named "List of..."
list = /==(\s|)List/gi
if(list.test(theText)){
document.theForm.theResponse.value+="\n
*This article may be a bit list-weighty; in other words, some of the lists should be converted to prose (paragraph form). {{#if:{{{1|}}}|For example, see "{{{1}}}".}}<ref name="list">See footnote</ref>"
}
 
//Checks if categories are in alphabetical order
cat1 = /\[\[Category:.{1,}\]\]/gi
alphed = true
if(cat1.test(theText)){
theCats = theText.match(cat1)
//moves categories to lower case
for(i=0;i<theCats.length;i++){
theCats[i]=theCats[i].toLowerCase()
}
//compares all cats to see if in alphabetical order
for(i=0;i<theCats.length-1;i++){
if(theCats[i+1]>theCats[i]){}
else{
alphed = false
}
}
}
else{
document.theForm.theResponse.value+="\n*This article does not have any [[WP:CAT|categories]]. Please categorize it with relevant <code><nowiki>[[Category:Categories]]</nowiki></code>."
}
 
alphed2 = true
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
 
if(il1.test(theText)){
theIL = theText.match(il1)
for(i=0;i<theIL.length-1;i++){
if(theIL[i+1]>theIL[i]){}
else{
alphed2 = false
}
}
}
 
if((!alphed)&&(alphed2)){
//document.theForm.theResponse.value+="\n
*Please alphabetize the [[WP:CAT|categories]].<ref name="alpha">See footnote</ref>"
}
if((!alphed2)&&(alphed)){
document.theForm.theResponse.value+="\n
*Please alphabetize the [[WP:IL|interlanguage links]].<ref name="alpha">See footnote</ref>"
}
if((!alphed)&&(!alphed2)){
document.theForm.theResponse.value+="\n
*Please alphabetize the {{{1|[[WP:IL|interlanguage links]]}}}.<ref name="alpha">See footnote</ref>"
}
 
//looks at length of article:
//summary style -ToC and entire article-
theLength = theText.length
newHeading = /\n==/g
if(newHeading.test(theText)){
theSections = document.editform.wpTextbox1.value.match(/\n==/g)
if(theSections.length<=5){
document.theForm.theResponse.value+="\n
*This article is a bit too short, and therefore may not be as comprehensive as [[WP:WIAFA]] critera 2(b) is looking for. Please see if anything can be expanded upon. {{{1|}}}"
}
if(theSections.length>=24){
document.theForm.theResponse.value+="\n
*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 [[Wikipedia:Summary style]].<ref name="toc">See footnote</ref>"
}
 
if((theLength<=7500)&&(theSections.length>5)){
document.theForm.theResponse.value+="\n
*This article is a bit too short, and therefore may not be as comprehensive as [[WP:WIAFA]] critera 2(b) is looking for. Please see if anything can be expanded upon. {{{1|}}}"
}
}
else{
theSections = "none"
}
 
if((theLength<=7500)&&(theSections=="none")){
document.theForm.theResponse.value+="\n
*This article is a bit too short, and therefore may not be as comprehensive as [[WP:WIAFA]] critera 2(b) is looking for. Please see if anything can be expanded upon. {{{1|}}}"
}
 
if(theLength>=50000){
document.theForm.theResponse.value+="\n
*{{#if:{{{1|}}}|At {{{1}}}kb, this|This}} article may need to undergo [[WP:SS|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. {{{2|}}}"
}
awtstring = ""
 
//looks for section-stub template
//Template:sectstub, section stub, section-stub, sect-stub, stub-section
nosectstub = true
var tempsectstub = new Array()
tempsectstub[0] = /\{\{sectstub\}\}/gi
tempsectstub[1] = /\{\{sect-stub\}\}/gi
tempsectstub[2] = /\{\{section stub\}\}/gi
tempsectstub[3] = /\{\{section-stub\}\}/gi
tempsectstub[4] = /\{\{stub-section\}\}/gi
for(s=0;s<tempsectstub.length;s++){
if(tempsectstub[s].test(theText)){
nosectstub = false
}
}
 
if(nosectstub==false){
document.theForm.theResponse.value+="\n
*There are a few sections that are too short and that should be either expanded or merged. {{#if:{{{1|}}}|For example, {{{1}}}}}{{#if:{{{2|}}}|, {{{2}}}}}{{#if:{{{3|}}}|, {{{3}}}}}{{#if:{{{4|}}}|, {{{4}}}}}{{#if:{{{5|}}}|, {{{5}}}}}{{#if:{{{6|}}}|, and {{{6}}}}} {{#if:{{{1|}}}|is/are a bit short.}}"
}
 
//looks for weasel words
var ww = new Array()
isww = false
ww[0] = /some people sa/gi
ww[1] = /it has been/gi
ww[2] = /many people have/gi
ww[3] = /many scientists believe/gi
ww[4] = /allege/gi
ww[5] = /many people sa/gi
ww[6] = /many people believe/gi
ww[7] = /arguably/gi
ww[8] = /it is claimed/gi
ww[9] = /correctly/gi
ww[10] = /apparently/gi
ww[11] = /people considered/gi
ww[12] = /many considered/gi
ww[13] = /is considered/gi
ww[14] = /are considered/gi
 
var ww2 = new Array()
ww2[0] = "some people sa"
ww2[1] = "it has been"
ww2[2] = "many people have"
ww2[3] = "many scientists believe"
ww2[4] = "allege"
ww2[5] = "many people sa"
ww2[6] = "many people believe"
ww2[7] = "arguably"
ww2[8] = "it is claimed"
ww2[9] = "correctly"
ww2[10] = "apparently"
ww2[11] = "people considered"
ww2[12] = "many considered"
ww2[13] = "is considered"
ww2[14] = "are considered"
 
Ref = /\<ref/gi
Refa = /<ref/gi
Ref2 = /\{\{ref/gi
Ref3 = /\{\{fn/gi
Ref4 = /\{\{harv/gi
Ref5 = /\{\{Harv/gi
 
theTextawt = theText;
 
for(i=0;i<ww.length;i++){
	while(ww[i].test(theTextawt)){
		theTextawt = theTextawt.substring(theTextawt.indexOf(ww[i]),theTextawt.length);
		if(!(Ref.test(theTextawt.substring(0,100)) || Ref.test(theTextawt.substring(0,100)) || Ref.test(theTextawt.substring(0,100)) || Ref.test(theTextawt.substring(0,100)) || Ref.test(theTextawt.substring(0,100)))){
			isww = true;
			if(awtstring.indexOf(ww2[i]) == -1) awtstring=awtstring+"|''"+ww2[i]+"''"
		}
	}
}
 
if(isww==true){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/awt"+awtstring+"}} <!--This javascript cannot determine if a citation is provided; if all weasel terms are covered by citations, please strike this-->"
}
 
//checks for redundancies - based on [[User:Tony1/How_to_satisfy_Criterion_2a#Redundancy]]
 
redun1 = new Array()
redun1[0] = ""
redun1[1] = ""
redun1[2] = ""
redun1[3] = ""
 
additive = /(also|in\saddition|additionally|moreover|furthermore)/gi
if(additive.test(theText)){
theaddnum = theText.match(additive)
if((theaddnum.length>=8)&&(theaddnum.length>=theText.length/2500)){
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(theText)){
thevsnum = theText.match(vaguesize)
if((thevsnum.length>=8)&&(thevsnum.length>=theText.length/2500)){
redun1[1] = "1"	
}
}
 
temporal = /(over\sthe\syears|currently|\snow\s|from\stime\sto\stime)/gi
if(temporal.test(theText)){
thetempnum = theText.match(temporal)
if(thetempnum.length>=5){
redun1[2] = "1"	
}
}
 
intheyear = /(in\sthe\syear|in\sthe\syear\sof)\s(\[\[|)(\d\d\d\d)/gi
if(intheyear.test(theText)){
//exyear = RegExp.$3
redun1[3] = "1"		
}
 
if((redun1[0]=="1") || (redun1[1]=="1") || (redun1[2]=="1") || (redun1[3]=="1")){
document.theForm.theResponse.value+="\n*Watch for [[User:Tony1/How_to_satisfy_Criterion_2a#Redundancy|redundancies]] that make the article too wordy instead of being crisp and concise. (You may wish to try Tony1's [[User:Tony1/How to satisfy Criterion 2a: redundancy exercises|redundancy exercises]].)"	
 
if(redun1[0]=="1"){
	document.theForm.theResponse.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.theForm.theResponse.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'><s>All</s></font> pigs are pink, so we thought of <font color='red'><s>a number of</s></font> ways to turn them green.”"
}
if(redun1[2]=="1"){
	document.theForm.theResponse.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'><s>now</s></font> using a semi-bot to generate your peer review.”"
}
if(redun1[3]=="1"){
	document.theForm.theResponse.value+="\n**“In <font color='red'><s>the year [of]</s></font> 1990”"
}
}
 
//searches for footnotes
Ref = /\<ref/gi
Refa = /<ref/gi
Ref2 = /\{\{ref/gi
Ref3 = /\{\{fn/gi
Ref4 = /\{\{harv/gi
Ref5 = /\{\{Harv/gi
if(Ref.test(theText)||Refa.test(theText)){
references="1"
}
else if(Ref2.test(theText) || Ref3.test(theText) || Ref4.test(theText) || Ref5.test(theText)){
references="2"
}
else{
references="0"
}
if(references=="0"){
document.theForm.theResponse.value+="\n{{#if:{{{1|}}}|*The article has a few or too many inline external links, which hamper the readibility of the article. Please convert them to [[WP:FOOTNOTE|footnotes]], preferably in the [http://meta.wikimedia.org/wiki/Cite/Cite.php cite.php] format recommended by [[WP:WIAFA]].|*This article needs [[WP:FOOTNOTE|footnotes]], preferably in the [http://meta.wikimedia.org/wiki/Cite/Cite.php cite.php] format recommended by [[WP:WIAFA]]. Simply, enclose inline citations, with [[WP:CITE]] or [[WP:CITE/ES]] information, with <nowiki><ref>THE FOOTNOTE</ref></nowiki>. At the bottom of the article, in a section named “References” or “Footnotes”, add <code><nowiki><div class="references-small"><references/></div></nowiki></code>.}}<ref name="foot">See footnote</ref>"
}
else if(references=="2"){
document.theForm.theResponse.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 spacing
sRefa = /<\/ref>\./gi
sRefb = /\.\s<ref>/gi
sRef2a = /\{\{ref\|.{1,}\}\}\./gi
sRef2b = /\.\s\{\{ref\|.{1,}\}\}/gi
sRef3a = /\.\s\{\{fn\|.{1,}\}\}/gi
sRef3b = /\{\{fn\|.{1,}\}\}\./gi
 
if(sRefa.test(theText) || sRefb.test(theText) || sRef2a.test(theText) || sRef2b.test(theText) || sRef3a.test(theText) || sRef3b.test(theText)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/footspace}}"
}
 
//searches for reference section
Refsect = /==(\s|)Reference/gi
Refsect2 = /==(\s|)Source/gi
Refsect3 = /==(\s|)Footnote/gi
Refsect4 = /==(\s|)Cit/gi
Refsect5 = /==(\s|)Note/gi
if(Refsect.test(theText) || Refsect2.test(theText) || Refsect3.test(theText) || Refsect4.test(theText) || Refsect5.test(theText)){}
else{
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/ref}}"
}
 
fact = /\{\{fact\}\}/gi
fact2 = /\{\{citation needed\}\}/gi
 
if(fact.test(theText) || fact2.test(theText)){
	document.theForm.theResponse.value += "\n*Please provide citations for all of the <code><nowiki>{{fact}}</nowiki></code>s.";
}
 
//all articles can always use copyediting:
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/copyedit}}"
 
//closing + signature
document.theForm.theResponse.value+="\nYou may wish to browse through [[User:AndyZ/Suggestions]] for further ideas. Thanks, ~~~~\n\n\n"
 
//<nowiki>format: 
//txt = txt.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/}}","g"),"{{subst:User:AndyZ/PR/}}"); </nowiki>
 
document.theForm.theResponse.value = document.theForm.theResponse.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.theForm.theResponse.value = document.theForm.theResponse.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.theForm.theResponse.value = document.theForm.theResponse.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.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/infobox}}","g"),"*There may be an applicable [[WP:INFOBOX|infobox]] for this article. For example, see [[Template:Infobox Biography]], [[Template:Infobox School]], or [[Template:Infobox City]].");
document.theForm.theResponse.value = document.theForm.theResponse.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 [[WP:CONTEXT|context]] for the article.");
document.theForm.theResponse.value = document.theForm.theResponse.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.");
 
//show feedback
document.getElementById("theFeedback").style.visibility = "visible"
//if(!doSelect) doSelect = false;
//if(doSelect) document.theForm.theResponse.select();
 
//<nowiki>
if((theTitle.indexOf("Wikipedia:Peer review")!=-1)&&(document.location.href.indexOf("Automated")==-1)&&(document.editform.wpTextbox1.value.indexOf("*Please see [[User:AndyZ/peerreviewer.js|automated]] peer review")==-1)&&(automsg)){
document.editform.wpTextbox1.value += "\n*Please see [[User:AndyZ/peerreviewer.js|automated]] peer review suggestions [[Wikipedia:Peer review/Automated#"+theTitle2.substring(22,theTitle2.length)+"|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:PR/A#"+theTitle2.substring(22,theTitle2.length)+"]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
 
thehide();
}
//</nowiki>
 
PRheader = /\{\{PR\-/gi
theArchive = ""
 
//<nowiki> - archiving of [[WP:PR/A|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.theForm.theResponse.value)){
		thePRarticle = theText.match(/===\[\[(.{1,})\]\]===/gi)
		for(i=0;i<thePRarticle.length;i++){
			if(document.theForm.theResponse.value.indexOf(thePRarticle[i].substring(5,thePRarticle[i].length-5))==-1){
				loc1 = theText.indexOf(thePRarticle[i])
				theText2 = theText.substring(loc1+5,theText.length)
				loc2 = ((theText2.indexOf("===[[") < theText2.indexOf("==Requests")) || (theText2.indexOf("==Requests")==-1)) ? theText2.indexOf("===[[") : theText2.indexOf("==Requests")
				theArchive+="\n===[["
				theArchive+=theText2.substring(0,loc2)
				document.editform.wpTextbox1.value = theText.substring(0,loc1) + theText2.substring(loc2,theText2.length)
 				theText = document.editform.wpTextbox1.value
			}
	}
	document.theForm.theResponse.value = theArchive
 
	// Add a tag to the summary box - ''stolen'' from [[User:Bobblewik]] 
    var txt = document.editform.wpSummary;
    var summary = "JS - [[Wikipedia:Peer review/Automated/Archive 1|archiving]] closed [[WP:PR|peer reviews]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
}			
}
 
 
//</nowiki>
 
//ending brace for first function
}
//
 
//
/* ////////////////////////////////////////////////Not working as of now//////////////////////////////////////
function imgtest(){
//checks image status
img = /\[\[image\:.{1,}(\||\])/gi
 
notag=""
futag=""
alltagged = true
allfurat = true
 
if(img.test(theText)){
var imglist = theText.match(img)	
 
for(i=0;i<imglist.length;i++){
imglist[i] = imglist[i].substring(2,imglist[i].length-2)	
imglist[i] = imglist[i].replace(/\s/g,"_")
}
 
for(i=0;i<imglist.length;i++){
imgWin = window.open(document.location.href,"Images")
imgWin.document.write("<html><frameset rows='100%,*'><frame src='http://en.wikipedia.org/w/index.php?title="+imglist[i]+"&action=edit' name='theImgWin'><frame src='about:blank' name='blank'></frameset></html>")
x=0
while(x<10000){
if(imgWin.theImgWin.document.editform.wpTextbox1.value){
imgtest2()
break;
}
x++
}
}
 
if(alltagged==false){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/imgtag"+notag+"}}"
}
 
if(allfurat==false){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/imgfu"+futag+"}}"	
}
}
 
function imgtest2(){
theImgText = imgWin.theImgWin.document.editform.wpTextbox1.value
if(theImgText!=null){alert("finally")}
 
templ1 = /\{\{/gi
templPD = /\{\{PD\}\}/gi
if(templ1.test(theImgText)){
	if(templPD.test(theImgText)){
           alltagged = false      
	       notag=notag+"|"+imglist[i]
	}	
}
else{
alltagged = false
notag=notag+"|"+imglist[i]
}
 
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|screenshot|screen|art|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)/gi
FUrat = /rationale/gi
 
if((templFU.test(theImgText))&&(!FUrat.test(theImgText))){
	allfurat = false
futag=futag+"|"+imglist[i]
}
 
imgWin.close()
 
}
}
*/
 
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"
}
 
document.write('<div id="theFeedback" style="position:absolute; margin-top:150px; margin-left:40px; border:2px solid #000000; background:55ff55; visibility:hidden; z-index:20"><div id="close" style="background:red; text-align:right" onclick="thehide()">[ X ]</div><form name="theForm"><textarea cols="50" rows="20" name="theResponse">The following suggestions were generated by a semi-automatic [[User:AndyZ/peerreviewer.js|javascript program]], and might not be applicable for the article in question.</textarea></form></div>'
+'<div id="restore" style="z-index:19; background:yellow; margin-top:120px; visibility:hidden; position:absolute; margin-left:5px" onclick="theshow()">[restore]</div>')
 
// Script from [[User:Omegatron/monobook.js/addlink.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Omegatron/monobook.js/addlink.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//adds peer review link to top bar (with your username, talk page, preferences, watchlist, etc.)
addOnloadHook(function () {
    if(document.forms.editform) {
        addLink('p-personal', 'javascript:review1()', 'peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', '', '');
    }
});
 
//these functions auto-submit articles for WP:PR, modified from AutoVFD script 
 
function pr()
{
  var pagename = document.editform.action;
  pagename = pagename.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 = '[[Wikipedia: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 [[Wikipedia:Peer review/' + wgTitle.split("/")[1] + ' 2]]).');
            }
          else
            document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' +
              '<!--Reason for nomination.--> ~~' + '~~';
        }
      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 - [[Wikipedia:Peer review/' + target + ']]';
            }
        }
      else
        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);
}
 
//</pre> end
 
////////////////////////////////////////
/*List of things to do:
 // Determine the usage of commas with dates
 // <s>Determine the length of a lead (number of paragraphs)</s>
 // <s>Figure out if the lead is too short (1 paragraph) or too long (>=4 paragraphs), depending upon size of article</s>
 // <s>Determine if no-break spaces (&nbsp;) are used </s>
 // Determine if conversions are included
 // <s>Determine if standard abbreviations are used for conversions</s>
 // <s>Determine if units are spelled out in text</s>
 // <s>Determine if last few sections (see also, references, notes, external links) follow [[WP:GTL]]</s>
 // Determine if extraneous bolding is used
 // <s>Determine if categories and interlanguage links are alphabetized</s>
 // Determine if quotes have sources
 // Prove that images have proper image copyright tags
 // Show that all fair use images have proper fair use rationales
 // <s>Determine if all images have captions</s>
 // <s>Find out the number of sections</s>
 // Determine if sections or paragraphs are too short 
 // Determine if a list is used
 // <s>Determine if footnote spacing standards are used (as in [[WP:FOOTNOTE]])</s>
 // Determine if words in headings are capitalized
 // Find common [[User:Tony1/How to satisfy Criterion 2a|redunancies]]
 // <s>Time/future issues</s>
 // Check w/ U:SUGG to see if any other things are missing
 // Automatic archiving
 // Improving efficiency
 
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...
*/
 
 
//Auto AFD script
 
//Please include the two following lines
//Modified version of AutoVFD script to work with AFD
//Script Modified by User:Jtkiefer
//Further modified to work with [[WP:AFDC]] by [[User:ais523]]
 
 
// This needs to change depending on skin used.
function add_link(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));
 
  var li = document.createElement('li');
  li.appendChild(na);
 
  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
  tabs.appendChild(li);
}
 
function strip_namespace(target)
{
  var colon = target.indexOf(':');
  if (colon != -1)
    {
      var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
      var ns = target.substring(0, colon);
      if (ns == '' || ns == 'Talk')
        return target.substring(colon + 1);
      else
        for (var i = 0; i < spaces.length; ++i)
          {
            if (ns == spaces[i]
                || ns == spaces[i] + '_talk')
              return target.substring(colon + 1);
          }
    }
 
  return target;
}
 
function afd()
{
  document.editform.wpTextbox1.value = '{{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'afd';
 
  var target = document.editform.action;
  target = target.substring(target.indexOf('title=') + 6,
                            target.lastIndexOf('&action=submit'));
 
  var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var date = new Date();
  date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate();
 
  var pagename = strip_namespace(target);
 
  window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target,
              'Afd ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
  window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename,
              'AfdLog ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}
 
function autoafd()
{
  if (document.title.indexOf('Editing ') == 0)
    {
      var action = '';
      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')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
            }
        }
 
      if (action == 'afdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'Wikipedia:Articles for deletion/' + target + '}}\n';
          document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]';
        }
      else if (action == 'afdsub')
        {
          if (document.editform.wpTextbox1.value.length > 0)
            {
              target = document.editform.action;
              target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' ');
              window.alert("There's an old afd at the default location already.\n\n" +
                           'Please either move it out of the way (and update existing links to it), or file the Afd by hand in another location (such as [[' + target + ' (2)]]).');
            }
          else
            document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' +
              '{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|>>add cat here<<}}\n'+
              'Reason for nomination. ~~' + '~~\n*\n*\n*\n';
        }
      else
        add_link('javascript:afd()', 'Afd');
    }
}
 
addOnloadHook(autoafd);
 
//
 
//<pre><nowiki>
 function aivlist(type) {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  var ip = prompt("Enter IP address", "");
  var reason = prompt("Enter reason for listing", "");
  t.value += "*{{" + type + "|" + ip +"}} " + reason + "--~" + "~" + "~" + "~";
  f.wpSummary.value = "Listing " + ip;
  f.submit();
 }
 
addOnloadHook(
 function addaivlink() { 
  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism") != -1)
  {
    addTab("javascript:aivlist('vandal')", "vandal", "ca-vandal", "Report a vandal", "");
    addTab("javascript:aivlist('ipvandal')", "ipvandal", "ca-ipvandal", "Report an ipvandal", "");
  } }
);
//</nowiki></pre>
 
/**** afd helper ****/
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
  'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */
//</nowiki>