User:Nichalp/monobook.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. |
The accompanying .css page for this skin is at User:Nichalp/monobook.css. |
// Useful stuff from [[Wikipedia:WikiProject_User_scripts]]
function addToolboxLink(url, name, id){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, url, name, id);
}
function addlilink(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if(id) {
if(key && title) ta[id] = [key, title];
else if(key) ta[id] = [key, ''];
else if(title) ta[id] = ['', title];
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function addPurge(){
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
var x = document.getElementById('ca-history');
if(!x) return;
if(x.children) x = x.children[0].href;
else x = x.childNodes[0].href;
addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge');
akeytt();
}
// culled from [[User:Lupin/popups.js]]
function nichalp_articleFromURL(h) {
if (typeof h != 'String') h=String(h);
h=decodeURI(h);
var m=RegExp('[^:]*://en\\.wikipedia\\.org/(wiki/|w/index\\.php\\?title=)([^&?]*)').exec(h);
if(m===null) return null;
return m[2];
}
function nichalp_isIpUser(user) {
return RegExp('(User:)?' +
'((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' +
'(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])')
.test(user);
}
function nichalp_removeAnchor(article) {
// is there a #? if not, we're done
var i=article.indexOf('#');
if (i == -1) return article;
return article.substring(0,i);
}
function nichalp_userName(article) {
var i=article.indexOf('User');
var j=article.indexOf(':');
if (i != 0 || j == -1) return null;
var k=article.indexOf('/');
if (k==-1) return article.substring(j+1);
else return article.substring(j+1,k);
}
// do it
function nichalp_customLinks() {
addPurge();
var article=nichalp_articleFromURL(document.location.href);
if (!article) return;
var user=nichalp_userName(article);
if(!user) return;
user=nichalp_removeAnchor(user);
if (!nichalp_isIpUser(user)) {
addToolboxLink('http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username='+user+'&site=en.wikipedia.org', user+"'s edit count", 'toolbox_katestool');
}
var special='http://en.wikipedia.org/w/index.php?title=Special:';
addToolboxLink(special + 'Log&user='+user, user+"'s log", 'toolbox_userlog');
addToolboxLink(special + 'Blockip&ip='+user, 'Block '+user, 'toolbox_blockuser');
addToolboxLink(special + 'Special:Ipblocklist&action=unblock&ip='+user, 'Unblock '+user, 'toolbox_unblockuser');
addToolboxLine(special + 'Special:PrefixIndex');
}
// make it all happen on page load
if (window.addEventListener) window.addEventListener("load",nichalp_customLinks,false);
else if (window.attachEvent) window.attachEvent("onload",nichalp_customLinks);
else {
window._old_nichalp_onload = window.onload;
window.onload = function() { window._old_nichalp_onload(); nichalp_customLinks(); }
}
<!-- Special customized script by Lupin ends -->
<!-- Edit 0 -->
// This will add an [edit] link at the top of all pages except preview pages and the main page
// by User:Pile0nades
// Add an [edit] link to pages
$(function () {
// if this is preview page or generated page, stop
if(
document.getElementById("wikiPreview") ||
document.getElementById("histlegend") ||
document.getElementById("difference") ||
document.getElementById("watchdetails") ||
document.getElementById("ca-viewsource") ||
window.location.href.indexOf("/wiki/Special:") != -1
) {
if(window.location.href.indexOf("&action=edit§ion=0") != -1) {
document.getElementById("wpSummary").value = "/* Intro */ ";
}
return;
};
// get the page title
var pageTitle = wgPageName;
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+pageTitle+'&action=edit§ion=0" title="Edit section: '+pageTitle+'">edit intro</a>]</div>';
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
});
<!-- Edit 0 ends -->
<!-- Bureaucrat script by VoA begins -->
//<pre><nowiki>
//Helper tools
mw.loader.load(
'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Addtabs/monobook.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s');
//END
//
RfAshowlinks = 'true';
//
function jssubmitclose()
{
var form = document.getElementById('editform');
form.submit();
}
//archive recent promotions
function cratfinish()
{
if (location.href.search(/&jsaction=[SF]RFAunlist&target=/) !=-1)
{
var name = unescape(location.href.split('&target=')[1].split('&target2=')[0]);
var user = unescape(location.href.split('&target2=')[1]);
var listing = "{{" + name + "}}\n----";
var txt=document.editform.wpTextbox1;
if (txt.value.indexOf(listing) == -1){alert('RfA already removed.'); return;}
txt.value = txt.value.replace(listing,'');
alert(name + ' unlisted.');
if (location.href.indexOf('&jsaction=SRFAunlist') !=-1)
{
document.editform.wpSummary.value = "RfA closed, [[User:" + user + "|" + user + "]] promoted.";
}
else if (location.href.indexOf('&jsaction=FRFAunlist') !=-1)
{
document.editform.wpSummary.value = "RfA closed, no consensus to promote [[User:" + user + "|" + user + "]].";
}
}
//add to recent promotion list
else if (location.href.indexOf('&jsaction=RFAsucadd&target') != -1)
{
var target = unescape(location.href.split('&target=')[1].split('&')[0]);
var name = '{{' + target + '}}' + '\n' + '----';
var txt = document.editform.wpTextbox1;
if (txt.value.indexOf('==Most recent successful nominations==') == -1) return;
var RFA_list = txt.value.split('==Most recent successful nominations==')[1];
var RFAs = RFA_list.match(/\{\{Wikipedia:Requests for adminship\/.+\}\}\n----/ig);
var lastRfA = RFAs[RFAs.length-1];
//remove last RfA
RFA_list=RFA_list.replace(lastRfA,'');
//add new one
txt.value = '==Most recent successful nominations==' + '\n' + name + RFA_list;
document.editform.wpSummary.value += 'Adding "' + target + '".';
//jssubmitclose();
}
//add to recent failure list
else if (location.href.indexOf('&jsaction=RFAfailadd&target=') != -1)
{
addTab("javascript:Alpha_userwait2()", "(Add)", "ca-add", "Add", "");
alert('Add "[NEW]" to the proper alphabetical location and press (add).');
var to_add = unescape(location.href.split('&target=')[1].split('&')[0]);
var name = to_add.split('[[')[1].split(']]')[0];
document.editform.wpSummary.value += 'Adding "' + name + '".';
}
}
//
var Alpha_user_done = 0;
function Alpha_userwait2()
{
var to_add = unescape(location.href.split('&target=')[1].split('&')[0]) + '\n';
var name = to_add.split('[[')[1].split(']]')[0];
if (Alpha_user_done == 1){alert('Already added.'); return;}
if (document.editform.wpTextbox1.value.indexOf('[NEW]') != -1){Alpha_user_done=1;}
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('[NEW]',to_add);
}
function CHUlinks()
{
if(document.title.indexOf("Editing Wikipedia:Changing username (section)") == 0)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'Rename results', 'chclosefunc');
var chclosefunc = document.getElementById('chclosefunc').getElementsByTagName('ul')[0];
//Rename results
addlilink(chclosefunc, 'javascript:Cng_UName(1)', 'done', '');
addlilink(chclosefunc, 'javascript:Cng_UName(2)', 'not done', '');
}
}
//
var Cng_UNamealready = 0;
function Cng_UName(type)
{
if (type == 1 && Cng_UNamealready != 1)
{
Cng_UNamealready=1;
document.editform.wpTextbox1.value += "\n" + ":{{done}} Done. ~~~~";
document.editform.wpSummary.value += "Complete.";
}
else if (type == 2 && Cng_UNamealready != 1)
{
Cng_UNamealready=1;
document.editform.wpTextbox1.value += "\n" + ":That username already exists. Please follow the instructions at the top of the page to select an unregistered username. ~~~~";
document.editform.wpSummary.value += ":{{not done}} Username already exists.";
}
}
//navdivs
var hide_rfa_div = '<div style="clear: both; width: 100%; padding: 1px; background: #ffffff; border:1px solid darkblue;" class="NavFrame"><div class="NavHead" style="text-align: center; padding: 2px; font-size: 120%;">';
var hide_rfa_div2 = '</div><div class="NavContent" style="font-size: 100%; text-align: left">';
function crathide()
{
if (location.href.search(/&oldid=|&diff=|&action=[^p]/) !=-1) return;
if (!RfAshowlinks){RfAshowlinks = 'false'}
if (wgTitle != "Requests for adminship" || wgNamespaceNumber != 4 || RfAshowlinks != 'true') return;
//kill table of contents
//if (document.getElementById('toc')) document.getElementById('toc').innerHTML = '';
var rawhtml = document.getElementById('bodyContent').innerHTML;
newhtml = rawhtml.replace(/(<p><a name=".+" id=".+"><\/a><\/p>[\n\r])<h3>/igm,'</div></div><br>$1' + hide_rfa_div + '<h3>');
newhtml = newhtml.replace(/(<p><a name="About_RfB" id="About_RfB"><\/a><\/p>[\n\r]<h2>)/igm,'</div></div>$1');
newhtml = newhtml.replace(/(<p><a name="Related_requests" id="Related_requests"><\/a><\/p>[\n\r]<h2>)/igm,'</div></div>$1');
newhtml = newhtml.replace(/(\(\d+\/\d+\/\d+\)).+ \d\d:\d\d.+ \(UTC\)( |)(<\/b>|)/ig,rfaTally);
document.getElementById('bodyContent').innerHTML = newhtml;
}
function rfaTally(match,tally)
{
var S = 1*tally.match(/\d+/g)[0]; var O = 1*tally.match(/\d+/g)[1]; var N = 1*tally.match(/\d+/g)[2];
perc = Math.round((100)*100*S/(S+O))/100; tperc = Math.round((100)*100*S/(S+O+N))/100;
var color = 'red';
if (perc > 90) color = 'green';
else if (perc > 80) color = 'darkgreen';
else if (perc > 70) color = 'darkorange';
else if (perc > 60) color = 'darkred';
poll = ' [<span style="color:' + color + '">' + perc + '%</span>] (Confident:<span style="color:darkblue">' + tperc + '%</span>)';
var string = match + ' ' + poll + '<br><br>' + hide_rfa_div2 + '<br><br>';
return string;
}
//Get text in between two <h2>heading</h2> tag (eventually, h1, h3, ect...)
//the first input is the raw parent xml
//this assumes unique titles!
function getSectionBodytext(html,firstheading,nextheading,level)
{
var htag = '<' + level + '>';
var ehtag = '<\/' + level + '>';
var first_id = '<p><a name="' + firstheading.replace(/ /g,'_') + '" id="' + firstheading.replace(/ /g,'_') + '"></a></p>';
var next_id = '<p><a name="' + nextheading.replace(/ /g,'_') + '" id="' + nextheading.replace(/ /g,'_') + '"></a></p>';
var body_html = html.split(first_id)[1].split(next_id)[0];
var first_header = body_html.match(new RegExp(htag + '.+' + ehtag,''))[0];
var body_html = body_html.substr(body_html.indexOf(first_header));
return body_html;
}
function crattools()
{
if(document.getElementById('ca-talk') && document.title.indexOf('Wikipedia:') != -1)
{document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';}
if (document.title.indexOf('Editing Wikipedia:Requests for adminship/') != -1)
{
addTab("javascript:cratClose(1)", "(✓)", "ca-cratS", "Close as success", "");
addTab("javascript:cratClose(-1)", "(X)", "ca-cratF", "Close as failure", "");
}
else if (document.title.indexOf('Editing ') == -1 && document.title.indexOf('Wikipedia:Requests for adminship/') != -1 && location.href.indexOf('=history') == -1)
{
addTab("javascript:cratcomment()", "mess", "ca-cratI", "Leave user a new message", "");
}
}
function cratClose(type)
{
var txt = document.editform.wpTextbox1;
var RfAName = document.title.split(' (section)')[0].split(' - ')[0].split('Editing ')[1];
var user_name = RfAName;
if (txt.value.indexOf('{{User|') != -1)
{user_name = txt.value.split('{{User|')[1].split('}}')[0].split('}')[0]}
else if (txt.value.indexOf('{{user|') !=-1)
{user_name = txt.value.split('{{user|')[1].split('}}')[0].split('}')[0]}
var message = 'Closing ' + RfAName + '.';
var return_value = confirm(message);
if (return_value != true){return;}
if (document.editform.wpTextbox1.value.indexOf('The following discussion is preserved as an archive of') != -1)
{alert('Already closed!'); return;}
if (txt.value.indexOf('{{subst:rfab}') != -1){alert('Already closed!'); return;}
//both
var timeValue = new Date().toUTCString().replace(/GMT/, "(UTC)");
txt.value = txt.value.replace(/(ending|Scheduled to end) \d\d:\d\d, .+ \(UTC\)/i,'Ended ' + timeValue);
txt.value = txt.value.replace(/\}\}( |)Voice your opinion/ig,"}} Final");
txt.value = txt.value.replace(/\|action=edit\}\} (voice|vote|discuss|comment) .{1,20}\]/ig,"|action=edit}} Final]");
//passed
if (type == 1)
{
var deadlink = 'NOT_FOUND_LINK_YET';
txt.value = "{{subst:rfap}}" + "\n" + txt.value + "{{subst:rfab}}";
document.editform.wpSummary.value += "Closing successful nomination."; window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_adminship&action=edit&jsaction=SRFAunlist&target=' + escape(RfAName) + '&target2=' + escape(user_name),'BCratcloseRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Successful_adminship_candidacies&action=edit§ion=1&jsaction=RFAsucadd&target=' + escape(RfAName),'BCratcloserecentRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
cratpromote();
}
//failed
if (type == -1)
{
var deadlink = 'NOT_FOUND_LINK_YET';
if (txt.value.indexOf('{{subst:rfab}') != -1){alert('Already closed!'); return;}
document.editform.wpTextbox1.value = "{{subst:rfaf}}" + "\n" + document.editform.wpTextbox1.value + "{{subst:rfab}}";
document.editform.wpSummary.value += "Closing unsuccessful nomination.";
var tally = '';
if (txt.value.search(/\(\d+\/\d+\/\d+\)/) != -1)
{tally = txt.value.match(/\(\d+\/\d+\/\d+\)/)[0];}
var RfA_data = '*[[' + RfAName + '|' + user_name + ']], ' + timeValue + ' - consensus not reached at ' + tally;
var first_let = user_name.substring(0,1).toUpperCase();
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_adminship&action=edit&jsaction=FRFAunlist&target=' + escape(RfAName) + '&target2=' + escape(user_name),'BCratcloseRFA:m' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Unsuccessful_adminship_candidacies/' + first_let + '&action=edit§ion=&jsaction=RFAfailadd&target=' + escape(RfA_data),'BCratcloserecentRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
}
function alpha_sec(string)
{
var letter = string.substring(0,1).toLowerCase();
if (letter == 'a'){sec=1;}
else if (letter == 'b'){sec=2;}
else if (letter == 'c'){sec=3;}
else if (letter == 'd'){sec=4;}
else if (letter == 'e'){sec=5;}
else if (letter == 'f'){sec=6;}
else if (letter == 'g'){sec=7;}
else if (letter == 'h'){sec=8;}
else if (letter == 'i'){sec=9;}
else if (letter == 'j'){sec=10;}
else if (letter == 'k'){sec=11;}
else if (letter == 'l'){sec=12;}
else if (letter == 'm'){sec=13;}
else if (letter == 'n'){sec=14;}
else if (letter == 'o'){sec=15;}
else if (letter == 'p'){sec=16;}
else if (letter == 'q'){sec=17;}
else if (letter == 'r'){sec=18;}
else if (letter == 's'){sec=19;}
else if (letter == 't'){sec=20;}
else if (letter == 'u'){sec=21;}
else if (letter == 'v'){sec=22;}
else if (letter == 'w'){sec=23;}
else if (letter == 'x'){sec=24;}
else if (letter == 'y'){sec=25;}
else if (letter == 'z'){sec=26;}
else {sec=0;}
return sec;
}
function cratcomment()
{
var user_name = document.title.split('Wikipedia:Requests for adminship/')[1].split(' - ')[0];
if (document.getElementsByTagName('h3')[1])
{
if (document.getElementsByTagName('h3')[1].getElementsByTagName('strong')[0])
{user_name = document.getElementsByTagName('h3')[1].getElementsByTagName('strong')[0].innerHTML;}
else
{user_name = document.getElementsByTagName('h3')[1].innerHTML;}
}
window.open('http://en.wikipedia.org/w/index.php?title=User_talk:' + user_name + '&action=edit§ion=new',
'targetnameBCratclose',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
function cratpromote()
{
var user_name = document.title.split('Wikipedia:Requests for adminship/')[1].split(' - ')[0];
if (document.editform.wpTextbox1.value.match(/\{\{user\|.+\}\}/ig))
{user_name = document.editform.wpTextbox1.value.split(/\{\{user\|/i)[1].split(/\}\}/)[0];}
window.open('http://en.wikipedia.org/w/index.php?title=Special%3AMakesysop&wpMakesysopUser=' + escape(user_name),
'BCratPromote:' + user_name,
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
function cratstats_add()
{
if (location.href.indexOf('&action=history') ==-1 || document.title.search(/Wikipedia:Requests for (adminship|bureaucratship)\/|Wikipedia:Arbitration Committee Elections [^ ]+ \d\d\d\d\/Vote\//) !=0){return;}
var name = document.title.split(' - ')[0];
var url = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=history&limit=5000&jsaction=validate';
addTab(url, "✓?", "ca-vstats", "Voter statistics", "");
}
function crat_stats()
{
if (location.href.indexOf('&limit=5000&jsaction=validate') ==-1){return;}
//monobook
if (document.getElementById('bodyContent'))
{var body = document.getElementById('bodyContent');}
//cologneblue
else
{var body = document.getElementById('content');}
var l = body.getElementsByTagName('li');
var html = '<p><strong>List of participants on this page:</strong></p>';
var thenamelist = '|';
for (var i=l.length-1; i >= 0; i--)
{
if (l[i].innerHTML.indexOf('>) (last)') !=-1)
{var name = l[i].getElementsByTagName('a')[2].innerHTML; var date = l[i].getElementsByTagName('a')[1].innerHTML;}
else if (l[i].innerHTML.indexOf('(cur) (<') !=-1)
{var name = l[i].getElementsByTagName('a')[2].innerHTML; var date = l[i].getElementsByTagName('a')[1].innerHTML;}
else
{var name = l[i].getElementsByTagName('a')[3].innerHTML; var date = l[i].getElementsByTagName('a')[2].innerHTML;}
if (thenamelist.indexOf('|' + name + '|') ==-1)
{
thenamelist += name + '|';
var name_link = '<a href="/wiki/User:' + name + '">' + name + '</a>';
html += '\n' + '<li>' + name_link + ' -- ' + date + '</li>';
}
}
body.innerHTML = body.innerHTML.split('<!-- start content -->')[0] + '<!-- start content -->' + '<ul id="voterstats">' + html + '</ul>';
//number our voters
var l = body.getElementsByTagName('li');
for (var i=0; i<l.length; i++)
{
var num = i+1;
l[i].innerHTML = '<strong>#' + num + '</strong> ' + l[i].innerHTML;
}
consec_votercheck(0);
}
//
var voter_index = 0;
var name_user_vote = '';
function consec_votercheck(voter_index)
{
if (document.getElementById('voterstats').getElementsByTagName('li')[voter_index])
{
current_user_name = document.getElementById('voterstats').getElementsByTagName('li')[voter_index].getElementsByTagName('a')[0].innerHTML;
var URL = '/w/index.php?title=Special%3ALog&type=newusers&page=User:' + current_user_name + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = consec_votercheck_last;
xml_http.send(null);
}
else
{return;}
}
function consec_votercheck_last()
{
if (xml_http.readyState != 4) return;
var doc = xml_http.responseText.split("<div id='article'>")[1];
var date = '(<i>older account</i>)';
if (!doc) date = '(<i>error</i>)';
else if (doc.indexOf('<ul>') !=-1)
{
doc = doc.split('<ul>')[1].split('</ul>')[0];
if (doc.indexOf('<li>') !=-1)
{date = '<span style="color:darkred;">' + doc.split('<li>')[1].split('</li>')[0].split('<a href=')[0].split('(')[0] + '</span>';}
}
date = ' <strong> Created:</strong> ' + date;
document.getElementById('voterstats').getElementsByTagName('li')[voter_index].innerHTML += date;
//
var URL = '/w/index.php?title=Special:Contributions&go=first&limit=1&target=' + current_user_name + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = consec_votercheck_edits;
xml_http.send(null);
}
function consec_votercheck_edits()
{
if (xml_http.readyState != 4) return;
var doc = xml_http.responseText.split('<div id="bodyContent">')[1];
var first = '(<i>error</i>)';
if (doc && doc.indexOf('<ul>') !=-1)
{
doc = doc.split('<ul>')[1].split('</ul>')[0];
if (doc.indexOf('<li>') !=-1)
{first = doc.split('<li>')[1].split('</li>')[0].split('<a href=')[0].split('(')[0];}
}
first = ' <strong> 1st edit:</strong> ' + first;
document.getElementById('voterstats').getElementsByTagName('li')[voter_index].innerHTML += first;
//
var URL = '/w/index.php?title=Special:Contributions&limit=250&target=' + current_user_name + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = consec_votercheck_blocks;
xml_http.send(null);
}
function consec_votercheck_blocks()
{
if (xml_http.readyState != 4) return;
var doc = xml_http.responseText.split("<div id='article'>")[1];
var edits=0;
if (!doc) edits = '(<i>error</i>)';
else if (doc.indexOf('<ul>') !=-1)
{
doc = doc.split('<ul>')[1].split('</ul>')[0];
if (doc.search(/<li>.+<\/li>/g) !=-1) edits = doc.match(/<li>.+<\/li>/g).length;
}
if (edits >= 250){edits = '<span style="color:blue;">250+</span>';}
else if (edits <= 100){edits = '<a href="/w/index.php?title=Special:Contributions/' + current_user_name + '"><span style="color:red;">' + edits + '</span></a>';}
else {edits = '<a href="/w/index.php?title=Special:Contributions/' + current_user_name + '"><span style="color:darkred;">' + edits + '</span></a>';}
edits = ' <strong> #E:</strong> ' + edits;
document.getElementById('voterstats').getElementsByTagName('li')[voter_index].innerHTML += edits;
//
var URL = '/w/index.php?title=Special:Log&type=block&limit=5000&page=User:' + current_user_name + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = consec_votercheck_next;
xml_http.send(null);
}
function consec_votercheck_next()
{
if (xml_http.readyState != 4) return;
var doc = xml_http.responseText.split("<div id='article'>")[1];
var blocks = 0;
if (!doc) blocks = '(<i>error</i>)';
else if (doc.indexOf('<ul>') !=-1)
{
doc = doc.split('<ul>')[1].split('</ul>')[0];
if (doc.match(/<li>.+<\/a>\) blocked "<a href=.+<\/li>/g))
{blocks = doc.match(/<li>.+<\/a>\) blocked "<a href=.+<\/li>/g).length;}
}
if (blocks > 0){blocks = '<a href="/w/index.php?title=Special:Log&type=block&limit=5000&page=User:' + current_user_name + '"><span style="color:red;">' + blocks + '</span></a>';}
blocks = ' <strong> #B:</strong> ' + blocks;
document.getElementById('voterstats').getElementsByTagName('li')[voter_index].innerHTML += blocks;
//re-iterate
voter_index += 1;
consec_votercheck(voter_index);
}
$(crat_main)
function crat_main()
{
crattools();
cratfinish();
CHUlinks();
crathide();
cratstats_add();
crat_stats();
}
//</nowiki></pre>
//<pre>
//This function adds a link to the toolbox which, when clicked, displays the size of the page
//and the size of the prose. See the talk page for more details.
//
//To use this function add {{subst:js|User:Dr pda/prosesize.js}} to your monobook.js
//
function loadXMLDocPassingTemplate(url,handler, page)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
var req = new XMLHttpRequest();
}
// branch for IE/Windows ActiveX version
else if (window.ActiveXObject) {
var req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req) {
req.onreadystatechange = function () {handler(req, page)};
req.open("GET", url, true);
req.send("");
}
}
function getWikiText(req, page) {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
// ...processing statements go here...
response = req.responseText;
var startindex = response.indexOf('mw-search-results');
startindex = response.indexOf('title="'+page+'"',startindex);
var endindex = response.indexOf('</li>',startindex);
if(startindex > -1){
searchresult = response.substr(startindex,endindex-startindex);
result = searchresult.match(/\d+ [Kk]?i?B \(\d+ words\)/);
wiki_value = document.createElement("li");
wiki_value.id = "wiki-size";
wiki_value.innerHTML = '<b>Wiki text: </b>'+result;
var output = document.getElementById("document-size-stats");
prose_value = document.getElementById("prose-size");
output.insertBefore(wiki_value,prose_value);
}
else{
//alert("There was a problem using the Wikipedia Search to find the wiki text size\nEither the search is not working or the correct article did not appear on the first page of results");
wiki_value = document.createElement("li");
wiki_value.id = "wiki-size";
wiki_value.innerHTML = '<b>Wiki text: </b>Problem with search';
var output = document.getElementById("document-size-stats");
prose_value = document.getElementById("prose-size");
output.insertBefore(wiki_value,prose_value);
}
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}
function getFileSize(req, page) {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
// ...processing statements go here...
var fsize = req.responseText.length;
window.status = fsize;
var total_value = document.createElement("li");
total_value.id = "total-size";
total_value.innerHTML='<b>File size: </b>'+(fsize/1024).toFixed(0)+' kB';
var output = document.getElementById("document-size-stats");
var prose_html_value = document.getElementById("prose-size-html");
output.insertBefore(total_value,prose_html_value);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText + "\n(" + url + ")");
}
}
}
function getLength(id){
var textLength = 0;
for(var i=0;i<id.childNodes.length; i++){
if(id.childNodes[i].nodeName == '#text'){
textLength += id.childNodes[i].nodeValue.length;
}
else{
textLength += getLength(id.childNodes[i]);
}
}
return textLength;
}
function getDocumentSize(){
var bodyContent = document.getElementById("bodyContent");
if(document.getElementById("document-size-stats")){
//if statistics already exist, turn them off and remove highlighting
var output = document.getElementById("document-size-stats");
var oldStyle = output.className;
var pList = bodyContent.getElementsByTagName("p");
for(var i=0;i<pList.length; i++){
if(pList[i].parentNode.id == 'bodyContent') pList[i].style.cssText = oldStyle;
}
output.parentNode.removeChild(output);
var header = document.getElementById("document-size-header");
header.parentNode.removeChild(header);
}
else{
var output = document.createElement("ul");
output.id = "document-size-stats";
var prose_html_value = document.createElement("li");
prose_html_value.id = "prose-size-html";
output.appendChild(prose_html_value);
var ref_html_value = document.createElement("li");
ref_html_value.id = "ref-size-html";
output.appendChild(ref_html_value);
var prose_value = document.createElement("li");
prose_value.id = "prose-size";
output.appendChild(prose_value);
output.className = bodyContent.getElementsByTagName("p").item(0).style.cssText;
var ref_value = document.createElement("li");
ref_value.id = "ref-size";
output.appendChild(ref_value);
var dummy = document.getElementById("siteSub");
dummy.parentNode.insertBefore(output, dummy.nextSibling);
var header = document.createElement("span");
header.id = "document-size-header";
header.innerHTML = '<br/>Document statistics: <small><i>(See <a href="http://en.wikipedia.org/wiki/User_talk:Dr_pda/prosesize.js">here</a> for details.)<i></small>';
dummy.parentNode.insertBefore(header,output);
//If browser supports document.fileSize property (IE)
if(document.fileSize){
var total_value = document.createElement("li");
total_value.id = "total-size";
total_value.innerHTML='<b>File size: </b>'+(document.fileSize/1024).toFixed(0)+' kB';
output.insertBefore(total_value,prose_html_value);
}
else{
loadXMLDocPassingTemplate(location.pathname,getFileSize,'')
}
//Get size of images only if browser supports filesize property (IE)
var iList = bodyContent.getElementsByTagName("img");
if(iList.length >0 && iList[0].fileSize){
//Get size of images included in document
var image_size = 0;
var first_magnify = true;
for (var i=0;i<iList.length; i++){
var im = iList[i];
if(im.getAttribute("src").indexOf("magnify-clip.png") != -1){
if(first_magnify){
image_size += im.fileSize*1;
first_magnify = false;
}
}
else{
image_size += im.fileSize*1;
}
}
var image_value = document.createElement("li");
image_value.id = "image-size";
image_value.innerHTML='<b>Images: </b>'+(image_size/1024).toFixed(0)+' kB';
output.appendChild(image_value);
}
//Calculate prose size
var pList = bodyContent.getElementsByTagName("p");
prose_size = 0;
prose_size_html = 0;
word_count = 0;
for(var i=0;i<pList.length; i++){
var para = pList[i];
if(para.parentNode.id == 'bodyContent'){
prose_size += getLength(para);
prose_size_html += para.innerHTML.length;
word_count += para.innerHTML.replace(/(<([^>]+)>)/ig,"").split(' ').length
para.style.cssText = "background-color:yellow";
}
}
//Calculate size of reference markers ([1] etc)
var rmList = bodyContent.getElementsByTagName("sup");
refmark_size = 0;
refmark_size_html = 0;
for(var i=0;i<rmList.length; i++){
var refmark = rmList[i];
if(refmark.className == "reference"){
refmark_size += getLength(refmark);
refmark_size_html += refmark.innerHTML.length;
}
}
if((prose_size-refmark_size)>10240){
prose_value.innerHTML='<b>Prose size (text only): </b>'+((prose_size-refmark_size)/1024).toFixed(0)+' kB ('+word_count+' words) "readable prose size"';
}
else{
prose_value.innerHTML='<b>Prose size (text only): </b>'+(prose_size-refmark_size)+' B ('+word_count+' words) "readable prose size"';
}
if((prose_size_html-refmark_size_html)>10240){
prose_html_value.innerHTML='<b>Prose size (including all HTML code): </b>'+((prose_size_html-refmark_size_html)/1024).toFixed(0)+' kB';
}
else{
prose_html_value.innerHTML='<b>Prose size (including all HTML code): </b>'+(prose_size_html-refmark_size_html)+' B';
}
//Calculate size of references (i.e. output of <references/>)
var rList = bodyContent.getElementsByTagName("ol");
var ref_size = 0;
var ref_size_html = 0;
for (var i=0; i<rList.length; i++){
if(rList[i].className == "references"){
ref_size = getLength(rList[i]);
ref_size_html = rList[i].innerHTML.length;
}
}
if((ref_size+refmark_size)>10240){
ref_value.innerHTML='<b>References (text only): </b>'+((ref_size+refmark_size)/1024).toFixed(0)+' kB';
}
else{
ref_value.innerHTML='<b>References (text only): </b>'+(ref_size+refmark_size)+' B';
}
if((ref_size_html+refmark_size_html)>10240){
ref_html_value.innerHTML='<b>References (including all HTML code): </b>'+((ref_size_html+refmark_size_html)/1024).toFixed(0)+' kB';
}
else{
ref_html_value.innerHTML='<b>References (including all HTML code): </b>'+(ref_size_html+refmark_size_html)+' B';
}
//get correct name of article from wikipedia-defined global variables
var pageNameUnderscores = wgPageName;
var pageNameSpaces = pageNameUnderscores.replace(/_/g,' ')
//if page is a permalink, diff, etc don't try to search
if(!location.pathname.match('/w/index.php')){
//Get size as returned by Wikipedia search
var searchURL = '/wiki/Special:Search?search=' + pageNameUnderscores + '&fulltext=Search';
loadXMLDocPassingTemplate(searchURL,getWikiText,pageNameSpaces);
}
}
}
$(function () {
if(!document.forms.editform){
mw.util.addPortletLink('p-tb', 'javascript:getDocumentSize()', 'Page size', 't-page-size', 'Calculate page and prose size', '', '');
}
});
//</pre>
importScript('User:Gimmetrow/fixRefs.js'); // [[User:Gimmetrow/fixRefs.js]]
importScript('User:Dr pda/articlehistory.js'); // [[User:Dr pda/articlehistory.js]]
importScript('User:Dr_pda/editrefs.js'); // [[User:Dr_pda/editrefs.js]]
importScript('User:Lupin/recent2.js');