تضامنًا مع حق الشعب الفلسطيني |
ميدياويكي:Gadget-lastedited&quickeditcounter.js
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
// [[kk:Gadget-lastedited&quickeditcounter.js]]
window.editHysteriaGadget = {
version: 5,
init: function() {
if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 && mw.config.get( 'wgNamespaceNumber' ) !== 1 && mw.config.get( 'wgNamespaceNumber' ) != 4 && mw.config.get( 'wgNamespaceNumber' ) != 5 && mw.config.get( 'wgNamespaceNumber' ) != 6 && mw.config.get( 'wgNamespaceNumber' ) != 7 && mw.config.get( 'wgNamespaceNumber' ) != 8 && mw.config.get( 'wgNamespaceNumber' ) != 9 && mw.config.get( 'wgNamespaceNumber' ) != 10 && mw.config.get( 'wgNamespaceNumber' ) != 11 && mw.config.get( 'wgNamespaceNumber' ) != 14 && mw.config.get( 'wgNamespaceNumber' ) != 15 && mw.config.get( 'wgNamespaceNumber' ) != 100 && mw.config.get( 'wgNamespaceNumber' ) != 101 && mw.config.get( 'wgNamespaceNumber' ) != 102 && mw.config.get( 'wgNamespaceNumber' ) != 103 && mw.config.get( 'wgNamespaceNumber' ) != 828 && mw.config.get( 'wgNamespaceNumber' ) != 829 ) {
return;
}
if ( mw.util.getParamValue('printable') == 'yes' ) {
return;
}
var that = this;
var request = {
action: 'query',
prop: 'revisions',
rvprop: 'user|ids',
format: 'json',
titles: mw.config.get( 'wgPageName' ),
rvlimit: 50,
requestid: new Date().getTime()
};
jQuery.getJSON( mw.util.wikiScript( 'api' ), request, function(result) {
jQuery(document).ready(function() {
if (result) {
that.showResults(result);
}
});
});
},
userlink: function(name) {
var str = '<a href="' + mw.util.getUrl('User:' + name) + '">' + name + '</a> ' +
'(<a href="' + mw.util.getUrl('Special:Contributions/' + name) + '">مساهمات</a>، <a href="' + mw.util.getUrl('User talk:' + name) + '">نقاش</a>';
if ( jQuery.inArray( 'sysop', mw.config.get( 'wgUserGroups' ) ) != -1 ) {
str += '، <a href="' + mw.util.getUrl('Special:Blockip/' + name) + '">سجل</a>';
}
str += ')';
return str;
},
showResults: function(data) {
var page = data.query.pages[ mw.config.get( 'wgArticleId' ) ];
var firstHeading;
var headers = document.getElementsByTagName( 'h1' );
var i;
for ( i = 0; i < headers.length; i++ ) {
var header = headers[i];
if(header.className == "firstHeading" || header.id == "firstHeading" || header.className == "pagetitle") {
firstHeading = header; break;
}
}
if( !firstHeading ) {
firstHeading = document.getElementById("section-0");
}
if( !firstHeading ) {
return;
}
var div = document.createElement("div");
div.style.cssText = "font-size: 0.5em;margin:0px 1em 0 0;line-height: 1.5em;width: 30%;";
div.className = 'plainlinks';
if ( mw.config.get( 'skin' ) == 'modern' ) {
div.style.marginLeft = "10px";
div.style.display = "inline-block";
}
firstHeading.appendChild(div);
var html = '';
if (! page) {
div.innerHTML = html + "لا صفحة.";
div.style.color = "red";
return;
}
var topuser = page.revisions[0].user;
var ldiff;
var luser;
var count = 1;
for ( i = 1; i < page.revisions.length; i++) {
ldiff = page.revisions[i].revid;
luser = page.revisions[i].user;
if (luser != topuser)
break;
count++;
}
if (ldiff) {
html += 'آخر <a href="'+ mw.util.getUrl( mw.config.get('wgPageName') ) + '?diff=cur&oldid=' + ldiff + '"/>تعديل:</a> ' +
this.userlink(topuser) + ' (' + count + 'x)';
if(luser !== "" && luser != topuser) {
html += ' تعديل سابق: ' + this.userlink(luser) ;
}
html += '<a href="' + mw.util.getUrl('ميدياويكي:Gadget-lastedited&quickeditcounter') + '">(؟)</a>';
div.innerHTML = html;
}
else if (topuser !== "") {
div.innerHTML = html + this.userlink(topuser) + ' من أنشأ هذه الصفحة' ;
html += '<a href="' + mw.util.getUrl('ميدياويكي:Gadget-lastedited&quickeditcounter') + '">(?)</a>';
}
if ( mw.config.get('skin') == 'modern' ) {
var links = div.getElementsByTagName('a');
for ( i = 0; i < links.length; i++) {
links[i].style.color = 'white';
links[i].style.textDecoration = 'underline';
}
}
}
};
editHysteriaGadget.init();
// Warning! This gadget also use other projects.
// Original version:
// - QuickEditCounter script by [[:pl:User:ChP94]]
// - Released under the [http://www.gnu.org/licenses/gpl.txt GNU Public License (GPL)]
// Modified by: [[:pl:User:Beau]], [[:pl:User:Rzuwig]], [[:fr:User:Arkanosis]], [[:d:User:Vivaelcelta]] tanslated by [[User:Arystanbek]]
window.qecGadget = {
version: 10,
_i18n: ( function() {
var l10n = {
bn: {
thismaleusermade: 'এই পুরুষ ব্যবহারকারী',
thisfemaleusermade: 'এই মহিলা ব্যবহারকারী',
total: 'মোট',
edits: 'টি সম্পাদনা করেছেন'
},
ca: {
thismaleusermade: 'Aquest usuari ha fet',
thisfemaleusermade: 'Aquesta usuària ha fet',
total: 'un total de',
edits: 'edicions'
},
ar: {
thismaleusermade: 'المستخدم أجرى',
thisfemaleusermade: 'المستخدمة أجرت',
total: 'إجمالي',
edits: '(تعديل)'
},
en: {
thismaleusermade: 'This user has made',
thisfemaleusermade: 'This user has made',
total: 'a total of',
edits: 'edits'
},
eo: {
thismaleusermade: 'Tiu ĉi uzanto faris',
thisfemaleusermade: 'Tiu ĉi uzanto faris',
total: 'entute',
edits: 'redaktojn'
},
es: {
thismaleusermade: 'Este usuario hizo',
thisfemaleusermade: 'Esta usuaria hizo',
total: 'un total de',
edits: 'ediciones'
},
fr: {
thismaleusermade: 'Cet utilisateur a fait',
thisfemaleusermade: 'Cette utilisatrice a fait',
total: 'un total de',
edits: 'éditions'
},
gl: {
thismaleusermade: 'Este usuario fixo',
thisfemaleusermade: 'Esta usuaria fixo',
total: 'un total de',
edits: 'edicións'
},
id: {
thismaleusermade: 'Pengguna ini telah membuat',
thisfemaleusermade: 'Pengguna ini telah membuat',
total: 'sebanyak',
edits: 'suntingan'
},
ko: {
thismaleusermade: '이 사용자는',
thisfemaleusermade: '이 사용자는',
total: '총',
edits: '회 편집하였습니다'
},
kk: {
thismaleusermade: 'Бұл қатысушы қазақша Уикипедияда',
thisfemaleusermade: 'Бұл қатысушы қазақша Уикипедияда',
total: 'барлығы',
edits: 'өңдеме жасады'
},
ms: {
thismaleusermade: 'Pengguna ini telah melakukan',
thisfemaleusermade: 'Pengguna ini telah melakukan',
total: 'sebanyak',
edits: 'suntingan'
},
pl: {
thismaleusermade: 'Ten użytkownik wykonał',
thisfemaleusermade: 'Ta użytkowniczka wykonała',
total: 'łącznie',
edits: 'edycji'
},
sk: {
thismaleusermade: 'Tento redaktor vykonal',
thisfemaleusermade: 'Táto redaktorka vykonala',
total: 'dokopy',
edits: 'úprav'
}
};
var lang = mw.user.options.get( 'language' );
if( !l10n[ lang ] ) {
lang = 'ar';
}
return function( key ) {
if( l10n[ lang ][ key ] ) {
return l10n[ lang ][ key ];
} else {
return l10n[ 'ms' ][ key ];
}
};
} )(),
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[0];
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[i];
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'
? this._i18n( 'thisfemaleusermade' )
: this._i18n( 'thismaleusermade' );
var lang = 'www';
var wiki = 'wikidata';
var m;
if ( m = mw.config.get( 'wgServer' ).match( /^(?:http:)?\/\/(.+?).([^.]+).org$/ ) ) {
lang = m[1];
wiki = m[2];
} else if ( m = mw.config.get( 'wgScriptPath' ).match( /\/(.+?)\/(.+?)\// ) ) {
lang = m[2];
wiki = m[1];
}
html += ' ' + this._i18n( 'total' ) + ' <a href="//tools.wmflabs.org/xtools-ec/index.php?name=' + encodeURIComponent( this.username ) + '&wiki=' + encodeURIComponent( wiki ) + '&lang=' + encodeURIComponent( lang ) + '&uselang=' + encodeURIComponent( lang ) + '">' + data.editcount + '</a> ' + this._i18n( 'edits' ) + '.';
var div = document.createElement( 'div' );
div.style.cssText = 'font-size: 0.5em;margin:0px 1em 0 0;line-height: 1.5em;width: 30%;';
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();