« MediaWiki:Gadget-LiveRC.js » : différence entre les versions

Contenu supprimé Contenu ajouté
EDUCA33E (discussion | contributions)
m si rollback
EDUCA33E (discussion | contributions)
m update 20080130/0.3.7
Ligne 2 :
==LiveWP==
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*AuthorsAuthor : [[:fr:User:EDUCA33E]], [[:fr:User:TiChou]] & [[:pl:User:Leafnode]]
*Dev & enhancements : [[:fr:User:TiChou]], [[:pl:User:Leafnode]] & [[:it:User:Jalo]]
*Version: 0.3.7 (beta)
 
Version modifiée basée sur la version du 1er avril 2007 a 00:49 :
 
http://fr.wikipedia.org/w/index.php?title=User:EDUCA33E/LiveRC.js&oldid=15525649
 
=== Variables globales ===
Ligne 75 ⟶ 72 :
var PAS = 2 << 19;
var FIRE = 2 << 20;
 
var UPLOAD = 2 << 21;
var NEWUSER = 2 << 22;
var BLOCK = 2 << 23;
var DELETE = 2 << 24;
var MOVE = 2 << 25;
var PROTECT = 2 << 26;
 
var lstSysop = new Array(); // Sysop list;
Ligne 481 ⟶ 485 :
'[<a id="LiveAvertoLink" href="javascript:var message=getLiveAverto(\''+utilde+'\');">'+lang_menu[0].AVERTS+'</a>] : ' +
'<select id="averto">' + optAvert + '</select>' + '</td></tr></table>';
}
 
/* </source>
 
=== LiveLog (:it:User:Jalo) ===
 
<source lang="javascript"> */
function liveLog(action,page) {
var titolo = '';
switch(action) {
case 'upload':
titolo = 'Log dei caricamenti';
break;
case 'newuser':
titolo = 'Log dei nuovi utenti';
break;
case 'block':
titolo = 'Log dei blocchi utente';
break;
case 'delete':
titolo = 'Log delle cancellazioni';
break;
case 'move':
titolo = 'Log degli spostamenti';
break;
case 'protect':
titolo = 'Log delle protezioni';
break;
default:
break;
}
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b style='text-decoration: blink;'><span style='color:red'>"+titolo+"</span>...</b>";
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=Special:Log&type=' + action + "&user=&page=" + encodeURIComponent(page), onSuccess: getLog, message: page });
}
function getLog(xmlreq, data) {
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
if (bC == null) bC = doc.getElementById('article')
var c=data.message;
var LP = document.getElementById( 'livePreview' );
var dLP = document.getElementById( 'divLivePreview' );
LP.innerHTML = bC.innerHTML;
if (dLP.style.display == "none") {
var elcb = document.getElementById( 'shidPrev' );
elcb.checked="true";
dLP.style.display = "inline";
}
var elt = document.getElementById( 'livePreviewTitle' );
elt.innerHTML='<b><a href="'+wgServer+'/wiki/'+encodeURI(c)+'" target="_new">'+c+'</a></b>';
}
 
Ligne 810 ⟶ 867 :
 
// ARTICLE //
 
var arti = "", artiStyle = "";
var preArti = "", postArti = "";
 
