User:Selmo/firefox.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Selmo/firefox. |
/* <pre><nowiki> */
/**
* Here be all good stuff
* Original location: [[User:Alphax/monobook.js]]
* Forked from [[User:ABCD/monobook.js]] around April 2005
* Dual licensed under the GFDL and GPL
* See also: [[User:JesseW/monobook.js]]
* And best of all: [[WP:US]]
*/
/**** Add Godmode-lite ****/
// this one breaks popups
// document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/godmode-light.js"><\/SCRIPT>');
// and this one is dead as well...
// document.write('<SCRIPT SRC="http://share.zopatista.com/WikiPedia/godmode-light.js"><\/SCRIPT>');
// this one works with popups
document.write('<script language="JavaScript" src="http://en.wikipedia.org/wiki/User:Ilmari_Karonen/godmode-light.js"><\/script>');
/**** Add navigation popups ****/
// [[User:Lupin/popups.js]] - please include this line
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');
// customisations = see [[Wikipedia:Tools/Navigation popups]] for more
popupFixRedirs = true;
popupRedirAutoClick = 'wpPreview';
popupFixDabs = true;
popupStructure = 'menus';
/**** Live RC filter ****/
// [[User:Lupin/recent2.js]] - please include this line
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');
/**** afd helper ****/
// From [[User:Jnothman/afd_helper/script.js]]
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>');
/**** 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>'); }
/**** Initialise on window load and load custom functions ****/
addOnloadHook( myLoadFuncs );
function myLoadFuncs()
{
// &action=purge
addPurge();
// §ion=0
addEditSection0();
// cause the personal menu looks bad
changeLinks();
// because edit summaries are good
addForceSummary();
// now add a million extra tabs
morelinks();
// and some stuff for the sidebar
addToolBoxLinks();
// make red talk page links start new sections
//talkpageplus();
// for admins only...
// if(document.title.indexOf("Confirm delete - Delete") == 0) addVfdLink();
// change the title of the edit link
ta['ca-edit'] = ['e', 'Edit page'];
// remove the logout access key
//ta['pt-logout'] = new Array(null, null);
// re-render the title and accesskeys for stuff
akeytt();
// add history link to new messages box
newmessagehistory();
}
/**** Edit section 0 ****/
function addEditSection0()
{
ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-edit');
if(!x) return;
var y = document.createElement('LI');
y.id = 'ca-edit-0';
if(x.className == 'selected'){
if(/&action=edit§ion=0$/.test(window.location.href)){
x.className = 'istalk';
y.className = 'selected';
} else {
x.className = 'selected istalk';
}
} else if(x.className == 'selected istalk'){
if(/&action=edit§ion=0$/.test(window.location.href)){
x.className = 'istalk';
y.className = 'selected istalk';
} else {
y.className = 'istalk';
}
} else {
y.className = x.className;
x.className = 'istalk';
}
var z = document.createElement('A');
if(x.children){
z.href = x.children[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
}else{
z.href = x.childNodes[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
/**** Add generic tab ****/
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
/**** Add tab as menu ****/
function addlimenu(tabs, name, id)
{
var na = document.createElement('a');
na.href = '#';
var mn = document.createElement('ul');
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.className = 'tabmenu';
li.appendChild(na);
li.appendChild(mn);
tabs.appendChild(li);
return li;
}
/**** Add purge tab ****/
function addPurge()
{
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-history');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(!x) return;
if(x.children) x = x.children[0];
else x = x.childNodes[0];
var pf = document.createElement('form');
pf.action = '?action=purge';
pf.method = 'POST';
pf.id = 'pf';
x.appendChild(pf);
addlilink(tabs, 'javascript:document.getElementById("pf").submit();', 'purge', 'ca-purge');
}
/**** Add afd header, footer and comment ****/
function closeafd(bold, notbold)
{
var txt = document.editform.wpTextbox1;
txt.value = "{{subst:vt}} '''" + bold + "'''" + notbold + ". – ~~~~\n" + txt.value
+ "\n{{subst:vb}}\n";
txt = document.editform.wpSummary;
txt.value = "close discussion: " + bold + notbold;
// I don't mind still watching them
// document.editform.wpWatchthis.checked = false;
}
/**** Generic custom talk message ****/
function autoMessage(msgtext, summary, saveopt)
{
var txt = document.editform.wpTextbox1;
document.editform.wpSummary.value = summary;
if(txt.value.length > 0) txt.value += '\n';
txt.value += msgtext;
if(saveopt == 'save')
{
document.editform.submit();
}
else if(saveopt == 'preview')
{
document.editform.wpPreview.click();
}
else if(saveopt == 'diff')
{
document.editform.wpDiff.click();
}
}
/**** Get the pagename for a specified thread ****/
function startThread()
{
var which = prompt("Thread number?");
var now = new Date();
if(which < 10) which = '0' + which;
var timestamp = now.getUTCFullYear() + '';
now.getUTCMonth() < 9 ? timestamp += '0' + (now.getUTCMonth() + 1) : timestamp += (now.getUTCMonth() + 1);
now.getUTCDate() < 10 ? timestamp += '0' + now.getUTCDate() : timestamp += now.getUTCDate();
return '{{User talk:Alphax/' + timestamp + '-' + which + '}}';
}
/**** Get the text for a specified test number ****/
function test(x)
{
var s = (x == '1' ? '' : x);
return ['{{subst:test' + s + '}} – ~~~~', '{{test' + s + '}}'];
}
/**** Get the text for a specified blanking number ****/
function blank(x)
{
var s = (x == '1' ? '' : x);
return ['{{subst:blank' + s + '}} – ~~~~', '{{blank' + s + '}}'];
}
/**** String replacement popup ****/
function replace()
{
var s = prompt("Search regexp?");
if(s){
var r = prompt("Replace regexp?");
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
/**** Talk page AFD result ****/
function afdresult()
{
var res = prompt("Result?");
if(!res) return;
var afddate = prompt("Nomination date?");
document.editform.wpSummary.value = 'AFD result - ' + res.replace(/'/g, '');
var txt = document.editform.wpTextbox1;
if(txt.value.length > 0) txt.value += '\n';
txt.value += '{{oldafdfull|date=[[' + afddate + ']] [[{{subst:CURRENTYEAR}}]]|result=' + res + '|votepage={{subst:PAGENAME}}}}';
txt.focus();
}
/**** Make old AfD's appear or disappear ****/
function hideafd()
{
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "none";
// needed to shrink the page - rendering bug
document.getElementById('footer').style.display = 'none';
}
function showafd()
{
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "";
// might as well put it back...
document.getElementById('footer').style.display = '';
}
/**** Make the top links look better ****/
function changeLinks()
{
if(!document.getElementById) return;
// remove the "my" bits
document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk';
document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences';
document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist';
document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions';
// add a clock
var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
addlilink(toplinks, '#', '', 'utcdate');
showtime();
}
/**** Now using the version I developed on commons ****/
function addForceSummary()
{
if(!/&action=edit/.test(window.location.href) && !/&action=submit/.test(window.location.href)) return;
if(/§ion=new/.test(window.location.href)) return;
if(!document.forms.editform) return;
document.forms.editform.wpSave.onclick = forceSummary;
document.forms.editform.wpSave.onfocus = forceSummary;
}
function forceSummary()
{
// Section names be damned
if (!document.forms.editform.wpSummary.value.replace(/^(?:\/\\*.*\\*\/)? *(.*) *$/,'$1'))
{
var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',document.forms.editform.wpSummary.value);
if(r == null) { return false; }
document.forms.editform.wpSummary.value = r;
}
return true;
}
/**** Not sure how this works ****/
function afddelete(){
var form = document.forms.deleteconfirm;
form.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')) + ']]';
form.wpConfirm.checked = true;
}
/**** Mega Tab Adding ****
*
* I'm making this comment block REALLY REALLY BIG so I can find it
*
* Possibly the most useful bit of this entire file, it adds various tabs depending on
* what page we are on
*
*/
function morelinks()
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0)
{
/**** AFD closing ****/
addlimenu(tabs, 'afd actions', 'afda');
var afda = document.getElementById('afda').getElementsByTagName('ul')[0];
addlilink(afda, 'javascript:closeafd("keep", "")', 'keep', '');
addlilink(afda, 'javascript:closeafd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'merge', '');
addlilink(afda, 'javascript:closeafd("redirect", " to [[" + prompt("Redirect to?") + "]]")', 'redir', '');
addlilink(afda, 'javascript:closeafd("transwiki", " to " + prompt("Transwiki to?"))', 'trans', '');
addlilink(afda, 'javascript:closeafd("transwiki", " to Wiktionary")', 'wikt', '');
addlilink(afda, 'javascript:closeafd("speedy delete", "")', 'speedy', '');
addlilink(afda, 'javascript:closeafd("delete", "")', 'del', '');
addlilink(afda, 'javascript:closeafd(prompt("Result?"), "")', 'other', '');
addlilink(tabs, 'javascript:replace()', 'replace', '');
/**** The "Make it Awesome!" button ****
document.editform.wpSummary.value = 'This vote brought to you by the "Make it Awesome!" button';
var txt = document.editform.wpTextbox1;
if(txt.value.length > 0) txt.value += '\n';
txt.value += "*'''Make it awesome!''' ~~~~";
document.editform.submit();
**** Finish making it awesome ****/
}
else if(document.title.indexOf("Confirm delete - Delete") == 0)
{
addlilink(tabs, 'javascript:afddelete()', 'afd', '');
}
else if(document.title.indexOf("Editing User talk:") == 0)
{
addlilink(tabs, 'javascript:replace()', 'replace', '');
addlimenu(tabs, 'talk messages', 'talkm');
var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
/**** Set up Welcome messages ****/
addlimenu(talkm, 'welcome', 'welcmess');
var welcmess = document.getElementById('welcmess').getElementsByTagName('ul')[0];
addlilink(welcmess, 'javascript:autoMessage("{{subst:User:Alphax/Welcome}} ~~~~", "Welcome to Wikipedia!", "save")', 'personal', '');
addlilink(welcmess, 'javascript:autoMessage("{{subst:anon}} Thanks, ~~~~", "Create an account!", "save")', 'anon', '');
addlilink(welcmess, 'javascript:autoMessage("{{subst:oldwelcome}} ~~~~", "Welcome to Wikipedia!", "save")', 'oldwelcome', '');
/**** Set up Test series ****/
addlimenu(talkm, 'test[x]', 'testx');
var testx = document.getElementById('testx').getElementsByTagName('ul')[0];
addlilink(testx, 'javascript:autoMessage("{{subst:selftest}} ~~~~", "{{selftest}}", "save")', 'selftest', '');
addlilink(testx, 'javascript:autoMessage(test(1)[0], test(1)[1], "save")', 'test', '');
addlilink(testx, 'javascript:autoMessage(test(2)[0], test(2)[1], "save")', 'test2', '');
addlilink(testx, 'javascript:autoMessage(test(3)[0], test(3)[1], "save")', 'test3', '');
addlilink(testx, 'javascript:autoMessage(test(4)[0], test(4)[1], "save")', 'test4', '');
addlilink(testx, 'javascript:autoMessage(test(5)[0], test(5)[1], "save")', 'test5', '');
/**** Set up Blanking series ****/
addlimenu(talkm, 'blanking', 'blankmess');
var blankmess = document.getElementById('blankmess').getElementsByTagName('ul')[0];
addlilink(blankmess, 'javascript:autoMessage(blank(1)[0], blank(1)[1], "save")', 'blank', '');
addlilink(blankmess, 'javascript:autoMessage(blank(2)[0], blank(2)[1], "save")', 'blank2', '');
addlilink(blankmess, 'javascript:autoMessage(test("2a")[0], test("2a")[1], "save")', 'test2a', '');
addlilink(blankmess, 'javascript:autoMessage(blank(3)[0], blank(3)[1], "save")', 'blank3', '');
addlilink(blankmess, 'javascript:autoMessage(blank(4)[0], blank(4)[1], "save")', 'blank4', '');
addlilink(blankmess, 'javascript:autoMessage(blank(5)[0], blank(5)[1], "save")', 'blank5', '');
/**** Generic talk messages ****/
addlilink(talkm, 'javascript:autoMessage(startThread(), "new thread", "save")', 'thread', '');
addlilink(talkm, 'javascript:autoMessage("{{subst:summary}} ~~~~", "Edit summary", "save")', 'summary', '');
addlilink(talkm, 'javascript:autoMessage("{{subst:bv}} ~~~~", "{{bv}}", "save")', 'bv', '');
}
else if(document.title.indexOf("Editing ") == 0)
{
addlilink(tabs, 'javascript:replace()', 'replace', '');
addlilink(tabs, 'javascript:afdresult()', 'afd result', '');
}
else if(document.title.indexOf("Wikipedia:Articles for deletion") == 0)
{
addlilink(tabs, 'javascript:hideafd()', 'hide closed', 'ca-hide');
ta['ca-hide'] = ['', 'Hide closed AFDs'];
addlilink(tabs, 'javascript:showafd()', 'show closed', 'ca-show');
ta['ca-show'] = ['', 'Show closed AFDs'];
}
else if((document.title.indexOf("User:") == 0) || (document.title.indexOf("User talk:") == 0))
{
addlimenu(tabs, 'User functions', 'userf');
var userf = document.getElementById('userf').getElementsByTagName('ul')[0];
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
editlk = editlk.substring(editlk.indexOf(':') + 1);
var slloc = editlk.indexOf('/');
if(slloc > 0) editlk = editlk.substring(0, slloc);
// add "block" tab
addlilink(userf, '/wiki/Special:Blockip/' + editlk, 'block user');
// add "blocklog" tab
addlilink(userf, '/wiki/Special:Log/block?page=User:' + editlk, 'block log', '');
// add "unblock" tab
addlilink(userf, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'unblock user', '');
// add "contributions" tab
addlilink(userf, '/wiki/Special:Contributions/' + editlk, 'contributions', '');
// add "edit count" tab
//addlilink(userf, 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=' + editlk + '&dbname=enwiki_p', 'interiot\'s tool', '');
addlilink(userf, 'http://tools.wikimedia.de/~essjay/edit_count/Count.php?username=' + editlk + '&submit=Count', 'Essjay\'s tool', '');
// add "whois" tab
addlilink(userf, 'http://www.samspade.org/t/lookat?a=' + editlk, 'whois user', '');
// add another "whois" tab
addlilink(userf, 'http://www.dnsstuff.com/tools/whois.ch?ip=' + editlk, 'whois (2)', '');
// add "proxycheck" tab
addlilink(userf, 'http://wikipedia.quyme.com/proxycheck.php?ip=' + editlk, 'open proxy check', '');
}
}
/**** Add links to the toolbox ****/
function addToolBoxLinks()
{
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
var afdtime = new Date();
var months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];
afdtime.setUTCDate(afdtime.getUTCDate() - 7);
addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', '');
addlilink(tb, '/wiki/Special:Log', 'Logs', '');
// addlilink(tb, '/wiki/Template:Deletiontools', 'Deletion tools', '');
addlilink(tb, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear()
+ '_' + months[afdtime.getUTCMonth()] + '_' + afdtime.getUTCDate(), 'Week old AfD', '');
addlilink(tb, '/wiki/Wikipedia:Disambiguation_pages_with_links', 'Dab list', '');
addlilink(tb, '/wiki/Wikipedia:Template_messages/User_talk_namespace', 'Talk messages', '');
addlilink(tb, '/wiki/User:Alphax/special', 'Special characters', '');
addlilink(tb, '/wiki/User:Alphax/monobook.js', 'Monobook.js', '');
addlilink(tb, '/wiki/User:Alphax/monobook.css', 'Monobook.css', '');
addlilink(tb, '/wiki/User:Alphax/Sandbox', 'My sandbox', '');
addlilink(tb, '/wiki/WP:ICT', 'Image Copyright tags', '');
}
/**** Get a clock that autoupdates! ****/
function showtime()
{
var timerID;
var now = new Date();
var timeValue = now.toUTCString().replace(/GMT/, "UTC");
document.getElementById('utcdate').firstChild.innerHTML = timeValue;
timerID = setTimeout('showtime()', 100);
}
/**** Auto start new topics when hitting empty talk pages from the content page ****/
function talkpageplus()
{
var talkpagelink = document.getElementById('ca-talk');
if (talkpagelink.className == 'new')
{
talkpagelink.firstChild.href += '§ion=new';
}
}
/**** Add history link to the "You have new messages" box ****/
function newmessagehistory()
{
var divs = document.getElementsByTagName('div');
var talkmessagebox;
for(var x = 0; x < divs.length; ++x)
{
if(divs[x].className.indexOf('usermessage') != -1)
{
talkmessagebox = divs[x];
x = divs.length; // force break
}
}
divs = ''; // release divs?
if(!talkmessagebox) return false;
var newmessagelink = talkmessagebox.getElementsByTagName('a')[0];
var historylink = document.createElement('a');
historylink.href = newmessagelink.href.replace(/\/wiki\//, '/w/index.php?title=') + '&action=history';
historylink.className = 'extiw';
historylink.appendChild(document.createTextNode('changes'));
// var talkmessagetext = 'You have ';
// talkmessagebox.innerHTML = talkmessagetext;
// talkmessagebox.appendChild(newmessagelink);
talkmessagebox.appendChild(document.createTextNode(' ('));
talkmessagebox.appendChild(historylink);
talkmessagebox.appendChild(document.createTextNode(')'));
}
//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>'); }
/* </nowiki></pre> */
function inc (file) {
var lt = String.fromCharCode(60);
var gt = String.fromCharCode(62);
document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}
inc("User:Lightdarkness/aiv.js");
/* Semi-automatic javascript peer reviewer - note that this is NOT a [[WP:BOT]] (but it may be a [[WP:SBOTS|semi-bot]]) */
/*<nowiki>
// Adding {{subst:js|User:AndyZ/peerreviewer.js}} to your /monobook.js
// will create a "peer review" link next to the "log out" link while in editing mode;
// onclicking, it creates a layer with suggestions in [[User:AndyZ/PR]] template form.</nowiki>
*/
/*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>
// 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...
*/
//<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 = theTitle.replace(/\D27/gi,"'")
theTitle = theTitle.replace(/\D28/gi,"(")
theTitle = theTitle.replace(/\D29/gi,")")
theTitle = theTitle.replace(/\D2C/g,",")
theTitle = 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
longstring = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
for(i=0;i<150;i++){
longstring+="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
theTextlead = theTextlead.replace(/==/,longstring)
theTextlead = theTextlead.substring(0,7200)
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{{subst:User:AndyZ/PR/persondata}}"
}
//[[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{{subst:User:AndyZ/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(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{{subst:User:AndyZ/PR/abbrev}}"
}
//checks that units are spelled out in text
kmSN = /km\s/gi
miSN = /\smi\s/gi
ftSN = /\sft\s/gi
ydSN = /yd\s/gi
cmSN = /cm\s/gi
dmSN = /dm\s/gi
nmSN = /nm\s/gi
//weights/mass
lbSN = /\slb\s/gi
gramSN = /\d\sg\s/gi
kgSN = /kg\s/gi
//area
sqinSN = /in<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{{subst:User:AndyZ/PR/spellnum}}"
}
//checks for usage of standard abbreviations in parentheses (for conversions)
kmSN2 = /kms(\s|\))/gi
miSN2 = /mis(\s|\))/gi
ftSN2 = /\sfts(\s|\))/gi
ydSN2 = /yds(\s|\))/gi
inchSN2 = /\sins(\s|\))/gi
cmSN2 = /cms(\s|\))/gi
dmSN2 = /dms(\s|\))/gi
nmSN2 = /nms(\s|\))/gi
//weights/mass
lbSN2 = /lbs(\s|\))/gi
gramSN2 = /\sgs(\s|\))/gi
kgSN2 = /kgs(\s|\))/gi
if(kmSN2.test(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{{subst:User:AndyZ/PR/convert}}"
}
*/
//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{{subst:User:AndyZ/PR/linkdate}}"
}
//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{{subst:User:AndyZ/PR/dateth}}"
}
//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{{subst:User:AndyZ/PR/headingthe}}"
//existence of link in heading
headinglink1 = /==.{0,}\[\[.{1,}\]\].{0,}==/gi
if(headinglink1.test(theText)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/headinglink}}"
}
//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{{subst:User:AndyZ/PR/headingre}}"
}
//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{{subst:User:AndyZ/PR/trivia}}"
}
//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{{subst:User:AndyZ/PR/gtl}}"
}
//looks for section named "List of..."
list = /==(\s|)List/gi
if(list.test(theText)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/list}}"
}
//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{{subst:User:AndyZ/PR/alpha|[[WP:CAT|categories]]}}"
}
if((!alphed2)&&(alphed)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha|[[WP:IL|interlanguage links]]}}"
}
if((!alphed)&&(!alphed2)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha}}"
}
//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{{subst:User:AndyZ/PR/expand}}"
}
if(theSections.length>=24){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/toc}}"
}
if((theLength<=7500)&&(theSections.length>5)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/expand}}"
}
}
else{
theSections = "none"
}
if((theLength<=7500)&&(theSections=="none")){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/expand}}"
}
if(theLength>=50000){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/SS}}"
}
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{{subst:User:AndyZ/PR/sectexpand}}"
}
//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;
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{{subst:User:AndyZ/PR/foot}}"
}
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"
//show feedback
document.getElementById("theFeedback").style.visibility = "visible"
//<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 <font color="red">may or may not be accurate</font> 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.split("==Requests==");
document.editform.wpTextbox1.value = req[0] + '==Requests==\n{{Wikipedia:Peer review/' + target + '}}' + req[1];
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)
{
setTimeout("autopr();",5000)
}
//</pre> end
// CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC:
// *** aut. signing / (automatische Unterschrift) *** [[User:Olliminatore/signing.js]]
// created 23.04.2006 by [[User:Olliminatore]]
// updated 23.04.2006 by [[:en:User:Ilmari Karonen]]
// current version 1.48 13.08.2006
//<pre><nowiki>
// Helper-function
String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")};
if (typeof usersignature == 'undefined') usersignature = ' --\~\~\~\~\n';
addOnloadHook(function(){
if(!document.editform) return;
var title = encodeURI(document.title); // object to string
// regarded pages type encoded
var regpages=new Array('talk:', 'Talk:', ':Village pump', ':Articles for deletion', ':Requests for deletion', ':Requests for ');
for(p in regpages)
if(title.indexOf(regpages[p])!=-1){
regpages=false;
break
}
if(regpages) return;
var txtarea=document.editform.wpTextbox1;
var txtOld=txtarea.value.trim();
// txtOld_l=txtOld.length
var txtOldEnd=txtOld.slice(-24);
var tNode = document.editform.wpMinoredit.parentNode
setSigBox()
tNode.insertBefore(neuB, tNode.getElementsByTagName("DIV").item(0));
var sig = /~{3}/g
function doSign(event){
if(document.editform.onsubmit==''){ // only once!
removeEvent(document.editform.wpSave,"click",doSign);
removeEvent(document.editform.wpPreview,"click",doSign);
}
if(document.editform.onsubmit=='') removeEvent(document.editform.wpSave,"click",doSign); // only once!
if(document.editform.wpMinoredit.checked || !sigBox.checked) return;
var cOld = txtOld.match(/<nowiki>.*?~{3}.*?<\/nowiki>/g); if (cOld) cOld = cOld.length;
var cNew = sig.exec(txtarea.value); if (cNew) cNew = cNew.length;
if(cNew <= cOld){ // then search a set position
txt=txtarea.value.trim();
txtEnd=txt.slice(-24);
if(txtOldEnd!=txtEnd) return txtarea.value = txt + usersignature; // aut. underwrite
else { // post between
pos = getCaretPos(txtarea);
pos = txt.indexOf('\n', pos); // go to the post-end
txtEnds = txt.substr(pos,24).replace(/(^\s*)/,""); // after
txtpEnds = txt.slice(pos-18,pos); // before
oldp = txtOld.indexOf(txtEnds);
if(oldp!=-1 && oldp < pos - 3 && txtOld.indexOf(txtpEnds+RegExp.$1+txtEnds)==-1) // if some added
return txtarea.value = txt.slice(0,pos).trim() + usersignature + txt.slice(pos+1);
}
// FIXME: the edit-end is not found
}
else if(!sig.test(txtOld) || cOld < cNew) return;
if (event) event=(window.Event)? event.target: event.srcElement;
if (event.name == 'wpPreview') return; // not for preview
return document.editform.onsubmit=new Function("document.editform.onsubmit='';return confirm('No signing was found. Continue anyway?')");
};
addEvent(document.editform.wpSave,"click", doSign);
addEvent(document.editform.wpPreview,"click", doSign);
addEvent(document.editform.wpMinoredit,"click", setSigBox);
});
var sigBox = document.createElement("input");
sigBox.setAttribute('type','checkbox');
sigBox.setAttribute('name','wpSigning');
sigBox.setAttribute('id','wpSigning');
sigBox.setAttribute('checked','checked');
sigBox.defaultChecked=true;
var neuB = document.createElement("label");
neuB.appendChild(sigBox);
neuB.appendChild(document.createTextNode("Undersign"));
neuB.setAttribute('for','wpSigning');
neuB.setAttribute('title','This edit automatic undersigning.');
function setSigBox(){
if(document.editform.wpMinoredit.checked)
sigBox.setAttribute('disabled', 'disabled');
else
sigBox.removeAttribute('disabled');
}
function getCaretPos(txtObj) {
if (txtObj.setSelectionRange) return txtObj.selectionStart; // NS like
else if(!document.selection) return 0; // not IE like
txtObj.focus();
var c="\001", pos=0;
var range=document.selection.createRange();
var txt=range.text, dul=range.duplicate();
dul.moveToElementText(txtObj);
range.text=txt+c;
pos=(dul.text.indexOf(c));
range.moveStart('character',-1);
range.text="";
return pos;
};
/* add/removeEvent Original idea by John Resig
Tweaked by Scott Andrew LePera, Dean Edwards and Peter-Paul Koch
Fixed for IE by Tino Zijdel (crisp) @date 2005-10 */
function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function(){obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}};
function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}};
//*** end ***
//</nowiki></pre>
// Interwiki <noinclude>[[en:User:Olliminatore/sign.js]]</noinclude>