User:EDUCA33E/LiveRC.js: Difference between revisions

Content deleted Content added
EDUCA33E (talk | contribs)
Init LiveRC
 
EDUCA33E (talk | contribs)
v0.3.3
Line 1:
/*
==LiveWP==
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Authors : [[:fr:User:EDUCA33E]] & [[:fr:User:TiChou]]
*Version: 0.3.3 (beta)
 
Version modifiée basée sur la version du 1er avril 2007 à 00:49 :
===Utilitaires===
 
http://fr.wikipedia.org/w/index.php?title=User:EDUCA33E/LiveRC.js&oldid=15525649
 
=== Variables globales ===
 
<pre> */
var cwwpajax;
// From [[WP:US]] mainpage (wpajax renamed to cwwpajax)
cwwpajax={
download:function(bundle) {
// mandatory: bundle.url
// optional: bundle.onSuccess (xmlhttprequest, bundle)
// optional: bundle.onFailure (xmlhttprequest, bundle)
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure
var x = window.XMLHttpRequest ? new XMLHttpRequest()
: window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
: false;
if (x) {
x.onreadystatechange=function() {
x.readyState==4 && cwwpajax.downloadComplete(x,bundle);
};
x.open("GET",bundle.url,true);
x.send(null);
}
return x;
},
 
if (wgTitle == "EDUCA33E/LiveRC") {
downloadComplete:function(x,bundle) {
 
x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
// Appel des paramètres par défaut de LiveRC ;
|| ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText));
// ///////////////////////////////////////////
document.write('<script type="text/javascript" src="'
+ wgServer + wgScriptPath + '/index.php?title='+wgPageName+'/LiveRCparam.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// Appel des paramètres utilisateur ;
// ///////////////////////////////////////////
document.write('<script type="text/javascript" src="'
+ wgServer + wgScriptPath + '/index.php?title=User:'+wgUserName+'/LiveRCparam.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
var lastrevid,lasttimestamp=1; // Timestamp d'initialisation;
 
// Découpage de l'URL et de ses paramètres;
 
var _GET = new Array();
var _uri = ___location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURIComponent(_temp_get_arr_1[0])] = decodeURIComponent(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
 
// Variables d'état (pour test sur rc.state);
 
var IP = 1;
var BOT = 2 << 0;
var SYSOP = 2 << 1;
var NEW = 2 << 2;
var MINOR = 2 << 3;
var NEWNS = 2 << 4;
var RENAMED = 2 << 5;
var PATROLLED = 2 << 6;
var REVERT = 2 << 7;
var BLANKING = 2 << 8;
var REPLACED = 2 << 9;
var REDIRECT = 2 << 10;
var CATEGORIZED = 2 << 11;
var LOCK = 2 << 12;
var FULLLOCK = 2 << 13;
var HOMONYMIE = 2 << 14;
var ADQ = 2 << 15;
var BA = 2 << 16;
var APDQ = 2 << 17;
var COPYRIGHT = 2 << 18;
var PAS = 2 << 19;
var FIRE = 2 << 20;
 
var lstSysop = new Array(); // Liste des Sysop;
var lstContact = new Array(); // Gestion liste de contact;
var lstRevoc = new Array(); // Gestion liste des révoc;
 
/* // Gestion liste de suivi;
var lstSuivi = new Array();
var lstSuiviHH = new Array(); */
}
 
/* </pre>
 
===Utilitaires===
 
<pre> */
var wpajax = {
http: function(bundle) {
// mandatory: bundle.url
// optional: bundle.async
// optional: bundle.method
// optional: bundle.headers
// optional: bundle.data
// optional: bundle.onSuccess (xmlhttprequest, bundle)
// optional: bundle.onFailure (xmlhttprequest, bundle)
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp = false
}
}
}
 
if (xmlhttp) {
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4)
wpajax.httpComplete(xmlhttp,bundle);
};
xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true);
if (bundle.headers) {
for (var field in bundle.headers)
xmlhttp.setRequestHeader(field,bundle.headers[field]);
}
xmlhttp.send(bundle.data ? bundle.data : null);
}
return xmlhttp;
},
 
httpComplete: function(xmlhttp,bundle) {
if (xmlhttp.status == 200 || xmlhttp.status == 302) {
if (bundle.onSuccess)
bundle.onSuccess(xmlhttp,bundle);
} else if (bundle.onFailure) {
bundle.onFailure(xmlhttp,bundle);
} else {
// A activer en debug mode ?
// alert(xmlhttp.statusText);
}
}
};
 
Line 56 ⟶ 155:
 
=== LiveDiff ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
 
<pre> */
 
function liveDiff(page, id, oldid) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b>Recherche du diff de : <span style='color:red'>"+page+"</span> en cours...</b>";
cwwpajax wpajax.downloadhttp({ url: wgServer + wgScriptPath + '/index.php?title='+encodeURI(page)+'&diffonly=1&diff='+id+'&oldid='+oldid,
onSuccess: getDiff, mpage: page, mid: id, moldid:oldid});
}
 