var diff = "";
var diffClose = "";
Ligne 819 ⟶ 876 :
diffClose='supprLigne(\''+pageid+'_'+revid+'\');';
if (state & NEW)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveArticle(\''+escTitle+'\',\''+user+'\');'+diffClose+'" style="color:green">New</a>';
else if (state & UPLOAD)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'upload\',\''+escTitle+'\');'+diffClose+'" style="color:darkslateblue">Log</a>';
else if (state & NEWUSER)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'newusers\',\''+escTitle+'\');'+diffClose+'" style="color:lime">Log</a>';
else if (state & BLOCK)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'block\',\''+escTitle+'\');'+diffClose+'" style="color:darkgoldenrod">Log</a>';
else if (state & DELETE)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'delete\',\''+escTitle+'\');'+diffClose+'" style="color: saddlebrown">Log</a>';
else if (state & MOVE)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'move\',\''+escTitle+'\');'+diffClose+'" style="color:black">Log</a>';
else if (state & PROTECT)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'protect\',\''+escTitle+'\');'+diffClose+'" style="color: darkslategray">Log</a>';
else // simple edit
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveDiff(\''+escTitle+'\','+revid+','+oldid+');'+diffClose+'" style="color:orange">Diff</a>';
var hist = '<a href="javascript:;" onClick="liveHist(\''+escTitle+'\');" style="color:darkorange">H</a>';
var hist = '';
var edit = '<a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=edit" target="_new" style="color:tomato">E</a>';
var edit = '';
var admin = '';
// Don't show link for log rows
if (lrcAdmin == true) {
if (!(state & UPLOAD) &&
admin = ' • <a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=delete" target="_new" style="color:orangered">S</a>';
!(state & NEWUSER) &&
!(state & BLOCK) &&
!(state & DELETE) &&
!(state & PROTECT) &&
!(state & MOVE))
{
hist = '<a href="javascript:;" onClick="liveHist(\''+escTitle+'\');" style="color:darkorange">C</a>';
edit = '<a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=edit" target="_new" style="color:tomato">M</a>';
if (lrcAdmin == true) {
admin = ' • <a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=delete" target="_new" style="color:orangered">S</a>';
admin += ' • <a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=protect" target="_new" style="color: coral">P</a>';
}
}
 
Ligne 882 ⟶ 965 :
postArti += '<sup style="color:crimson">(cat ?)</sup>';
 
// Redirect, Log, or simple edit ? ;
//////////////////
if (state & REDIRECTMOVE) {
// artiStyle = 'color: magenta; font-weight: bold; font-style: italic;';
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/0/0e/Forward.png" width="20px" alt="Sposta" />';
postArti += ' <a href="javascript:;" onClick="liveArticle(\''+rc.new_title+'\',\''+user+'\');">'+rc.new_title+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');">'+title+'</a>';
}
else if (state & REDIRECT) {
artiStyle = 'color: green; font-weight: bold; font-style: italic;';
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Redirectltr.png/20px-Redirectltr.png" width="20px" alt="RedirectionRedirect" />';
postArti += ' <a href="javascript:;" onClick="liveArticle(\''+rc.redirect+'\',\''+user+'\');">'+rc.redirect+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');">'+title+'</a>';
/* if (rc.redirect) {
}
// postArti += '<a href="'+wgServer+'/wiki/'+encodeURIComponent(rc.redirect)+'" target="_new">'+rc.redirect+'</a>';
else if (state & UPLOAD) {
postArti += '<a href="javascript:;" onClick="liveArticle(\''+rc.redirect+'\');">'+rc.redirect+'</a>';
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/4/47/Gartoon-Gnome-dev-floppy.png" width="20px" alt="Carica" />';
} else {
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
regex.compile(/^#REDIRECT\s*\[\[(.*)\]\]/i);
match = regex.exec(revisions[0].textContent);
if (match) {
// postArti += '<a style="color:red;" href="'+wgServer+'/wiki/'+encodeURIComponent(match[1])+'" target="_new">'+match[1]+'</a>';
postArti += '<a style="color:red" href="javascript:;" onClick="liveArticle(\''+match[1]+'\');">'+match[1]+'</a>';
} else {
// postArti += '<a style="color:red;" href="'+wgServer+wgScriptPath+'/index.php?title='+encodeURI(title)+'&redirect=no" target="_new">/!\\</a>';
postArti += '<a style="color:red" href="javascript:;" onClick="liveArticle(\''+title+'\');">'+title+'</a>';
}
} */
// arti = '<a style="'+artiStyle+'" href="'+wgServer+wgScriptPath+'/index.php?title='+encodeURI(title)+'&redirect=no" target="_new">'+title+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+title+'\');">'+title+'</a>';
} else {
// arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+title+'\');">'+title+'</a>';
// arti = '<a href="#" mousebotton="right" onmousedown="window.open(\'http://fr.wikipedia.org/\')">'+title+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+title+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
else if (state & NEWUSER) {
 
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/c/c1/Crystal_personal.png" width="20px" alt="Nuovo utente" />';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
else if (state & BLOCK) {
// artiStyle = 'color: magenta; font-weight: bold; font-style: italic;';
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/6/64/Crystal_Clear_action_lock3.png" width="20px" alt="Blocca" />';
postArti += ' <a href="javascript:;" onClick="liveLog("block",\''+rc.title+'\');">('+rc.duration+')</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');">'+title+'</a>';
}
else if (state & DELETE) {
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/e/ef/Editcut.png" width="20px" alt="Cancella" />';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
else if (state & PROTECT) {
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/7/72/Crystal_Clear_app_agent.png" width="20px" alt="Proteggi" />';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
else {
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\',\''+user+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • ' + edit + admin + ' • </small>'
+ preArti + arti + postArti;
Ligne 916 ⟶ 1 011 :
th1.style.border="1px";
th1.style.width="40%";
 
 
// EDITOR //
Ligne 974 ⟶ 1 068 :
td3.style.border = "1px";
td3.style.width = "40%";
 
if (state & UPLOAD) {
th0.style.backgroundColor = "#D1CAFA";
th1.style.backgroundColor = "#D1CAFA";
td2.style.backgroundColor = "#D1CAFA";
td3.style.backgroundColor = "#D1CAFA";
td4.style.backgroundColor = "#D1CAFA";
tr1.style.border = "1px solid darkslateblue";
}
if (state & NEWUSER) {
th0.style.backgroundColor = "#C6FF6D";
th1.style.backgroundColor = "#C6FF6D";
td2.style.backgroundColor = "#C6FF6D";
td3.style.backgroundColor = "#C6FF6D";
td4.style.backgroundColor = "#C6FF6D";
tr1.style.border = "1px solid lime";
}
if (state & BLOCK) {
th0.style.backgroundColor = "#EECC84";
th1.style.backgroundColor = "#EECC84";
td2.style.backgroundColor = "#EECC84";
td3.style.backgroundColor = "#EECC84";
td4.style.backgroundColor = "#EECC84";
tr1.style.border = "1px solid darkgoldenrod";
}
if (state & DELETE) {
th0.style.backgroundColor = "#E7CAA7";
th1.style.backgroundColor = "#E7CAA7";
td2.style.backgroundColor = "#E7CAA7";
td3.style.backgroundColor = "#E7CAA7";
td4.style.backgroundColor = "#E7CAA7";
tr1.style.border = "1px solid saddlebrown";
}
if (state & MOVE) {
th0.style.backgroundColor = "#FDC5FF";
th1.style.backgroundColor = "#FDC5FF";
td2.style.backgroundColor = "#FDC5FF";
td3.style.backgroundColor = "#FDC5FF";
td4.style.backgroundColor = "#FDC5FF";
tr1.style.border = "1px solid magenta";
}
if (state & PROTECT) {
th0.style.backgroundColor = "#B2BCC6";
th1.style.backgroundColor = "#B2BCC6";
td2.style.backgroundColor = "#B2BCC6";
td3.style.backgroundColor = "#B2BCC6";
td4.style.backgroundColor = "#B2BCC6";
tr1.style.border = "1px solid darkslategray";
}
 
if (state & REVERT) {
Ligne 1 073 ⟶ 1 221 :
}
 
// Don't show RC if checkbox is not checked
if ((!document.getElementById('showRC').checked) &&
(!(state & UPLOAD) &&
!(state & NEWUSER) &&
!(state & BLOCK) &&
!(state & DELETE) &&
!(state & PROTECT) &&
!(state & MOVE)))
supprLigne(pageid+"_"+revid);
// Don't show Log if checkbox is not checked
if ((!document.getElementById('showLog').checked) &&
((state & UPLOAD) ||
(state & NEWUSER) ||
(state & BLOCK) ||
(state & DELETE) ||
(state & PROTECT) ||
(state & MOVE)))
supprLigne(pageid+"_"+revid);
 
// MISE A JOUR LISTES //
Ligne 1 131 ⟶ 1 298 :
function getRedirCat(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
 
var yurik = xmlreq.responseXML.getElementsByTagName('yurik')[0];
 
if (yurik.firstChild.nodeName == "error") return;
 
var rc = data.rc;
var pageid = rc.pageid;
var revid = rc.revid;
var state = rc.state;
 
var page = yurik.getElementsByTagName('pages')[0].getElementsByTagName('page')[0];
 
if (page.getElementsByTagName('redirect').length) {
state += REDIRECT;
Ligne 1 148 ⟶ 1 315 :
rc.redirect = page.getElementsByTagName('redirect')[0].getElementsByTagName('to')[0].textContent;
}
 
if (page.getElementsByTagName('categories').length) {
state += CATEGORIZED;
 
var categories = page.getElementsByTagName('categories')[0].getElementsByTagName('cl');
var i,j;
var leni = categories.length;
var lenj = categoriestests.length;
for (i=0; i<leni; i++)
for (j=0; j<lenj; j++)
Ligne 1 162 ⟶ 1 329 :
state += categoriestests[j].state;
}
 
rc.state = state;
 
getRevision(rc);
// wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=query&prop=revisions&pageids=' + pageid + '&rvstartid=' + revid + '&rvlimit=1&rvprop=content&format=xml',
// onSuccess: getRevision, rc: rc });
}
 
function getRedirCat2(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
var yurik = xmlreq.responseXML.getElementsByTagName('yurik')[0];
if (yurik.firstChild.nodeName == "error") return;
var log = data.log;
var pageid = log.pageid;
var revid = log.revid;
var state = log.state;
var page = yurik.getElementsByTagName('pages')[0].getElementsByTagName('page')[0];
if (page.getElementsByTagName('redirect').length) {
state += REDIRECT;
if (page.getElementsByTagName('redirect')[0].getElementsByTagName('to').length)
log.redirect = page.getElementsByTagName('redirect')[0].getElementsByTagName('to')[0].textContent;
}
if (page.getElementsByTagName('categories').length) {
state += CATEGORIZED;
var categories = page.getElementsByTagName('categories')[0].getElementsByTagName('cl');
var i,j;
var leni = categories.length;
var lenj = categoriestests.length;
for (i=0; i<leni; i++)
for (j=0; j<lenj; j++)
if (new RegExp(lang_category+categoriestests[j].regex, "i").test(categories[i].textContent))
state += categoriestests[j].state;
}
log.state = state;
getRevision(log);
// wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=query&prop=revisions&pageids=' + pageid + '&rvstartid=' + revid + '&rvlimit=1&rvprop=content&format=xml',
// onSuccess: getRevision, rc: rc });
}
// Get RC and Log
function getRC(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
Ligne 1 244 ⟶ 1 453 :
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + encodeURIComponent(rc.title) + '&what=redirects|categories&format=xml',
onSuccess: getRedirCat, rc: rc });
}
 
// Log
var logs = api.getElementsByTagName('query')[0].getElementsByTagName('logevents')[0].getElementsByTagName('item');
var i,j,leni,lenj,log;
leni=logs.length;
for (i=leni-1; i>=0; i--) {
if (logs[i].getAttribute('timestamp').replace(new RegExp(/\D/g), "") <= lasttimestamp) continue;
log = new Object();
log.state = 0;
lenj = logs[i].attributes.length;
for (j=0; j<lenj; j++) {
if (logs[i].attributes[j].name == 'type')
{
switch(logs[i].attributes[j].value) {
case 'patrol':
// I "Segna come verificata" non li cago
// rc.state += PATROL;
break;
case 'newusers':
log.state += NEWUSER;
break;
case 'upload':
log.state += UPLOAD;
break;
case 'block':
log.state += BLOCK;
if (logs[i].firstChild)
log.duration = logs[i].firstChild.attributes[1].value;
break;
case 'delete':
log.state += DELETE;
break;
case 'move':
log.state += MOVE;
if (logs[i].firstChild)
log.new_title = logs[i].firstChild.attributes[1].value;
case 'protect':
log.state += PROTECT;
break;
default:
break;
}
}
else
log[logs[i].attributes[j].name] = logs[i].attributes[j].value;
}
if (typeof(log.comment) != "undefined") {
lenj = commenttests.length;
for (j=0; j<lenj; j++)
if (new RegExp(commenttests[j].regex).test(log.comment))
log.state += commenttests[j].state;
}
if (lstSysop.indexOf(log.user) != -1)
log.state += SYSOP;
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + encodeURIComponent(log.title) + '&what=redirects|categories&format=xml',
onSuccess: getRedirCat2, log: log });
}
 
Ligne 1 323 ⟶ 1 595 :
'<input id="showDiffR" type="checkbox" />' +
'<label for="showDiffR">'+ lang_menu[0].LOWDIFF + '</label>' +
'<input id="shidRC" type="checkbox" checked onclick="showHideObj(this, \'divTabRC\');" />' +
'<label for="shidRC">' + lang_menu[0].RCLABEL + '</label>' +
'<input id="showBot" type="checkbox" checked />' +
'<label for="showBot">' + lang_menu[0].NOBOTS + '</label>' +
'<input id="showIP" type="checkbox" />' +
'<label for="showIP">' + lang_menu[0].IPONLY + ' • </label>' +
'<input id="showRC" type="checkbox" checked />' +
'<label for="showRC">' + lang_menu[0].RCLABEL + ' • </label>' +
'<input id="showLog" type="checkbox" />' +
'<label for="showLog">' + lang_menu[0].LOGSHOW + ' • </label>' +
'<span id="selectNS" />';
 
// '<input id="shidRC" type="checkbox" checked onclick="showHideObj(this, \'divTabRC\');" />' +
// '<label for="shidRC">' + lang_menu[0].RCLABEL + '</label>' +
 
if (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight;