Wikipedia:Monobook.js/LiveRC.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 70:
var HOMONYMIE = 2 << 14;
var ADQ = 2 << 15;
var
var
var
var
var
var DELETE = 2 << 21;
var MOVE = 2 << 22;
var PROTECT = 2 << 23;
var lstSysop = new Array(); // Sysop list;
Riga 391 ⟶ 394:
function getArticle(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>';
}
/* </source>
=== LiveLog ===
<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=Speciale:Registri&type=' + action + "&user=&page=" + encodeURIComponent(page), onSuccess: getLog, message: page });
}
function getLog(xmlreq, data) {
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
Riga 771 ⟶ 827:
var ns = rc.ns;
var state = rc.state;
// ONLY LOG
var type = rc.type;
var new_title = rc.new_title;
var duration = duration;
regex.compile(/\'/g);
Riga 812 ⟶ 873:
if (state & NEW)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveArticle(\''+escTitle+'\');'+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 = '';
var edit = '';
var admin = '';
// Don't show link for log rows
if (!(state & UPLOAD) &&
!(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>';
}
}
Riga 846 ⟶ 931:
if (state & PAS)
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cestino_pieno_architetto_01.svg/11px-Cestino_pieno_architetto_01.svg.png" height="11px" alt="Voci da cancellare" /> ';
// Adq ? ;
Riga 856 ⟶ 936:
if (state & ADQ)
postArti += '<sup><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Fairytale_bookmark_gold.png/10px-Fairytale_bookmark_gold.png" width="10px" alt="Voci in vetrina" /></sup>';
// Article catégorisé ? ;
Riga 876 ⟶ 946:
postArti += '<sup style="color:crimson">(cat ?)</sup>';
// Redirect, Log, or simple edit ? ;
//////////////////
if (state &
// 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+'\');">'+rc.new_title+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\');">'+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="Redirect" />';
postArti += ' <a href="javascript:;" onClick="liveArticle(\''+rc.redirect+'\');">'+rc.redirect+'</a>';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\');">'+title+'</a>';
}
else if (state & UPLOAD) {
postArti += ' <img src="http://upload.wikimedia.org/wikipedia/commons/4/47/Gartoon-Gnome-dev-floppy.png" width="20px" alt="Carica" />';
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\');" 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+'\');" 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+'\');">'+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+'\');" 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+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
else {
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+escTitle+'\');" onDblClick="window.open(\''+wgServer+'/wiki/'+encodeURI(title)+'\');">'+title+'</a>';
}
Riga 968 ⟶ 1 050:
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) {
Riga 1 058 ⟶ 1 194:
else
tab.appendChild(tr1);
if (elold == null || typeof(oldid) == "undefined") {
if (tab.childNodes.length > lrcRCLimit) {
var idt = tab.lastChild.id;
Riga 1 067 ⟶ 1 203:
}
// 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 //
Riga 1 164 ⟶ 1 319:
}
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;
Riga 1 171 ⟶ 1 368:
if (api.firstChild.nodeName == "error") return;
// RC
var rcs = api.getElementsByTagName('query')[0].getElementsByTagName('recentchanges')[0].getElementsByTagName('rc');
var i,j,leni,lenj,rc;
Riga 1 240 ⟶ 1 439:
}
// 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;
var mitigating = (lstContact[log.user])
|| (lstRevoc[log.user])
|| (log.user == wgUserName);
if (document.getElementById('showIP').checked
&& !(log.state & IP)
&& !mitigating ) continue;
if (lstHidden[log.user] && !mitigating) continue;
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + encodeURIComponent(log.title) + '&what=redirects|categories&format=xml',
onSuccess: getRedirCat2, log: log });
}
lastrevid = rcs[0].getAttribute('revid');
lasttimestamp = rcs[0].getAttribute('timestamp').replace(new RegExp(/\D/g), "");
Riga 1 323 ⟶ 1 595:
'<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].RCSHOW + ' • </label>' +
'<input id="showLog" type="checkbox" checked />' +
'<label for="showLog">' + lang_menu[0].LOGSHOW + ' • </label>' +
'<span id="selectNS" />';
if (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight;
|