// UWAGA! Z tego gadżetu korzystają także inne projekty
// Original version:
// - QuickEditCounter script by ]
// - Released under the
// Modified by ]
window.qecGadget = {
version: 9,
init: function() {
if ( mw.config.get( 'wgNamespaceNumber' ) != 2 && mw.config.get( 'wgNamespaceNumber' ) != 3 ) {
return;
}
if ( mw.util.getParamValue('printable') == 'yes' ) {
return;
}
this.username = mw.config.get( 'wgTitle' ).replace(/\/.*$/, '');
var that = this;
var request = {
action: 'query',
list: 'users',
usprop: 'editcount|gender',
format: 'json',
ususers: this.username,
requestid: new Date().getTime()
};
jQuery.getJSON( mw.util.wikiScript( 'api' ), request, function(result) {
jQuery(document).ready(function() {
if (result) {
that.showResults(result);
}
});
});
},
showResults: function(data) {
data = data.query.users;
if (!data || data.name != this.username || data.invalid != null || data.editcount === undefined)
return;
var firstHeading;
var headers = document.getElementsByTagName( 'h1' );
for ( var i = 0; i < headers.length; i++ ) {
var header = headers;
if(header.className == "firstHeading" || header.id == "firstHeading" || header.className == "pagetitle") {
firstHeading = header; break;
}
}
if( !firstHeading ) {
firstHeading = document.getElementById("section-0");
}
if( !firstHeading ) {
return;
}
var html = data.gender == "female" ? 'Ta użytkowniczka wykonała' : 'Ten użytkownik wykonał';
var lang = 'pl';
var wiki = 'wikipedia';
var m;
if (m = mw.config.get( 'wgServer' ).match(/^(?:http:)?\/\/(.+?).(+).org$/)) {
lang = m;
wiki = m;
}
else if (m = mw.config.get( 'wgScriptPath' ).match(/\/(.+?)\/(.+?)\//)) {
lang = m;
wiki = m;
}
html += ' łącznie <a href="//xtools.toolforge.org/ec/' + encodeURIComponent(lang) + '.' + encodeURIComponent(wiki) + '.org/' + encodeURIComponent(this.username) + '">' + data.editcount + '</a> edycji.';
var div = document.createElement("div");
div.style.cssText = "font-size:0.5em;line-height:1em";
div.className = 'plainlinks';
div.innerHTML = html;
if ( mw.config.get( 'skin' ) == 'modern' ) {
div.style.marginLeft = "10px";
div.style.display = "inline-block";
}
firstHeading.appendChild(div);
}
};
qecGadget.init();