Line 81 ⟶ 177:
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',doc,'td');
if (user1 != null && user1[0].getElementsByTagName('a' != null)[2].innerHTML;
user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',doc,'td');
if (user2 != null && user2[0].getElementsByTagName('a' != null)[2].innerHTML;
user2 = user2[0].getElementsByTagName('a')[2].innerHTML;
if (user2 == "défaire"){
if (user2 == "défaire") {
user2 = getElementsByClass('diff-ntitle',doc,'td');
user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
Line 90 ⟶ 188:
user1=user1.replace(new RegExp(/\'/g), "\\'");
user2=user2.replace(new RegExp(/\'/g), "\\'");
var upage=page.replace(new RegExp(/\'/g), "\\'");
 
if (lD[0] == null)
LP.innerHTML = bC.innerHTML;
else {
if (document.getElementById('showDiffR').checked) {
{
if(document.getElementById('showDiffR').checked) {
var avantEl = getElementsByClass('diff-deletedline',bC,null);
var apresEl = getElementsByClass('diff-addedline',bC,null);
Line 112 ⟶ 210:
}
}
if (dLP.style.display == "none") {
var elcb = document.getElementById( 'shidPrev' );
elcb.checked="true";
dLP.style.display = "inline";
}
var entete = document.getElementById( 'livePreviewTitle' );
entete.innerHTML='<b>Dernier diff de : <a href="'+wgServer+'/wiki/'+encodeURI(page)+'">'+page+'</a></b>';
 
var optAvert = "";
entete.innerHTML = '<table width="100%" class="creator"><tr><td>'+entete.innerHTML +'</td><td align="right"><small>'+
var optl = lstAvert.length;
'[<a href="javascript:var message=getLiveMessage(\'liverevert\',\''+user1+'\',\''+user2+'\',\''+page+'\',\''+oldid+'\');">Annuler</a>] • ' +
for (j=0; j<optl; j++) {
'[<a href="javascript:var message=getLiveMessage(\'livevandalism\',\''+user1+'\',\''+user2+'\',\''+page+'\',\''+oldid+'\');">Vandalism</a>] • ' +
optAvert += '<option value="'+lstAvert[j].template;
'Raison : <input id="LiveRevertMessage" /> ••• ' +
if(lstAvert[j].hasPage) optAvert += '|'+upage;
'[<a href="javascript:var message=getLiveAverto(\''+user2+'\');">Avertir</a>] : ' +
optAvert += '">'+lstAvert[j].string+'</option>';
'<select id="averto">' +
}
'<option value="Test 0">Test 0</option>' +
 
'<option value="Test 1">Test 1</option>' +
var entete = document.getElementById( 'livePreviewTitle' );
'<option value="Test 2">Test 2</option>' +
entete.innerHTML='<b>Dernier diff de : <a href="'+wgServer + '/wiki/' + encodeURI(page) + '">' + page + '</a></b> • ' +
'<option value="Test 3">Test 3</option>' +
'(<a href="javascript:;" onClick="liveHist(\''+upage+'\');" style="color:darkorange">Hist</a>)';
'<option value="Vandalisme|'+page+'">Vandal</option>' +
entete.innerHTML = '<table width="100%" class="creator"><tr><td>' + entete.innerHTML +
'<option value="Spammeur|'+page+'">Spam</option>' +
'<option/td><td valuealign="Coucouright">Coucou</optionsmall>' +
// Verifier avant si le patrouilleur peut modifier cette page ? (query.php?what=permissions&titles=page)
'<option value="Motivation_modif|'+page+'">Résumé</option>' +
'[<a id="LiveRevertLink" href="javascript:getLiveMessage(\'liverevert\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >'+lang_menu[0].UNDORC+'</a>] • ' +
'<option value="Signature">Signature</option>' +
'[<a id="LiveVandalismLink" href="javascript:getLiveMessage(\'livevandalism\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >'+lang_menu[0].REVERT+'</a>] • ' +
'<option value="Bienvenue_copyright|'+page+'">Copyright</option>' +
lang_menu[0].REASON+' : <input id="LiveRevertMessage" /> ••• ' +
'</select>' +
'[<a id="LiveAvertoLink" href="javascript:getLiveAverto(\''+user2+'\');">'+lang_menu[0].AVERTS+'</a>] : ' +
'</td></tr></table>';
'<select id="averto">' + optAvert + '</select>' +
'</td></tr></table>';
document.getElementById('LiveRevertMessage').focus();
}
 
function getLiveAverto(user) {
var avertolink = document.getElementById('avertoLiveAvertoLink').value;
link.href = "javascript:;";
averto=averto.replace(new RegExp(/\'/g), "\\'");
link.style.color = "silver";
user=user.replace(new RegExp(/\'/g), "\\'");
link.style.cursor = "default";
window.open(wgServer+'/w/index.php?title=User_talk:'+user+'&action=edit&lwarn='+encodeURI(averto));
link.style.textDecoration = "none";
document.getElementById('averto').disabled = true;
var message = document.getElementById('averto').value;
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=User_Talk:' + encodeURIComponent(user) + '&action=edit',
onSuccess: postLiveAverto,
user: user, message: message });
}
 
function getLiveMessage postLiveAverto(where, user1, user2, pagexmlreq, oldiddata) {
var parser = new DOMParser();
var message = document.getElementById('LiveRevertMessage');
var doc = parser.parseFromString(xmlreq.responseText, 'application/xhtml+xml');
window.open(wgServer + '/w/index.php?title=' + page + '&action=edit&oldid=' + oldid + '&'+where+'=1&user1='+user1+'&user2='+user2+'&message='+encodeURI(message.value));
}
 
var user = data.user;
function queryString(p) {
var remessage = RegExp('[&?]' + p + '=([^&]*)')data.message;
 
var matches;
var wpTextbox1 = encodeURIComponent('{{subst:' + message + '}} ~~~~\n' + doc.getElementById('wpTextbox1').value);
if (matches = re.exec(document.___location)) {
 
try {
var inputs = doc.getElementById('editform').getElementsByTagName('input');
return decodeURI(matches[1]);
var editform }= catchnew Array(e) {;
for (i=0; i<inputs.length; i++) {
}
editform[inputs[i].name] = inputs[i].value;
}
var wpStarttime = encodeURIComponent(editform['wpStarttime']);
return null;
var wpEdittime = encodeURIComponent(editform['wpEdittime']);
};
var wpEditToken = encodeURIComponent(editform['wpEditToken']);
 
var wpSummary = encodeURIComponent('LiveRC : Avertissement ! ' + message.replace(new RegExp(/\|(.*)/), ' sur [[$1]]') + ' !');
 
var _GETheaders = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
var _uri = ___location.href;
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=User_Talk:' + encodeURIComponent(user) + '&action=submit',
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
method: "POST", headers: headers,
var _temp_get_arr_1 = new Array();
data: 'wpSave=1&wpTextbox1=' + wpTextbox1 + '&wpStarttime=' + wpStarttime + '&wpEdittime=' + wpEdittime
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
+ '&wpEditToken=' + wpEditToken + '&wpSummary=' + wpSummary});
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
 
function getLiveMessage(where, user1, user2, page, oldid) {
 
var links = [ document.getElementById('LiveRevertLink'), document.getElementById('LiveVandalismLink') ];
addOnloadHook(function () {
var i,len=links.length;
if(___location.href.match(/liverevert=1/)) {
for (i=0; i<len; i++) {
var message = "";
links[i].href = "javascript:;";
if(_GET['message'] != null && _GET['message'] !="" ) message=" ("+_GET['message']+")";
links[i].style.color = "silver";
document.getElementById('wpSummary').value = 'Révocation des modifications par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]) via LiveRC' + message;
links[i].style.cursor = "default";
document.getElementById('editform').submit();
links[i].style.textDecoration = "none";
}
document.getElementById('LiveRevertMessage').disabled = true;
});
var message = document.getElementById('LiveRevertMessage').value;
addOnloadHook(function () {
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&action=edit&oldid=' + oldid,
if(___location.href.match(/livevandalism=1/)) {
onSuccess: postLiveRevert,
var message = "";
where: where, page: page, user1: user1, user2: user2, message: message });
if(_GET['message'] != null && _GET['message'] !="" ) message=" (_GET['message'])";
}
document.getElementById('wpSummary').value = 'Révocation de vandalisme par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] via LiveRC)' + message;
 
document.getElementById('editform').submit();
function postLiveRevert(xmlreq, data) {
}
var parser = new DOMParser();
});
var doc = parser.parseFromString(xmlreq.responseText, 'application/xhtml+xml');
addOnloadHook(function () {
if(___location.href.match(/lwarn=/)) {
var what = _GET['lwarn'];
 
var where = data.where;
Textbox1 = '{{subst:'+_GET['modele']+'}} ~~~~';
var page = data.page;
var user1 = data.user1;
var user2 = data.user2;
var message = data.message;
 
var wpTextbox1 document= encodeURIComponent(doc.getElementById('wpSummarywpTextbox1').value = 'Avertissement : '+what+' (via LiveRC)';
 
document.getElementById('wpTextbox1').value = '{{'+what+'}} ~~'+'~~\n' + document.getElementById('wpTextbox1').value;
var inputs document= doc.getElementById('editform').submitgetElementsByTagName('input');
var editform = new Array();
for (i=0; i<inputs.length; i++) {
editform[inputs[i].name] = inputs[i].value;
}
var wpStarttime = encodeURIComponent(editform['wpStarttime']);
});
var wpEdittime = encodeURIComponent(editform['wpEdittime']);
var wpEditToken = encodeURIComponent(editform['wpEditToken']);
 
switch(where) {
//
case 'liverevert':
var wpSummary = 'LiveRC : Révocation des modifications de [[Special:Contributions/' + user2 + '|' + user2
+ ']]; retour à la version de [[User:' + user1 + '|' + user1 + ']]';
break;
case 'livevandalism':
var wpSummary = 'LiveRC : Révocation de vandalisme par [[Special:Contributions/' + user2 + '|' + user2
+ ']]; retour à la version de [[User:' + user1 + '|' + user1 + ']]';
break;
}
if (message)
wpSummary = wpSummary + ' ; ' + message;
wpSummary = encodeURIComponent(wpSummary);
 
var headers = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&action=submit',
method: "POST", headers: headers,
data: 'wpSave=1&wpTextbox1=' + wpTextbox1 + '&wpStarttime=' + wpStarttime + '&wpEdittime=' + wpEdittime
+ '&wpEditToken=' + wpEditToken + '&wpSummary=' + wpSummary});
}
 
/* </pre>
 
=== LiveHist ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
 
<pre> */
 
function liveHist(page) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b>Recherche de l'historique de : <span style='color:red'>"+page+"</span> en cours...</b>";
cwwpajax wpajax.downloadhttp({url:wgServer + wgScriptPath + '/index.php?title=' + encodeURI(page) + '&action=history', onSuccess: getHist, message: page });
onSuccess: getHist, message: page });
}
 
Line 228 ⟶ 358:
var dLP = document.getElementById( 'divLivePreview' );
LP.innerHTML = bC.innerHTML;
if (dLP.style.display == "none") {
var elcb = document.getElementById( 'shidPrev' );
elcb.checked="true";
Line 236 ⟶ 366:
elt.innerHTML='<b>Historique de : <a href="'+wgServer+'/wiki/'+encodeURI(c)+'">'+c+'</a></b>';
}
 
/* </pre>
 
=== LiveContrib ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
 
<pre> */
 
function liveContrib(user) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b>Recherche des contributions de : <span style='color:red'>"+user+"</span> en cours...</b>";
cwwpajax wpajax.downloadhttp({url:wgServer + wgScriptPath + 'iki/wiki/Special:Contributions/'+encodeURI(user),
onSuccess: getContrib, message: user });
}
Line 255 ⟶ 383:
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
var cuser=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 utilde=user.replace(new RegExp(/\'/g), "\\'");
var elt = document.getElementById( 'livePreviewTitle' );
 
elt.innerHTML='<b>Contributions de : <a href="'+wgServer+'/wiki/User:'+encodeURI(c)+'">'+c+'</a></b>';
var optAvert = "";
var optl = lstAvert.length;
for (j=0; j<optl; j++) {
if(lstAvert[j].hasPage) continue;
optAvert += '<option value="'+lstAvert[j].template+'">'+lstAvert[j].string+'</option>';
}
 
var entete = document.getElementById( 'livePreviewTitle' );
entete.innerHTML='<b>Contributions de : <a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a></b>';
entete.innerHTML = '<table width="100%" class="creator"><tr><td>'+entete.innerHTML +
'</td><td align="right"><small>' +
'[<a href="javascript:var message=getLiveAverto(\''+utilde+'\');">Avertir</a>] : ' +
'<select id="averto">' + optAvert + '</select>' + '</td></tr></table>';
}
 
Line 271 ⟶ 412:
 
=== LiveSuivi ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
 
<pre> */
 
var lstSysop = new Array();
 
function liveSysop() {
cwwpajax wpajax.downloadhttp({url:wgServer + wgScriptPath + '/index.php?title=Special:Listusers&limit=500&group=sysop',
onSuccess: getSysop, message: "Récup sysoplist" });
}
Line 290 ⟶ 426:
var info="";
var len = lstSys.length
for(var i=0; i < len ; i++) {
{
info=lstSys[i].getElementsByTagName( 'a' )[ 0 ].innerHTML;
lstSysop.push(info);
}
}
 
liveNS();
var lstSuivi = new Array();
}
var lstSuiviHH = new Array();
 
/* function liveWatch() {
cwwpajax wpajax.downloadhttp({url:wgServer + wgScriptPath + '/api.php?action=query&list=watchlist&wllimit=500&format=xml',
onSuccess: getWatch, message: "Récup watchlist" });
}
Line 309 ⟶ 443:
var c=data.message;
var i;
// document.getElementById('debug').innerHTML = a+"<br />**************************";
if(a.indexOf("<error>")!=-1) return; //cat is empty, nothing to do here
if(a.indexOf("<error")!=-1) {
var lvSuivi = document.getElementById( 'liveSuivi' );
lvSuivi.innerHTML = "<small>Suivi désactivé. (API.php : watchlist)</small>";
return;
}
a=a.split("title=\"");
var info="";
for(i=a.length-1; i >= 0 ; i--) {
{
info=a[i].substr(0,a[i].indexOf("\" pageid"));
if (info == "") continue;
lstSuivi.push(info);
lstSuiviHH.push("--:--");
}
//document.getElementById('debug').innerHTML += lstSuivi;
}
} */
 
var menu = '<input id="stopLive" type="checkbox" value="true" />' +
'<label for="stopLive">Pause</label>' +
'<input id="shidPrev" type="checkbox" onclick="showHideObj(this, \'divLivePreview\');" />' +
'<label for="shidPrev">Prévisualiser</label>' +
'<input id="shidList" type="checkbox" onclick="showHideObj(this, \'liveFollow\');" />' +
'<label for="shidList">Listes</label>' +
'<input id="showDiffR" type="checkbox" />' +
'<label for="showDiffR">Diff réduit</label>' +
'<input id="shidRC" type="checkbox" checked onclick="showHideObj(this, \'divTabRC\');" />' +
'<label for="shidRC">RC</label>' +
'<input id="showBot" type="checkbox" checked />' +
'<label for="showBot">Sans Bots</label>' +
'<input id="showIP" type="checkbox" />' +
'<label for="showIP">IP seules • </label>' +
'<span id="selectNS" />';
 
function liveNS() {
cwwpajax wpajax.downloadhttp({url: wgServer + wgScriptPath + '/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml',
onSuccess: getNS, message: "Récup NS" });
}
 
function getNS(xmlreq, data) {
var aapi = xmlreq.responseTextresponseXML;
 
var c=data.message;
if (api.firstChild.nodeName == "error") return;
 
var nss = api.getElementsByTagName('query')[0].getElementsByTagName('namespaces')[0].getElementsByTagName('ns');
var len = nss.length;
var i;
var id,ns;
if(a.indexOf("<error>")!=-1) return; //cat is empty, nothing to do here
var options = "";
//a = a.replace(new RegExp(/.ns id=.(.*)..(.*)...../g), "<ns>$1</ns><lib>$1</lib>");
var lstNs = new Array();
//a = a.replace(new RegExp(/.ns id=.0. ../g), "<ns>0</ns><lib>Articles</lib>");
 
var nsid=a.split("<ns id=\"");
for (i=0; i<len; i++) {
//var nslb=a.split("<lib>");
id = nss[i].getAttribute('id');
var info="";
ns = nss[i].textContent;
var info2="";
 
var lstNS = '<option value="*">Tout</option>';
if (id < 0) continue;
var len=nsid.length;
for if (varid i=1;= i0) <ns len= "Article"; i++)
 
{
options += '<option value="' + id + '">' + ns + '</option>';
info =nsid[i].substr(0,nsid[i].indexOf("\""));
lstNs.push(id);
if (info == "") continue;
if(info==0)
info2 = "Articles";
else
info2=info +": "+nsid[i].substr(nsid[i].indexOf("\">")+2,nsid[i].indexOf("</ns>")-1);
lstNS = lstNS + '<option value="'+info+'">'+ info2 +'</option>';
}
options = '<option value="' + lstNs.join('|') + '">*</option>' + options;
var slcNS = document.getElementById( 'selectNS' );
slcNSdocument.getElementById('selectNS').innerHTML = '<label for="showNS0">Espace'+lang_menu[0].NAMESP+' </label><select id="showNS0">' + lstNSoptions + '</select>';
 
liveRC();
}
 
/* </pre>
 
=== LiveRC ===
function liveBlock() {
 
cwwpajax.download({url:wgServer + wgScriptPath + '/api.php?action=query&list=logevents&letype=block&format=xml',
<pre> */
onSuccess: getBlock, message: "Récup des blocages" });
 
function supprLigne(quelLigne) {
var tab = document.getElementById('tabRC');
var els = new Array();
if (quelLigne == '*')
els = tab.getElementsByTagName('tr');
else
els.push(document.getElementById(quelLigne));
var len = els.length;
for (var i=len-1; i>=0; i--)
if (els[i] != null)
tab.removeChild(els[i]);
}
 
function getBlockchangeLigne(xmlreq, dataquelLigne) {
var el = document.getElementById(quelLigne);
var a=xmlreq.responseText;
var cels1 =data el.messagegetElementsByTagName('th');
var els2 = el.getElementsByTagName('td');
var i;
var len = els1.length;
for (var i=len-1; i>=0; i--)
if (els1[i] != null)
els1[i].style.backgroundColor = "#DCDCDC";
var len = els2.length;
for (var i=len-1; i>=0; i--)
if (els2[i] != null)
els2[i].style.backgroundColor = "#F5F5F5";
}
 
function getElementsByClass(searchClass,node,tag) {
var dbug = document.getElementById( 'debug' );
var classElements = new Array();
var xx=a.split("title=\"");
if ( node == null )
dbug.innerHTML = "Debug: <br />"+xx+"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />";
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
for (i = 0, j = 0; i < elsLen; i++) {
if (pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
 
function tsToHhMm(timestamp) {
var now = new Date();
var tz = -now.getTimezoneOffset();
var regex = new RegExp(/.*T(\d\d):(\d\d):\d\dZ/g);
var hhmm = regex.exec(timestamp);
var tt = (hhmm[1] * 60 + hhmm[2] * 1 + tz + 1440) % 1440;
var mm = tt % 60;
var hh = (tt - mm) / 60 % 24;
return hh + ':' + mm;
}
 
function updateFollowContact() {
if(a.indexOf("<error>")!=-1) return; //cat is empty, nothing to do here
var tempAr = new Array();
a = a.replace(new RegExp(/[.]*title="[.]*:(.*)"[.]*[/s][.]*<param>(.*)<\/param><param>[.]*<\/param>/g), "<user>$1</user><param>$2</param>");
for (var user in lstContact) {
dbug.innerHTML = dbug.innerHTML+"<br />XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />"+a;
var timestamp = lstContact[user].ts;
a = a.replace(new RegExp(/[^<][^u][.*](\s)/g), "$1");
if (timestamp == 0) continue;
dbug.innerHTML = dbug.innerHTML+"<br />XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />"+a;
a var utilde = auser.replace(new RegExp(/(\s)*'/g), "$1\\'");
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(user)+'" style="color:seagreen">D</a>';
dbug.innerHTML = dbug.innerHTML+"<br />XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />"+a;
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:darkseagreen">C</a>';
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>';
var ligne = '<span id="contact-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + ' • </small>' + ueditor + '</span><br />';
tempAr.push(ligne);
}
tempAr.sort();
var lvContact = document.getElementById('liveContact');
lvContact.innerHTML = "";
var len = tempAr.length;
for (var n=len-1; n>=0; n--)
lvContact.innerHTML += tempAr[n];
}
 
function updateFollowRevoc() {
var us=a.split("<user");
var titempAr =a.split new Array("<param>");
for (var user=""; in lstRevoc) {
var timetimestamp ="" lstRevoc[user].ts;
var utilde = user.replace(new RegExp(/\'/g), "\\'");
var len=us.length;
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(user)+'" style="color:seagreen">D</a>';
for(var i=1; i < len ; i++) {
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:darkseagreen">C</a>';
user =us[i].substr(0,us[i].indexOf("</user>"));
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>';
if (user == "") continue;
var ligne = '<span id="revoc-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + ' • </small>' + ueditor + ' (' + lstRevoc[user].nb + ' '+lang_menu[0].XTIMES+')</span><br />';
time =ti[i].substr(0,ti[i].indexOf("</param>"));
tempAr.push(ligne);
var isRevoq = followRevoc.indexOf(user);
if(isRevoq != -1) {
followRevocHH[isrevoq] = "<span style='color:red'>lock/"+time+"</span>";
}
}
updateFollowRevoctempAr.sort();
var lvRevoc = document.getElementById('liveRevoc');
lvRevoc.innerHTML = "";
var len = tempAr.length;
for (var n=len-1; n>=0; n--)
lvRevoc.innerHTML += tempAr[n];
}
 
function getRevision(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
 
var api = xmlreq.responseXML.getElementsByTagName('api')[0];
/* </pre>
 
if (api.firstChild.nodeName == "error") return;
=== LiveRCparam ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
 
var rc = data.rc
<pre>*/
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 timestamp = rc.timestamp;
var ns = rc.ns;
var state = rc.state;
 
var revisions = api.getElementsByTagName('query')[0].getElementsByTagName('pages')[0].getElementsByTagName('page')[0].getElementsByTagName('revisions')[0].getElementsByTagName('rev');
var rclimit = 30;
var lstContact = new Array();
 
var oldsize = (state & NEW ? 0 : revisions[1].textContent.length);
document.write('<script type="text/javascript" src="'
var newsize = revisions[0].textContent.length
+ wgServer + wgScriptPath + '/index.php?title=User:'+wgUserName+'/LiveRCparam.js'
var sizediff = newsize - oldsize;
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
/* </pre>
 
// INITIALISATION LIGNE RC //
=== LiveRC ===
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Author : [[:fr:User:EDUCA33E]]
*Version: 0.1.0 (beta)
<pre> */
 
var tr1 = document.createElement('tr');
lstContact.push(wgUserName);
 
var th0 = document.createElement('th');
var dontShowThisRev = new Array();
var th1 = document.createElement('th');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
var td4 = document.createElement('td');
 
function supprLigne(quelLigne) {
dontShowThisRev.push(quelLigne);
var tab = document.getElementById( 'tabRC' );
var el = document.getElementById( quelLigne );
if(el != null)
tab.removeChild(el);
}
 
// SUPPR. LIGNE //
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
 
th0.innerHTML = '<a href="javascript:;" onClick="supprLigne(\''+pageid+'_'+revid+'\');" style="color:red">X</a>';
function updateFollowRevoc() {
 
var tempAr = new Array();
 
var len = followRevoc.length;
// ARTICLE //
for (var n = 0; n < len; n++) {
 
var utilde = followRevoc[n].replace(new RegExp(/\'/g), "\\'");
var arti = "", artiStyle = "";
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(followRevoc[n])+'" style="color:seagreen">D</a>';
var preArti = "", postArti = "";
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:darkseagreen">C</a>';
 
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(followRevoc[n])+'">'+followRevoc[n]+'</a>';
var ctilde = title.replace(new RegExp(/\'/g), "\\'");
var ligne = '<small>' + followRevocHH[n] +' • '+ udiscut +' • ' + ucontrib + ' • </small>' + ueditor + " (" + followRevocNb[n] + " fois)<br />";
var diff = "";
tempAr.push(ligne);
var diffClose = "";
if (autoCloseDiff == 1)
diffClose='supprLigne(\''+pageid+'_'+revid+'\');';
if (state & NEW)
diff = '<span style="color:silver">Diff</span>';
else
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveDiff(\''+ctilde+'\','+revid+','+oldid+');'+diffClose+'" style="color:orange">Diff</a>';
var hist = '<a href="javascript:;" onClick="liveHist(\''+ctilde+'\');" style="color:darkorange">Hist</a>';
 
// Homonymie ? ;
////////////////
if (ns == 0 && state & HOMONYMIE) {
artiStyle = 'color: darkorange; font-weight: bold; font-style: italic;';
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Disambig.svg/16px-Disambig.svg.png" width="16px" alt="Homonymie" /> '
}
 
tempAr.sort();
// Page protégée ? ;
var lvRevoc = document.getElementById( 'liveRevoc' );
////////////////////
lvRevoc.innerHTML = "";
if (state & FULLLOCK)
for (var n=len-1; n >= 0; n--) {
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Padlock-red.svg/16px-Padlock-red.svg.png" width="16px" alt="Article protégé"/> ';
lvRevoc.innerHTML = lvRevoc.innerHTML + tempAr[n];
if (state & LOCK)
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Padlock-gold.svg/16px-Padlock-gold.svg.png" width="16px" alt="Article semi-protégé"/> ';
 
// Copyright ? ;
//////////
if (state & COPYRIGHT)
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Copyright.svg/16px-Copyright.svg.png" width="16px" alt="Copyright" /> ';
 
// PàS ? ;
//////////////////
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="PàS" /> ';
 
// Intervention wikipompiers ? ;
////////////////////////////////
if (state & FIRE)
preArti += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/99/FireIcon.svg/12px-FireIcon.svg.png" height="12px" alt="Intervention Wikipompiers" /> ';
 
// Redirection ? ;
//////////////////
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="Redirection" />';
postArti += '<a href="'+wgServer+'/wiki/'+encodeURI(rc.redirect)+'">'+rc.redirect+'</a>';
}
}
 
// Adq ? ;
//var page_debug = document.getElementById( 'debug' );
//////////
//page_debug.innerHTML = "lstContact = " + lstContact;
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="Adq" /></sup>';
 
// Bon article ? ;
var lstContactActif = new Array();
//////////////////
var lstContactActifHH = new Array();
if (state & BA)
var followRevoc=new Array();
postArti += '<sup><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Fairytale_bookmark_silver_light.png/10px-Fairytale_bookmark_silver_light.png" width="10px" alt="Bon article" /></sup>';
var followRevocNb=new Array();
var followRevocHH=new Array();
 
// Article potentiellement de qualité ? ;
function getRevision(xmlreq, data) {
/////////////////////////////////////////
if(document.getElementById('stopLive').checked) return;
if (state & APDQ)
var a=xmlreq.responseText;
postArti += '<sup><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Fairytale_bookmark_light.png/10px-Fairytale_bookmark_light.png" width="10px" alt="Article potentiellement de qualité" /></sup>';
var c=data.message;
var avant=data.avant;
var i;
if(a.indexOf("<error>")!=-1) return; //cat is empty, nothing to do here
a = a.replace(new RegExp(/(timestamp|revid|pageid|oldid|user|comment)=\"([^\"]*)?\"/g), "<$1>$2</$1>");
var us=a.split("<user>");
var co=a.split("<comment>");
var re=a.split("<revid>");
var pi=a.split("<pageid>");
var ol=a.split("<oldid>");
var ts=a.split("<timestamp>");
var user="";
var comment="";
var revid="";
var pageid="";
var oldid="";
var timestamp="";
var tab = document.getElementById( 'tabRC' );
 
// Article catégorisé ? ;
for(i in us)
/////////////////////////
{
var isCategorized = "";
user =us[i].substr(0,us[i].indexOf("</user>"));
if (user!(state ==& ""REDIRECT) continue;
&& !(state & HOMONYMIE)
if(co[i] != null) comment=co[i].substr(0,co[i].indexOf("</comment>"));
&& ns == 0
revid =re[i].substr(0,re[i].indexOf("</revid>"));
&& !(state & CATEGORIZED))
pageid =pi[i].substr(0,pi[i].indexOf("</pageid>"));
postArti += '<sup style="color:crimson">(cat ?)</sup>';
oldid=avant; //oldid =ol[i].substr(0,ol[i].indexOf("</oldid>"));
timestamp =ts[i].substr(0,ts[i].indexOf("</timestamp>"));
timestamp = timestamp.replace(new RegExp(/.*T(.*):..Z/g), "$1");
 
arti = '<a style="'+artiStyle+'" href="'+wgServer+'/wiki/'+encodeURI(title)+'">'+title+'</a>';
var el = document.getElementById( pageid+"_"+revid );
th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • </small>'
var elold = document.getElementById( pageid+"_"+oldid );
+ preArti + arti + postArti;
th1.className="creator-title";
th1.style.border="1px";
th1.style.width="40%";
 
if(dontShowThisRev.indexOf(pageid+"_"+revid) != -1) continue;
 
// EDITEUR //
var ctilde = c.replace(new RegExp(/\'/g), "\\'");
var th0 = document.createElement( 'th' );
var th1 = document.createElement( 'th' );
var diff = '<a href="javascript:;" onClick="liveDiff(\''+ctilde+'\','+revid+','+oldid+');" style="color:orange">Diff</a>';
var hist = '<a href="javascript:;" onClick="liveHist(\''+ctilde+'\');" style="color:darkorange">Hist</a>';
var arti = '<a href="'+wgServer+'/wiki/'+encodeURI(c)+'">'+c+'</a>';
th0.innerHTML='<a href="javascript:;" onClick="supprLigne(\''+pageid+'_'+revid+'\');" style="color:red">X</a>';
th1.innerHTML='<small>' + timestamp + ' • ' + diff + ' • ' + hist + ' • </small>' + arti;
th1.className="creator-title";
th1.style.border="1px";
th1.style.width="40%";
var usertilde = user.replace(new RegExp(/\'/g), "\\'");
var td2 = document.createElement( 'td' );
var discut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(user)+'" style="color:seagreen">D</a>';
var contrib = '<a href="javascript:;" onClick="liveContrib(\''+usertilde+'\');" style="color:darkseagreen">C</a>';
var editor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>';
if(lstSysop.indexOf(user) != -1)
editor = '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Broom_icon.svg/400px-Broom_icon.svg.png" width="16px" />&nbsp;'+editor;
td2.innerHTML='<small>'+ discut +' • ' + contrib + ' • </small>' + editor;
td2.className="creator-name";
td2.style.border="1px";
td2.style.width="20%";
var td3 = document.createElement( 'td' );
td3.innerHTML="<small>"+comment+"</small>";
td3.style.border="1px";
td3.style.width="40%";
var tr1 = document.createElement( 'tr' );
if (comment.indexOf("Révocation") != -1
|| comment.indexOf("Annulation des modifications") != -1
|| comment.indexOf("Revert to revision") != -1
|| comment.indexOf("Revert to the revision") != -1) {
th0.style.backgroundColor = "#FFE4E1";
th1.style.backgroundColor = "#FFE4E1";
td2.style.backgroundColor = "#FFE4E1";
td3.style.backgroundColor = "#FFE4E1";
tr1.style.border = "1px solid crimson";
}
 
var usertilde = user.replace(new RegExp(/\'/g), "\\'");
if (comment.indexOf("Résumé automatique : blanchiment") != -1) {
var discut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(user)+'" style="color:seagreen">D</a>';
th0.style.backgroundColor = "white";
var contrib = '<a href="javascript:;" onClick="liveContrib(\''+usertilde+'\');" style="color:darkseagreen">C</a>';
th1.style.backgroundColor = "white";
var editor = "", td2.style.backgroundColorpreEditor = "white";
td3.style.backgroundColor = "white";
tr1.style.border = "2px double crimson";
}
if (comment.indexOf("Nouvelle page :") != -1) {
th0.style.backgroundColor = "#e2f2d2";
th1.style.backgroundColor = "#e2f2d2";
td2.style.backgroundColor = "#e2f2d2";
td3.style.backgroundColor = "#e2f2d2";
tr1.style.border = "1px solid green";
}
tr1.appendChild( th0 );
tr1.appendChild( th1 );
 
// Bot ? ;
var isIP = new RegExp(/[\d]*\.[\d]*\.[\d]*\.[\d]*/);
//////////
if(isIP.test(user)) {
if (state & BOT)
td2.style.backgroundColor = "white";
preEditor += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Nuvola_apps_kservices.png/16px-Nuvola_apps_kservices.png" width="16px" />&nbsp;';
td3.style.backgroundColor = "white";
}
 
// Sysop ? ;
var isTOR = new RegExp(/172\.[\d]*\.[\d]*\.[\d]*/);
////////////
if(isTOR.test(user))
if (state & SYSOP)
td2.style.backgroundColor = "pink";
preEditor += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Broom_icon.svg/16px-Broom_icon.svg.png" width="16px" />&nbsp;';
 
// Reverté ? ;
if(lstContact.indexOf(user) != -1) {
/////////////////
td2.style.border = "2px solid gold";
if (state & REVERT)
td2.style.backgroundColor = "yellow";
preEditor = '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Nuvola_actions_undo.png/16px-Nuvola_actions_undo.png" width="16px" />&nbsp;';
var isActif = lstContactActif.indexOf(user);
if(isActif == -1) {
lstContactActif.push(user);
lstContactActifHH.push(timestamp);
}
else {
lstContactActifHH[isActif] = timestamp;
}
var lstActif = new Array();
var len = lstContactActif.length;
for (var n = 0; n < len; n++) {
var utilde = lstContactActif[n].replace(new RegExp(/\'/g), "\\'");
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURI(lstContactActif[n])+'" style="color:seagreen">D</a>';
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:darkseagreen">C</a>';
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(lstContactActif[n])+'">'+lstContactActif[n]+'</a>';
var ligne = '<small>'+ lstContactActifHH[n] +' • ' + udiscut +' • ' + ucontrib + ' • </small>' + ueditor + "<br />"
lstActif.push(ligne)
}
lstActif.sort();
var lvContact = document.getElementById( 'liveContact' );
lvContact.innerHTML = "";
len = lstActif.length;
for (var n=len-1; n >= 0; n--) {
lvContact.innerHTML = lvContact.innerHTML + lstActif[n];
}
}
 
// TOR potentiel / AOL
if(followRevoc.indexOf(user) != -1) {
var isTOR = new RegExp(/172\.[\d]*\.[\d]*\.[\d]*/);
td2.style.border = "2px solid red";
if (isTOR.test(user))
td2.innerHTML = td2.innerHTML + '<sup style="color:red">(' + followRevocNb[followRevoc.indexOf(user)] + ' révoc)</sup>'
preEditor += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Dialog-warning.svg/16px-Dialog-warning.svg.png" width="16px" />&nbsp;';
 
editor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>';
td2.innerHTML = '<small>' + discut + ' • ' + contrib + ' • </small>'
+ preEditor + editor;
td2.className="creator-name";
td2.style.border = "1px";
td2.style.width = "20%";
 
if (lstRevoc[user]) {
td2.style.border = "2px solid red";
td2.innerHTML += '<sup style="color:red">(' + lstRevoc[user].nb + ' révoc)</sup>'
}
 
// COMMENTAIRE //
 
td3.innerHTML = "<small>" + comment + "</small>";
td3.style.border = "1px";
td3.style.width = "40%";
 
if (state & REVERT) {
th0.style.backgroundColor = "#FFE4E1";
th1.style.backgroundColor = "#FFE4E1";
td2.style.backgroundColor = "#FFE4E1";
td3.style.backgroundColor = "#FFE4E1";
td4.style.backgroundColor = "#FFE4E1";
tr1.style.border = "1px solid crimson";
}
 
if (state & BLANKING || newsize == 0) {
th0.style.backgroundColor = "white";
th1.style.backgroundColor = "white";
td2.style.backgroundColor = "white";
td3.style.backgroundColor = "white";
td4.style.backgroundColor = "white";
tr1.style.border = "2px double crimson";
}
if (state & NEW) {
th0.style.backgroundColor = "#e2f2d2";
th1.style.backgroundColor = "#e2f2d2";
td2.style.backgroundColor = "#e2f2d2";
td3.style.backgroundColor = "#e2f2d2";
td4.style.backgroundColor = "#e2f2d2";
tr1.style.border = "1px solid green";
}
 
if (state & IP) {
td2.style.backgroundColor = "white";
td3.style.backgroundColor = "white";
td4.style.backgroundColor = "white";
}
 
if (isTOR.test(user))
td2.style.backgroundColor = "pink";
 
if (state & REPLACED) {
th0.style.backgroundColor = "pink";
th1.style.backgroundColor = "pink";
td2.style.backgroundColor = "pink";
td3.style.backgroundColor = "pink";
td4.style.backgroundColor = "pink";
td4.innerHTML = '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Categorie_III.svg/10px-Categorie_III.svg.png" width="10px" alt="Warning"/>';
tr1.style.border = "2px solid crimson";
}
 
// CONTACT LIST //
//////////////////
if (lstContact[user]) {
td2.style.border = "2px solid gold";
td2.style.backgroundColor = "yellow";
}
 
if (user == wgUserName) {
td2.style.border = "2px solid #A0B0E0";
td2.style.backgroundColor = "#F0F8FF";
}
 
// DELTA SIZE //
 
// delta de modif ;
///////////////////
var txtdiff = "";
if (sizediff < 0)
txtdiff = '<sub style="color:red">'+sizediff+'</sub>';
else if (sizediff == 0)
txtdiff = '<small style="color:purple">='+sizediff+'</small>';
else
txtdiff = '<sup style="color:blue">+'+sizediff+'</sup>';
td4.innerHTML += txtdiff;
td4.style.border = "1px";
td4.style.textAlign = "right";
 
 
// ASSEMBLAGE LIGNE //
 
tr1.appendChild(th0);
tr1.appendChild(th1);
tr1.appendChild(td2);
tr1.appendChild(td3);
tr1.appendChild(td4);
tr1.id = pageid+"_"+revid;
 
var tab = document.getElementById( 'tabRC' );
var elold = document.getElementById(pageid+"_"+oldid);
 
if (tab.firstChild != null)
tab.insertBefore(tr1, tab.firstChild);
else
tab.appendChild(tr1);
if (elold == null) {
if (tab.childNodes.length > rclimit) {
var idt = tab.lastChild.id;
supprLigne(idt);
}
} else {
supprLigne(pageid+"_"+oldid);
}
 
tr1.appendChild( td2 );
tr1.appendChild( td3 );
 
// MISE if(elA ==JOUR null)LISTES {//
tr1.id = pageid+"_"+revid;
if(tab.firstChild != null)
tab.insertBefore(tr1, tab.firstChild );
else
tab.appendChild(tr1);
if(elold == null) {
if (tab.childNodes.length > rclimit) {
// tab.removeChild(tab.lastChild);
var idt = tab.lastChild.id;
supprLigne(idt);
}
} else {
supprLigne(pageid+"_"+oldid);
}
 
/* var spos = lstSuivi.indexOf(ctitle);
if(spos != -1) {
th0.style.border = "2px solid gold";
th0.style.backgroundColor = "yellow";
th1.style.border = "2px solid gold";
th1.style.backgroundColor = "yellow";
lstSuiviHH[spos] = timestamp;
var tempsAr = new Array();
var len = lstSuivi.length;
for (var n = 0; n < len; n++) {
if(lstSuiviHH[n] == "--:--") continue;
var cstilde = lstSuivi[n].replace(new RegExp(/\'/g), "\\'");
var sdiff = '<a href="javascript:;" onClick="liveDiff(\''+cstilde+'\',\'current\','+revid+');" style="color:orange">Diff</a>';
var shist = '<a href="javascript:;" onClick="liveHist(\''+cstilde+'\');" style="color:darkorange">Hist</a>';
var sarti = '<a href="'+wgServer+'/wiki/'+encodeURI(lstSuivi[n])+'">'+lstSuivi[n]+'</a>';
var ligne='<small>' + lstSuiviHH[n] + ' • ' + sdiff + ' • ' + shist + ' • </small>' + sarti +'<br />';
tempsAr.push(ligne);
}
tempsAr.sort();
len = tempsAr.length;
var lvSuivi = document.getElementById( 'liveSuivi' );
lvSuivi.innerHTML = "";
for (var n=len-1; n >= 0; n--) {
lvSuivi.innerHTML = lvSuivi.innerHTML + tempsAr[n];
}
*/
}
 
if (lstContact[user]) {
var isRevoq = new RegExp(/(.*)ontributions\/(.*)\|(.*)\|(.*)/);
lstContact[user].ts = timestamp;
var isRevoqPopup = new RegExp(/(.*)(par|by|de) (.*) (grâce|using)(.*)/);
updateFollowContact();
var match = isRevoq.exec(comment);
}
var matchPopup = isRevoqPopup.exec(comment);
 
var fpos = "";
if (state & REVERT) {
var fposU = "";
var scUser = new RegExp(/\[\[Special:Contributions\/([^\]\|]+)/);
if (match != null && match.length > 2) {
var fposUmatch = match[2]scUser.exec(comment);
if (match != null) {
fpos = followRevoc.indexOf(fposU);
}var userR = match[1];
if (matchPopupuserR != nulluser && matchPopup.lengthuserR >!= 3wgUserName) {
if (!lstRevoc[userR]) lstRevoc[userR] = { ts: 0, nb: 0 };
fposU = matchPopup[3];
fposlstRevoc[userR].ts = followRevoc.indexOf(fposU)timestamp;
lstRevoc[userR].nb += 1;
}
if (fpos != "" && fposU != user) {
if(fpos == -1) {
followRevoc.push(fposU);
followRevocNb.push(1);
followRevocHH.push(timestamp);
}
else {
followRevocNb[fpos] += 1;
followRevocHH[fpos] = timestamp;
}
updateFollowRevoc();
}
Line 708 ⟶ 913:
}
 
function getContentgetRedirCat(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
var a=xmlreq.responseText;
 
var c=data.message;
var yurik = xmlreq.responseXML.getElementsByTagName('yurik')[0];
var el_content = document.getElementById( c );
 
var i;
if (ayurik.indexOf(firstChild.nodeName == "<error>")!=-1) return; //cat is empty, nothing to do here
 
a=a.split('<content xml:space="preserve">');
var contentrc ="" data.rc;
var pageid = rc.pageid;
for(i in a)
var revid = rc.revid;
{
var state = rc.state;
content=a[i].substr(0,a[i].indexOf("</content>"));
 
if (content == "") continue;
var page = yurik.getElementsByTagName('pages')[0].getElementsByTagName('page')[0];
el_content.appendChild( document.createTextNode( content ) );
 
if (page.getElementsByTagName('redirect').length) {
state += REDIRECT;
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++)
if (new RegExp(lang_category+categoriestests[j].regex, "i").test(categories[i].textContent))
state += categoriestests[j].state;
}
 
rc.state = state;
 
wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=query&prop=revisions&pageids=' + pageid + '&rvstartid=' + revid + '&rvlimit=2&rvprop=content&format=xml',
onSuccess: getRevision, rc: rc });
}
 
function getRC(xmlreq, data) {
if (document.getElementById('stopLive').checked) return;
var page_content = document.getElementById( 'content' );
var a=xmlreq.responseText;
var c=data.message;
var d=data.type;
var i;
if(a.indexOf("<error>")!=-1) return; //cat is empty, nothing to do here
 
var api = xmlreq.responseXML.getElementsByTagName('api')[0];
a = a.replace(new RegExp(/ (title|revid|old_revid)=\"([^\"]*)?\"/g), " <$1>$2</$1>");
var ti=a.split("<title>");
var rv=a.split("<revid>");
var ol=a.split("<old_revid>");
var title="";
var revid="";
var oldrevid="";
var tab = document.getElementById( 'tabRC' );
for(i=ti.length-1; i >= 0 ; i--)
{
title=ti[i].substr(0,ti[i].indexOf("</title>"));
if (title == "") continue;
revid=rv[i].substr(0,rv[i].indexOf("</revid>"));
oldrevid=ol[i].substr(0,ol[i].indexOf("</old_revid>"));
 
if (api.firstChild.nodeName == "error") return;
cwwpajax.download({url:wgServer + wgScriptPath + '/api.php?action=query&prop=revisions&titles='+title+'&rvprop=timestamp|user|comment&format=xml',
 
onSuccess: getRevision, message: title, avant: oldrevid });
var rcs = api.getElementsByTagName('query')[0].getElementsByTagName('recentchanges')[0].getElementsByTagName('rc');
var i,j,leni,lenj,rc;
 
leni=rcs.length;
for (i=leni-1; i>=0; i--) {
if (rcs[i].getAttribute('revid') <= lastrevid) continue;
 
rc = new Object();
rc.state = 0;
 
lenj = rcs[i].attributes.length;
for (j=0; j<lenj; j++) {
switch(rcs[i].attributes[j].name) {
case 'anon':
rc.state += IP;
break;
case 'bot':
rc.state += BOT;
break;
case 'new':
rc.state += NEW;
break;
case 'minor':
rc.state += MINOR;
break;
case 'new_ns':
rc.state += NEWNS;
break;
case 'new_title':
rc.state += RENAMED;
break;
case 'patrolled':
rc.state += PATROLLED;
break;
case 'bot':
rc.state += BOT;
break;
case 'type':
break;
default:
rc[rcs[i].attributes[j].name] = rcs[i].attributes[j].value;
break;
}
}
 
if (typeof(rc.comment) != "undefined") {
lenj = commenttests.length;
for (j=0; j<lenj; j++)
if (new RegExp(commenttests[j].regex).test(rc.comment))
rc.state += commenttests[j].state;
}
 
if (lstSysop.indexOf(rc.user) != -1)
rc.state += SYSOP;
 
if (document.getElementById('showIP').checked
&& !(rc.state & IP)
&& !(rc.state & REVERT)
&& !(rc.state & BLANKING)
&& !(rc.state & REPLACED)
&& !(lstContact[rc.user])
&& !(lstRevoc[rc.user])
&& (rc.user != wgUserName)) continue;
 
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + rc.title + '&what=redirects|categories&format=xml',
onSuccess: getRedirCat, rc: rc });
}
 
lastrevid = rcs[0].getAttribute('revid');
lasttimestamp = rcs[0].getAttribute('timestamp').replace(new RegExp(/\D/g), "");
document.getElementById('tsInit').innerHTML = "Dernière situation : " + lasttimestamp;
}
 
function liveRC() {
var rcshowrefresh = ""10;
timer= setTimeout("liveRC()",refresh*1000);
var rcns = "";
 
timer= setTimeout("liveRC()",20000);
if (document.getElementById('stopLive').checked) return;
 
var slcNS = document.getElementById('showNS0');
var rcns = document.getElementById('showNS0').value;
if(slcNS != null) {
if var ns(rcns == null) slcNS.valuereturn;
var rcshow;
if(ns != null && ns != "*") rcns = '&rcnamespace='+ ns;
if (document.getElementById('showBot').checked) rcshow = '&rcshow=!bot';
}
 
if(document.getElementById('showBot').checked) rcshow = '&rcshow=!bot';
wpajax.http({url:wgServer + wgScriptPath
if(document.getElementById('showIP').checked) rcshow = '&rcshow=anon';
cwwpajax.download({url:wgServer + wgScriptPath + '/api.php?action=query&list=recentchanges'+rcshow+rcns+'&rclimitrcnamespace=' +rclimit+'&format=xml', rcns
+ '&rcprop=user|comment|flags' + rcshow
onSuccess: getRC, message: "Traitement en cours...\n\n" });
+ '&rcend=' + lasttimestamp + '&rclimit=' + rclimit + '&format=xml',
// liveBlock();
onSuccess: getRC, message: "Traitement en cours...\n\n" });
}
 
function showHideObj(parent, fils) {
var ofils = document.getElementById( fils );
if (parent.checked)
ofils.style.display="inline";
else
Line 779 ⟶ 1,059:
 
addOnloadHook(function () {
if if(wgTitle == "EDUCA33E/LiveRC") {
var top = document.getElementById( 'top' ); top.innerHTML = "";
var siteSub = document.getElementById( 'siteSub' );
var contentSub = document.getElementById( 'contentSub' );
var rtb = document.getElementById( 'RealTitleBanner' );
var rt = document.getElementById( 'RealTitle' );
var pca = document.getElementById( 'p-cactions' );
 
var top = document.stylegetElementById( 'top' ); top.displayinnerHTML = "none";
var siteSub.style.display = "none"document.getElementById( 'siteSub' );
var contentSub.style.display = "none"document.getElementById( 'contentSub' );
var rtb = document.getElementById( 'RealTitleBanner' );
if(rtb != null) rtb.style.display = "none";
var rt = document.getElementById( 'RealTitle' );
if(rt != null) rt.style.display = "none";
var pca = document.getElementById( 'p-cactions' );
if(pca != null) pca.style.display = "none";
 
top.style.display = "none";
var lvPreviewFoot = document.getElementById( 'livePreviewFoot' );
lvPreviewFootsiteSub.style.innerHTMLdisplay = menu"none";
contentSub.style.display = "none";
// Main
if (rtb != null) rtb.style.display = "none";
liveWatch();
if (rt != null) rt.style.display = "none";
liveSysop();
if (pca != null) pca.style.display = "none";
liveNS();
 
liveRC();
var lvPreviewFoot = document.getElementById( 'livePreviewFoot' );
}
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' +
'<input id="stopLive" type="checkbox" value="true" />' +
'<label for="stopLive">' + lang_menu[0].PAUSE + '</label>' +
'<input id="shidPrev" type="checkbox" onclick="showHideObj(this, \'divLivePreview\');" />' +
'<label for="shidPrev">' + lang_menu[0].PREVIEW + '</label>' +
'<input id="shidList" type="checkbox" onclick="showHideObj(this, \'liveFollow\');" />' +
'<label for="shidList">' + lang_menu[0].LISTS + '</label>' +
'<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>' +
'<span id="selectNS" />';
if (previewHeight) document.getElementById('livePreview').style.height = previewHeight;
 
var _lstContact = lstContact;
var _len = lstContact.length;
lstContact = new Array();
for (var _i=0; _i<_len; _i++)
lstContact[_lstContact[_i]] = { ts: 0 };
 
// Main
//liveWatch();
liveSysop();
}
});
 
// ////////////
/* </pre> */