Szerkesztő:Bdamokos/peer-review.js
Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.
- Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
- Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
- Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
//[[:en:User talk:AndyZ/peer-review.js]] <pre>
/*
// User:Bdamokos/Teszt --> Wikipédia:Referálás az éles változatban !!!!!!!!!
//Semi-automatic javascript peer reviewer
// note that this is NOT a [[WP:BOT]]
// (though it may be considered a [[WP:SBOTS|semi-bot]])
/////////////////////////////////////////////
// See talk page for details //
// //
// Quick installation - //
// Add to your monobook.js: //
// {{subst:js|User:Bdamokos/peer-review.js}} //
// //
// Written by AndyZ //
/////////////////////////////////////////////
*/
// start code
////// addlink script, from User:Omegatron
// Script from [[User:Omegatron/monobook.js/addlink.js]]
document.write('<script type="text/javascript" src="'
+ 'http://en.wiki.x.io/w/index.php?title=User:Omegatron/monobook.js/addlink.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/////////////////////////
//configurable options //
/////////////////////////
//details on talk page //
/////////////////////////
//most, if they dont exist, are set to false
////variables for: functionality
//input and output (ids):
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 [[User:Bdamokos/peerreviewer|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:Bdamokos/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;
if(!maintain_PR) maintain_PR = false;
var spellcheck_PR;
if(!spellcheck_PR) spellcheck_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 <span onclick="addToPage()">move to</span> soon
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="topBar" style="background:'+topBarColor_PR+'; text-align:right"><span onclick="popreview();">new window</span> | <span onclick="thehide()">close</span></div><form name="theForm"><textarea cols="50" rows="20" name="theResponse" id="theResponse">'+initMsg_PR+'</textarea>'+
'<div style="background:'+botBarColor_PR+'"><input type="button" value="Template form" name="switch_temp" onclick="determineReplace();" style="width:150"> <input type="button" value="Add footnotes" name="switch_foot" onclick="determineFoot();" style="width:150"> <a href="http://hu.wiki.x.io/wiki/User vita:Bdamokos/peer-review.js" target="_blank">Questions/comments/errors?</a><br></div>'
+'</form></div>'
+'<div id="restore" style="z-index:19; visibility:hidden;'+restoreStyle_PR+'" onclick="theshow()">'+restoreText_PR+'</div>')
}
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://up.wiki.x.io/wikipedia/en/a/a9/AZbutton_PR.PNG
addOnloadHook(function () {
alert("creating button");
//document.getElementById('toolbar').innerHTML = document.getElementById('toolbar').innerHTML + "<a href='javascript:review1();'><img src='http://up.wiki.x.io/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://up.wiki.x.io/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 (somewhat similar to wgPageName and wgTitle, but not exactly)
theTitle = document.location.href;
if(theTitle.indexOf("section=")!=-1) theTitle = document.location.href.substring(42,document.location.href.length-22);
else if(theTitle.indexOf("fakeaction") != -1) theTitle = document.location.href.substring(42,document.location.href.length-33);
else theTitle = document.location.href.substring(42,document.location.href.length-12);
//alternative: if(wgNamespaceNumber == 0 || document.location.href.indexOf("fakeaction=")!=-1) theTitle = wgTitle;
theTitle2 = theTitle.replace(/\_/gi," ")
theTitle = unescape(theTitle).replace(/\_/gi," ")
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)
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{{subst:User:Bdamokos/PR/lead}}"
if((theNumPara==2) && (theLength>=30000))
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/lead}}"
if((theNumPara==3) && (theLength<=15000))
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/leadlong}}"
if((theNumPara==4) && (theLength<=30000))
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/leadlong}}"
if(theNumPara>=5){
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/leadlong}}"
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/leaddetail}}"
}
// --------------------
//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{{subst:User:Bdamokos/PR/underlink}}";
else if(.1* words.length <= links.length)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/overlink}}";
// --------------------
//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(/\[\[hétfő\]\]/gi,/\[\[kedd\]\]/gi,/\[\[szerda\]\]/gi, /\[\[csütörtök\]\]/gi,/\[\[péntek\]\]/gi,/\[\[szombat\]\]/gi,/\[\[vasárnap\]\]/gi);
//array for months
var list_month = new Array(/\[\[január\]\]/gi,/\[\[február\]\]/gi,/\[\[március\]\]/gi,/\[\[április\]\]/gi,/\[\[május\]\]/gi,/\[\[június\]\]/gi,/\[\[július\]\]/gi,/\[\[augusztus\]\]/gi,/\[\[szeptember\]\]/gi,/\[\[október\]\]/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{{subst:User:Bdamokos/PR/contxt}}"
// --------------------
//about [[WP:MOS#Time]]
// --------------------
// 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{{subst:User:Bdamokos/PR/time"+mostimestring+"}}"
// --------------------
//searches for images
// --------------------
regex_img = /\[\[Kép:/gi
if(!regex_img.test(wpTxt)) document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/noimg}}"
//sees if lead image exists (may not be accurate if template is at front
if(!((wpTxt.substring(0,100).indexOf("[[Kép")!=-1)||(wpTxt.substring(0,100).indexOf("[[kép")!=-1)||(wpTxt.substring(0,2)=="{{")||(wpTxt.substring(0,2)=="<!")||(wpTxt.substring(0,3)==":''"))){
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/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-->"
}
// --------------------
//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:Bdamokos/PR/caption}}";
// --------------------
// image licensing: as of now, cannot check licensing of WikiMedia Commons images
// assumes images on commons are properly sourced
// --------------------
var imgCode = /\[\[kép:(.+?)(\||\])/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(/\[\[kép:(.+?)(\||\])/gi,"Kép:$1");
try{
wpajax.download({url:'http://hu.wiki.x.io/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:Bdamokos/PR/imgtag"+imgNTstr+"}} <!--Listed images do not have licensing information-->";
if(imgFU) document.getElementById(output_PR).value += "\n{{subst:User:Bdamokos/PR/imgfu"+imgFUstr+"}} <!--List images are fair use without rationale-->";
}
// --------------------
//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:Bdamokos/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 //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:Bdamokos/PR/persondata}}"
// -------------------- --------------------
//[[WP:MOSNUM]] and [[WP:MOSDATE]]:
// -------------------- --------------------
// NOTE: Following sections need cleanup
// to become easily readable
// -------------------- --------------------
// --------------------
//nbsp checker: distances
// --------------------
km = /\d(\s|)(km|kilométer)/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)/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(wpTxt) || mi.test(wpTxt) || ft.test(wpTxt) || yd.test(wpTxt) || cm.test(wpTxt) || nm.test(wpTxt) || inch.test(wpTxt) || dm.test(wpTxt) || lb.test(wpTxt) || ton.test(wpTxt) || gram.test(wpTxt) || mton.test(wpTxt) || sqin.test(wpTxt) || sqft.test(wpTxt) || sqmt.test(wpTxt) || sqkm.test(wpTxt) || sqcm.test(wpTxt) || sqmi.test(wpTxt) || cuin.test(wpTxt) || cuft.test(wpTxt) || cumt.test(wpTxt) || cukm.test(wpTxt) || cucm.test(wpTxt) || cumi.test(wpTxt)){
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/nbsp}}"
}
// --------------------
//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:Bdamokos/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<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(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:Bdamokos/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<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(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{{subst:User:Bdamokos/PR/convert}}"
}
*/
// --------------------
//looks for unlinked dates
// --------------------
jan2= /\sjanuár\s(\d)(\d|)\D/gi
feb2= /\sfebruár\s(\d)(\d|)\D/gi
mar2= /\smárcius\s(\d)(\d|)\D/gi
apr2= /\sáprilis\s(\d)(\d|)\D/gi
may2= /\smájus\s(\d)(\d|)\D/gi
jun2= /\sjúnius\s(\d)(\d|)\D/gi
jul2= /\sjúlius\s(\d)(\d|)\D/gi
aug2= /\saugusztus\s(\d)(\d|)\D/gi
sep2= /\sszeptember\s(\d)(\d|)\D/gi
oct2= /\soktóber\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{{subst:User:Bdamokos/PR/linkdate}}"
}
// --------------------
// date-th
// --------------------
var dateth = new Array(); var check_th = false;
dateth[0] = /(január|február|március|április|május|június|július|augusztus|szeptember|október|november|december)\s\d(\d|)(th|st|nd|rd)/gi
dateth[1] = /\[\[(január|február|március|április|május|június|július|augusztus|szeptember|október|november|december)\s\d(\d|)\]\](th|st|nd|rd)/gi
dateth[2] = /(január|február|március|április|május|június|július|augusztus|szeptember|október|november|december)\s\d(\d|)<sup>(th|st|nd|rd)<\/sup>/gi
dateth[3] = /\[\[(január|február|március|április|május|június|július|augusztus|szeptember|október|november|december)\s\d(\d|)\]\]<sup>(th|st|nd|rd)<\/sup>/gi
dateth[4] = /\d(\d|)<sup>(th|st|nd|rd)<\/sup>\s(of\s|)(január|február|március|április|május|június|július|augusztus|szeptember|október|november|december)/gi
dateth[5] = /\d(\d|)(th|st|nd|rd)\s(január|február|március|április|május|június|július|augusztus|szeptember|október|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{{subst:User:Bdamokos/PR/dateth}}";
// -------------------- --------------------
//checks for correct MOS heading styles
// -------------------- --------------------
// --------------------
//occurence of "the" at beginning
// --------------------
if(wpTxt.indexOf("==A ")!= -1 || wpTxt.indexOf("== A ")!= -1 || wpTxt.indexOf("==Az ")!= -1 || wpTxt.indexOf("== Az ")!= -1) document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/headingthe}}";
// --------------------
//existence of link in heading
// --------------------
regex_headlink = /==.{0,}\[\[.{1,}\]\].{0,}==/gi
if(regex_headlink.test(wpTxt))
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/headinglink}}";
// --------------------
//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{{subst:User:Bdamokos/PR/headingre}}"
// --------------------
//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{{subst:User:Bdamokos/PR/trivia}}";
// --------------------
//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("Külső hivatkozás","Külső hivatkozások");
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{{subst:User:Bdamokos/PR/gtl}}"
// --------------------
//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{{subst:User:Bdamokos/PR/list}}"
*/
// --------------------
//Checks if categories are in alphabetical order
// --------------------
cat1 = /\[\[Kategória:.{1,}\]\]/gi
alphed = true; alphed2 = true; //first for [[WP:CAT]]s, [[WP:IL]]s
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 [[WP:CAT|categories]]. Please categorize it with relevant <code><nowiki>[[Category:Categories]]</nowiki></code>." //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+="\n{{subst:User:Bdamokos/PR/alpha|[[WP:CAT|categories]]}}"
if(!alphed2 && alphed)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/alpha}}"
if(!alphed && !alphed2 && !cat_PR)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/alpha}}"
if(!alphed && !alphed2 && cat_PR)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/alpha|[[WP:CAT|categories]] and [[WP:IL|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{{subst:User:Bdamokos/PR/expand}}";
if(theSections.length>=24)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/toc}}";
if(theLength <= 7500 && theSections.length>5)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/expand}}";
}
else theSections = "none"
if(theLength<=7500 && theSections=="none")
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/expand}}"
if(theLength>=50000)
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/SS}}"
// --------------------
//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{{subst:User:Bdamokos/PR/sectexpand}}";
// --------------------
//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{{subst:User:Bdamokos/PR/awt"+awtstring+"}} <!--This javascript cannot determine if a citation is provided; if all weasel terms are covered by citations, please strike this-->"
}
// --------------------
// American/British English spellings (ize/ise, ization/isation, or/our, er/re)
var check_amer = false, check_brit = false;
var ab_ex = "";
AmSpell = new Array("color","flavor","honor","armor","behavior","harbor","neighbor","favorite","aluminum","mustache","tidbit","meter","center","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("colour","flavour","honour","armour","behaviour","harbour","neighbour","favourite","aluminium","moustache","titbit","metre","centre","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 = true;
ab_ex += "''" + AmSpell[i] + "'' (A) (British: ''" + BrSpell[i] + "''), ";
}
if(wpTxt.indexOf(BrSpell[i]) != -1 && wgTitle.indexOf(BrSpell[i]) == -1){
check_brit = true;
ab_ex += "''" + BrSpell[i] + "'' (B) (American: ''" + AmSpell[i] + "''), ";
}
}
if(check_amer && check_brit) document.getElementById(output_PR).value += "\n*Please make the spelling of English words consistent with either [[American and British English spelling differences|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 [[Wikipedia:Lists of common misspellings/For machines]]
// --------------------
if(!noXHR_PR && spellcheck_PR && wgTitle.indexOf("Peer review") == -1){
wpajax.download({url:'http://en.wiki.x.io/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#Redundancy]]
// --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 [[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.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'><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.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'><s>now</s></font> using a semi-bot to generate your peer review.”"
if(redun1[3]=="1")
document.getElementById(output_PR).value+="\n**“In <font color='red'><s>the year [of]</s></font> 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{{subst:User:Bdamokos/PR/foot}}"
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<ref>/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{{subst:User:Bdamokos/PR/footspace}}"
// --------------------
//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{{subst:User:Bdamokos/PR/ref}}"
// --------------------
// looks for <nowiki>{{fact}} and {{citation needed}} </nowiki>
// --------------------
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 <code><nowiki>{{fact}}</nowiki></code>s.";
//all articles can always use copyediting:
document.getElementById(output_PR).value+="\n{{subst:User:Bdamokos/PR/copyedit}}"
//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");
// --------------------
//<nowiki> Summary on WP:PR/
// --------------------
if((theTitle.indexOf("Wikipedia:Peer review")!=-1 || theTitle.indexOf("Wikipedia:WikiProject Military history/Peer review/")!=-1)&&(document.location.href.indexOf("/Automated")==-1)&&(document.editform.wpTextbox1.value.indexOf("*Please see [[User:Bdamokos/peerreviewer|automated]] peer review")==-1))
{
document.editform.wpTextbox1.value += "\n*Please see [[User:Bdamokos/peerreviewer|automated]] peer review suggestions [[Wikipedia:Peer review/Automated/"+m_full[cur_month]+" "+cur_year+"#"+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:PRA/"+m_abbrev[cur_month]+y_abbrev+"#"+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>
//// NO LONGER NEEDED (but kept here to continue archiving [[WP:PR/A]])
PRheader = /\{\{PR\-/gi
theArchive = ""
//<nowiki> - archiving of [[WP:PR/A|automated peer reviews]]
if(document.location.href=="http://hu.wiki.x.io/w/index.php?title=User:Bdamokos/Teszt&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")) || (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 - [[Wikipedia:Peer review/Automated/Archives|archiving]] closed [[WP:PR|peer reviews]]";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | ";
}
txt.value += summary;
}
}
}
//// END UNNEEDED ARCHIVING CODE
//</nowiki>
// --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://hu.wiki.x.io/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 [[Wikipedia: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 += "*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:Bdamokos/PR]] form
//temp_mem = document.getElementById(output_PR).value;
//<nowiki>format:
//document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/}}","g"),"{{subst:User:Bdamokos/PR/}}");
//</nowiki>
//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:Bdamokos\/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://hu.wiki.x.io/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:Bdamokos/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:Bdamokos/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:Bdamokos/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:Bdamokos/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.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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:Bdamokos/PR/dateth}}","g"),"*As per [[WP:MOSDATE]], 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''.");
//document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/time}}","g"),"*Per [[WP:MOS#Time|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.}}<ref name='time'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/nbsp}}","g"),"*Per [[WP:MOSNUM#Units of measurement|WP:MOSNUM]], there should be a non-breaking space - <code>&nbsp;</code> 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&nbsp;mm</tt>.<ref name='nbsp'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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''.<ref name='spellnum'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/abbrev}}","g"),"*Per [[WP:MOSNUM]], when doing conversions, please use standard abbreviations: for example, miles -> mi, kilometers squared -> km<sup>2</sup>, and pounds -> lb.");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/headingthe}}","g"),"*Per [[WP:MOS#Headings]], headings generally do not start with the word 'The'. For example, ''<nowiki>==The Biography==</nowiki>'' would be changed to ''<nowiki>==Biography==</nowiki>''.");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/headingre}}","g"),"*Per [[WP:MOS#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>''.");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/headinglink}}","g"),"*As per [[WP:MOS#Headings|WP:MOS]], please do not [[WP:LINK|link]] words in headings.");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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:Bdamokos/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:Bdamokos/PR/underlink}}","g"),"*Consider adding more [[WP:LINK|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:Bdamokos/PR/footspace}}","g"),"*As done in [[WP:FOOTNOTE]], footnotes usually are located right after a punctuation mark (as recommended by the [[The Chicago Manual of Style|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:Bdamokos/PR/alpha}}","g"),"*Please alphabetize the [[WP:IL|interlanguage links]].<ref name='alpha'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/alpha|[[WP:CAT|categories]]}}","g"),"*Please alphabetize the [[WP:CAT|categories]].<ref name='alpha'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/alpha|[[WP:CAT|categories]] and [[WP:IL|interlanguage links]]}}","g"),"*Please alphabetize the [[WP:CAT|categories]] and [[WP:IL|interlanguage links]].<ref name='alpha'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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:Bdamokos/PR/foot}}","g"),"*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>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/noimg}}","g"),"*This article has no [[WP:IMAGE|images]]. Please see if there are any [[WP:IT|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-[[WP:FU|fair use]] images on the [[Wikimedia Commons]], go to [[commons:special:upload]].<ref name='noimg'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/leadimg}}","g"),"*See if possible if there is a [[WP:IT|free use]] image that can go on the top right corner of this article.<ref name='leadimg'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/caption}}","g"),"*Per [[WP:WIAFA]], [[WP:IMAGE|Images]] should have concise captions.<ref name='caption'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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]].<ref name='toc'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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:Bdamokos/PR/SS}}","g"),"*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.");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/PR/copyedit}}","g"),"*Please ensure that the article has gone through a thorough copyediting so that it exemplifies some of [[WP:WIAFA|Wikipedia's best work]]. See also [[User:Tony1/How to satisfy Criterion 1a]].<ref name='copyedit'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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).<ref name='list'>See footnote</ref>");
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(new RegExp("{{sub"+"st:User:Bdamokos/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:Bdamokos/PR/persondata}}","g"),"*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.");
//}
//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 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>.*<\/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;
//<nowiki>
document.getElementById(output_PR).value = document.getElementById(output_PR).value.replace(/<ref name='(\w{1,})'>See footnote<\/ref>/gi,"").replace(/<sup>\[\[User:Bdamokos\/PRnotes#_note-(.{1,})\|(.{1,})\]\]<\/sup>/gi,"");
////
// use link to WP:PR/A's footnotes: "<sup>[[User:Bdamokos/PRnotes#_note-$1|$1]]</sup>"
////
//</nowiki>
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>[[User:Bdamokos/PRnotes#_note-$1|$1]]</sup>");
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://hu.wiki.x.io/w/index.php?title=User:Bdamokos/peer-review.js&action=raw&ctype=text/javascript&dontcountme=s'>wgUserName = \"" + wgUserName + "\"; temp_mem = \"" + temp_mem + "\";</script>Return to <a href='http://hu.wiki.x.io/wiki/" + wgPageName + "'>" + wgTitle + "</a> (<a href='http://hu.wiki.x.io/w/index.php?title="+wgPageName+"&action=edit'>edit</a> | <a href='http://hu.wiki.x.io/w/index.php?title="+wgPageName+"&action=history'>history</a>) <br><br><form name='theForm'><!--<input type='button' value='Template form' name='switch_temp' onclick='determineReplace();' style='width:150'> <input type='button' value='Add footnotes' name='switch_foot' onclick='determineFoot();' style='width:150'> --><input type='button' value='Readonly' name='switch_readonly' onclick='determineReadonly()' style='width:150'><br><textarea id='theResponse' name='theResponse' cols='120' rows='50'>" + document.getElementById(output_PR).value + "</textarea></form>";
var newPage_PR = window.open("http://hu.wiki.x.io/","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; //<nowiki>
results_PR = document.getElementById(output_PR).value;
results_PR = results_PR.match(/\{\{subst:User:Bdamokos\/PR\/(.*)\}\}/gi);
for(i=0;i<results_PR.length;i++) results_PR[i] = results_PR[i].replace(/\{\{subst:User:Bdamokos\/PR\/(.*)\}\}/gi,"$1");
//</nowiki>
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 + "§ion=2&fakeaction=movePR&faketarget="+faketarget;
}
else if(moveToPrompt == "1")
newPageName = "Talk:" + wgPageName +"§ion=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://hu.wiki.x.io/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://hu.wiki.x.io/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://hu.wiki.x.io/w/index.php?title=Vita:' + unescape(pagename) + '&action=edit&fakeaction=prtemp','Talk', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');
window.open('/w/index.php?title=User:Bdamokos/Teszt/' + unescape(pagename) + '&action=edit&fakeaction=prsub&faketarget=' + unescape(pagename),'PRnom', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');
window.open('/w/index.php?title=User:Bdamokos/Teszt&action=edit&fakeaction=prlist&faketarget=' + unescape(pagename), 'PRlisting', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}
function autopr()
{
if (document.title.indexOf('szerkesztése') == 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("{{User:Bdamokos/Teszt/");
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.substring(0,req) + '{{User:Bdamokos/Teszt/' + target + '}}\n' + document.editform.wpTextbox1.value.substring(req,document.editform.wpTextbox1.value.length);
document.editform.wpSummary.value = '[[User:Bdamokos/Teszt/' + 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('{{referálás}}') != -1)
window.alert("There has already been a peer review.");
else{
document.editform.wpTextbox1.value = '{{referálás}}\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'peer reviewing - [[User:Bdamokos/Teszt/' + 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++) //<nowiki>
document.getElementById('wpTextbox1').value += "{{subst:User:Bdamokos/PR/"+list_PR[i]+"}}\n"
//</nowiki>
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++) //<nowiki>
document.getElementById('wpTextbox1').value += "{{subst:User:Bdamokos/PR/"+list_PR[i]+"}}\n"
//</nowiki>
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++) //<nowiki>
document.getElementById('wpTextbox1').value += "{{subst:User:Bdamokos/PR/"+list_PR[i]+"}}\n"
//</nowiki>
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++) //<nowiki>
document.getElementById('wpTextbox1').value += "{{subst:User:Bdamokos/PR/"+list_PR[i]+"}}\n"
//</nowiki>
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++) //<nowiki>
document.getElementById('wpTextbox1').value += "{{subst:User:Bdamokos/PR/"+list_PR[i]+"}}\n"
//</nowiki>
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);
//</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 ( ) 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>
//- not necessary to check - Determine if extraneous bolding is used
// <s>Determine if categories and interlanguage links are alphabetized</s>
//- 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
// <s>Determine if all images have captions</s>
// <s>Find out the number of sections</s>
//- 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
// <s>Determine if footnote spacing standards are used (as in [[WP:FOOTNOTE]])</s>
//- not able to do (w/ JS) 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
// <s>Automatic archiving</s>
// <s>British/American English spellings</s>
// 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
// <s>Improve the headingre function to exclude "the" and words in parentheses</s>
// infoboxes...
*/
// -- <pre> Specific to: User:AZPR (this simplifies the process of maintaining [[WP:PR/A]] -
// to use this, inquire on [[User talk:AndyZ/peer-review.js]])
var mem;
if(wgUserName == "AZPR" || maintain_PR){
if((document.location.href.indexOf("http://hu.wiki.x.io/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: -- 107 -- users use this script
/////////////////
*/
//</pre>
//cut out code can be found at [[User:Bdamokos/peer-review.js/comment]]