Utilisateur:Dr Brains/LiveRC/StatsExtension.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./* ************************************************************************************************************************************************
// Extension de LiveRC
// Procure un panneau de statistiques sur la session courante
{{Catégorisation JS|LiveRC}}
************************************************************************************************************************************************ */
if (typeof(lrcHooks)!="undefined") { // DÉBUT IF
/* ************************************************************************************************************************************************ */
if(typeof(lang_menu.STATS)=="undefined") lang_menu.STATS = "Stats";
function LiveRC_StatsExtension_AddButton(){
var OptionBar = document.getElementById('livePreviewFoot');
if(!OptionBar) return;
var NewInput = document.createElement('input');
NewInput.id = "STATS";
NewInput.type = "button";
NewInput.onclick = function(){ LiveRC_StatsExtension_ToggleStats(); return false; };
NewInput.onselect = function(){ LiveRC_StatsExtension_ToggleStats(); return false; };
OptionBar.appendChild(NewInput);
}
LiveRC_AddHook("AfterOptions", LiveRC_StatsExtension_AddButton);
var LiveRC_Stats = new Array();
LiveRC_Stats["pages"] = new Array();
LiveRC_Stats["users"] = new Array();
function LiveRC_StatsExtension_UpdateStats(Args){
var rc = Args.rc;
var title = rc.title;
var pageid = rc.pageid;
var revid = rc.revid;
var oldid = rc.old_revid;
var user = rc.user;
var comment = (rc.comment ? rc.comment : "");
var parsedcomment = (rc.parsedcomment ? rc.parsedcomment : "");
var timestamp = rc.timestamp;
var ns = rc.ns;
var state = rc.state;
var oldsize = rc.oldlen
var newsize = rc.newlen
var sizediff = newsize - oldsize;
if(typeof(LiveRC_Stats["users"][user]=="undefined") LiveRC_Stats["users"][user] = new Array();
if(typeof(LiveRC_Stats["pages"][title])=="undefined") LiveRC_Stats["pages"][title] = new Array();
}
LiveRC_AddHook("AfterRC", LiveRC_StatsExtension_UpdateStats);
function LiveRC_StatsExtension_ToggleStats(){
var OldStats = document.getElementById('StatPanel');
if(OldStats){
OldStats.parentNode.removeChild(OldStats);
return;
}
var RC = document.getElementById('divTabRC');
if(!RC) return;
var Stats = document.createElement('table');
Stats.id = 'StatPanel';
RC.parentNode.insertBefore(Stats, RC);
}
/* ************************************************************************************************************************************************ */
} // FIN IF