//===========================================================================
// Fügt an den Reiter "Versionen/Autoren" die Anzahl Versionen an und die
// Anzahl vom Nutzer erstellter Versionen
// revisionCounterを日本語環境に適応させた改良版。
// 改良点:日本語に翻訳。表示位置が一番左のタブになるように変更。
// Sakoppiが一部変更
//===========================================================================
/* Please uncomment when problems in [[phab:T72470]] have been addressed.*/
var revisionCounter =
{
queryUrl : mw.config.get('wgScriptPath') + '/api.php?action=query&prop=revisions&pageids=' + mw.config.get('wgArticleId') + '&rvprop=user&rvlimit=max&format=json&callback=revisionCounter.queryResult',
revisionCount : 0,
revisionCountUser : 0,
checkOnlyOnHistory : true,
execute : function(){
if ((revisionCounter.checkOnlyOnHistory) && (mw.config.get('wgAction') != "history")) return;
mw.loader.load(revisionCounter.queryUrl);
},
queryResult : function(res){
if (!res['query'] || !res['query']['pages'] ||
!res['query']['pages'][mw.config.get('wgArticleId')] || !res['query']['pages'][mw.config.get('wgArticleId')]['revisions']) return;
var revs = res['query']['pages'][mw.config.get('wgArticleId')]['revisions'];
revisionCounter.revisionCount += revs.length;
for (var i = 0; i < revs.length; i++)
if (revs[i]['user'] == mw.config.get('wgUserName')) revisionCounter.revisionCountUser++;
if (res && res['query-continue']) {
mw.loader.load(revisionCounter.queryUrl + '&rvstartid=' + encodeURIComponent(res['query-continue'].revisions.rvstartid));
}else{
if (mw.config.get('skin') == 'vector'){
if (mw.config.get('wgNamespaceNumber') % 2){
$("#ca-talk a").text(function(index, curText) {
return "(自分の編集:" + revisionCounter.revisionCountUser + "/版数:" + revisionCounter.revisionCount + ")";
});
}else{
$("#ca-nstab-main a,#ca-nstab-user a,#ca-nstab-project a,#ca-nstab-image a,#ca-nstab-mediawiki a,#ca-nstab-template a,#ca-nstab-help a,#ca-nstab-category a,#ca-nstab-portal a,#ca-nstab-プロジェクト a").text(function(index, curText) {
return "(自分の編集:" + revisionCounter.revisionCountUser + "/版数:" + revisionCounter.revisionCount + ")";
});
}
}else{
var info = document.createElement("span");
info.appendChild(document.createTextNode(" (" + "自分の編集:" + revisionCounter.revisionCountUser + "/"+ "版数:" + revisionCounter.revisionCount + ")"));
var infoTitle = document.createAttribute("title");
infoTitle.nodeValue = "Insgesamt " + revisionCounter.revisionCount + " Versionen, davon " + revisionCounter.revisionCountUser + " von mir";
info.setAttributeNode(infoTitle);
document.getElementById('ca-history').firstChild.appendChild(info);
}
}
}
};
if (mw.config.get('wgNamespaceNumber') >= 0) addOnloadHook( revisionCounter.execute );