„Benutzer:EDUCA33E/LiveRC.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
v0.3.4 |
v0.3.5a |
||
Zeile 2: | Zeile 2: | ||
==LiveWP== |
==LiveWP== |
||
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]] |
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]] |
||
*Authors : [[:fr:User:EDUCA33E]] |
*Authors : [[:fr:User:EDUCA33E]], [[:fr:User:TiChou]] & [[:pl:User:Leafnode]] |
||
*Version: 0.3. |
*Version: 0.3.5a (beta) |
||
Version modifiée basée sur la version du 1er avril 2007 à 00:49 : |
Version modifiée basée sur la version du 1er avril 2007 à 00:49 : |
||
Zeile 24: | Zeile 24: | ||
// /////////////////////////////////////////// |
// /////////////////////////////////////////// |
||
document.write('<script type="text/javascript" src="' |
document.write('<script type="text/javascript" src="' |
||
+ wgServer + wgScriptPath + '/index.php?title=User:'+wgUserName+'/LiveRCparam.js' |
+ wgServer + wgScriptPath + '/index.php?title=User:'+encodeURI(wgUserName)+'/LiveRCparam.js' |
||
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); |
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); |
||
Zeile 66: | Zeile 66: | ||
var FIRE = 2 << 20; |
var FIRE = 2 << 20; |
||
var lstSysop = new Array(); // |
var lstSysop = new Array(); // Sysop list; |
||
var lstContact = new Array(); // |
var lstContact = new Array(); // Contact list; |
||
var lstRevoc = new Array(); // |
var lstRevoc = new Array(); // Reverted list; |
||
/ |
// Is user Sysop; |
||
var lrcAdmin = false; // default value; |
|||
if(wgUserGroups.indexOf("sysop") != -1) |
|||
lrcAdmin = true; |
|||
// Watchlist; |
|||
var lstSuivi = new Array(); |
var lstSuivi = new Array(); |
||
var lstSuiviHH = new Array(); |
var lstSuiviHH = new Array(); |
||
} |
} |
||
/* </pre> |
/* </pre> |
||
=== |
===Utilities=== |
||
<pre> */ |
<pre> */ |
||
Zeile 150: | Zeile 155: | ||
} |
} |
||
return null; |
return null; |
||
} |
|||
// HTMLize |
|||
String.prototype.htmlize = function() { |
|||
var chars = new Array('&','<','>','"'); |
|||
var entities = new Array('amp','lt','gt','quot'); |
|||
var regex = new RegExp(); |
|||
var string = this; |
|||
for (var i=0; i<chars.length; i++) { |
|||
regex.compile(chars[i], "g"); |
|||
string = string.replace(regex, '&' + entities[i] + ';'); |
|||
} |
|||
return string; |
|||
} |
} |
||
Zeile 160: | Zeile 178: | ||
function liveDiff(page, id, oldid) { |
function liveDiff(page, id, oldid) { |
||
var el = document.getElementById( 'livePreviewTitle' ); |
var el = document.getElementById( 'livePreviewTitle' ); |
||
el.innerHTML="<b |
el.innerHTML="<b style='text-decoration: blink;'>Diff : <span style='color:red'>"+page+"</span>...</b>"; |
||
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title='+ |
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title='+encodeURIComponent(page)+'&diffonly=1&diff='+id+'&oldid='+oldid, |
||
onSuccess: getDiff, mpage: page, mid: id, moldid:oldid}); |
onSuccess: getDiff, mpage: page, mid: id, moldid:oldid}); |
||
} |
} |
||
Zeile 175: | Zeile 193: | ||
var lD = getElementsByClass('diff',bC,null); |
var lD = getElementsByClass('diff',bC,null); |
||
// Get username of submitter |
|||
var user1 = getElementsByClass('diff-otitle',doc,'td'); |
|||
if (user1 != null && user1[0] != null) |
|||
user1 = user1[0].getElementsByTagName('a')[2].innerHTML; |
|||
var user2 = getElementsByClass('diff-ntitle',doc,'td'); |
|||
if (user2 != null && user2[0] != null) |
|||
user2 = user2[0].getElementsByTagName('a')[2].innerHTML; |
|||
if (user2 == "défaire") { |
|||
user2 = getElementsByClass('diff-ntitle',doc,'td'); |
|||
user2 = user2[0].getElementsByTagName('a')[3].innerHTML; |
|||
} |
|||
user1=user1.replace(new RegExp(/\'/g), "\\'"); |
|||
user2=user2.replace(new RegExp(/\'/g), "\\'"); |
|||
var upage=page.replace(new RegExp(/\'/g), "\\'"); |
var upage=page.replace(new RegExp(/\'/g), "\\'"); |
||
Zeile 214: | Zeile 219: | ||
elcb.checked="true"; |
elcb.checked="true"; |
||
dLP.style.display = "inline"; |
dLP.style.display = "inline"; |
||
} |
|||
var optAvert = ""; |
|||
var optl = lstAvert.length; |
|||
for (j=0; j<optl; j++) { |
|||
optAvert += '<option value="'+lstAvert[j].template; |
|||
if(lstAvert[j].hasPage) optAvert += '|'+upage; |
|||
optAvert += '">'+lstAvert[j].string+'</option>'; |
|||
} |
} |
||
var entete = document.getElementById( 'livePreviewTitle' ); |
var entete = document.getElementById( 'livePreviewTitle' ); |
||
entete.innerHTML='<b> |
entete.innerHTML='<b><a href="'+wgServer + '/wiki/' + encodeURI(page) + '" target="_new">' + page + '</a></b> • ' + |
||
'(<a href="javascript:;" onClick="liveHist(\''+upage+'\');" style="color:darkorange">Hist</a>)'; |
'(<a href="javascript:;" onClick="liveHist(\''+upage+'\');" style="color:darkorange">Hist</a>)'; |
||
entete.innerHTML = '<table width="100%" class="creator"><tr><td>' + entete.innerHTML + |
|||
var asNextDiff = doc.getElementById("differences-nextlink"); |
|||
'</td><td align="right"><small>' + |
|||
if(asNextDiff == null) { |
|||
// Verifier avant si le patrouilleur peut modifier cette page ? (query.php?what=permissions&titles=page) |
|||
var optAvert = ""; |
|||
'[<a id="LiveRevertLink" href="javascript:getLiveMessage(\'liverevert\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >'+lang_menu[0].UNDORC+'</a>] • ' + |
|||
var optl = lstAvert.length; |
|||
'[<a id="LiveVandalismLink" href="javascript:getLiveMessage(\'livevandalism\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >'+lang_menu[0].REVERT+'</a>] • ' + |
|||
for (j=0; j<optl; j++) { |
|||
lang_menu[0].REASON+' : <input id="LiveRevertMessage" /> ••• ' + |
|||
optAvert += '<option value="'+lstAvert[j].template; |
|||
'[<a id="LiveAvertoLink" href="javascript:getLiveAverto(\''+user2+'\');">'+lang_menu[0].AVERTS+'</a>] : ' + |
|||
if(lstAvert[j].hasPage) optAvert += '|'+upage; |
|||
optAvert += '">'+lstAvert[j].string+'</option>'; |
|||
'</td></tr></table>'; |
|||
} |
|||
document.getElementById('LiveRevertMessage').focus(); |
|||
// Get username of submitter |
|||
var user1 = getElementsByClass('diff-otitle',doc,'td'); |
|||
if (user1 != null && user1[0] != null) |
|||
user1 = user1[0].getElementsByTagName('a')[2].innerHTML; |
|||
var user2 = getElementsByClass('diff-ntitle',doc,'td'); |
|||
if (user2 != null && user2[0] != null) |
|||
user2 = user2[0].getElementsByTagName('a')[2].innerHTML; |
|||
if (user2 == "défaire") { |
|||
user2 = getElementsByClass('diff-ntitle',doc,'td'); |
|||
user2 = user2[0].getElementsByTagName('a')[3].innerHTML; |
|||
} |
|||
user1=user1.replace(new RegExp(/\'/g), "\\'"); |
|||
user2=user2.replace(new RegExp(/\'/g), "\\'"); |
|||
entete.innerHTML = '<table width="100%" class="creator"><tr><td>' + entete.innerHTML + |
|||
'</td><td align="right"><small>' + |
|||
// Verifier avant si le patrouilleur peut modifier cette page ? (query.php?what=permissions&titles=page) |
|||
'[<a id="LiveRevertLink" href="javascript:getLiveMessage(\'liverevert\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >' + lang_menu[0].UNDORC+'</a>] • ' + |
|||
lang_menu[0].REASON+' : <input id="LiveRevertMessage" /> ••• ' + |
|||
'[<a id="LiveAvertoLink" href="javascript:getLiveAverto(\''+user2+'\');">'+lang_menu[0].AVERTS+'</a>] : ' + |
|||
'<select id="averto">' + optAvert + '</select>' + |
|||
'</td></tr></table>'; |
|||
document.getElementById('LiveRevertMessage').focus(); |
|||
} |
|||
} |
} |
||
Zeile 274: | Zeile 296: | ||
var headers = new Array(); |
var headers = new Array(); |
||
headers['Content-Type'] = 'application/x-www-form-urlencoded'; |
headers['Content-Type'] = 'application/x-www-form-urlencoded'; |
||
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=User_Talk:' + |
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=User_Talk:' + encodeURI(user) + '&action=submit', |
||
method: "POST", headers: headers, |
method: "POST", headers: headers, |
||
data: 'wpSave=1&wpTextbox1=' + wpTextbox1 + '&wpStarttime=' + wpStarttime + '&wpEdittime=' + wpEdittime |
data: 'wpSave=1&wpTextbox1=' + wpTextbox1 + '&wpStarttime=' + wpStarttime + '&wpEdittime=' + wpEdittime |
||
Zeile 281: | Zeile 303: | ||
function getLiveMessage(where, user1, user2, page, oldid) { |
function getLiveMessage(where, user1, user2, page, oldid) { |
||
var links = [ document.getElementById('LiveRevertLink |
var links = [ document.getElementById('LiveRevertLink') ]; |
||
var i,len=links.length; |
var i,len=links.length; |
||
for (i=0; i<len; i++) { |
for (i=0; i<len; i++) { |
||
Zeile 291: | Zeile 313: | ||
document.getElementById('LiveRevertMessage').disabled = true; |
document.getElementById('LiveRevertMessage').disabled = true; |
||
var message = document.getElementById('LiveRevertMessage').value; |
var message = document.getElementById('LiveRevertMessage').value; |
||
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=' + |
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=' + encodeURI(page) + '&action=edit&oldid=' + oldid, |
||
onSuccess: postLiveRevert, |
onSuccess: postLiveRevert, |
||
where: where, page: page, user1: user1, user2: user2, message: message }); |
where: where, page: page, user1: user1, user2: user2, message: message }); |
||
Zeile 319: | Zeile 341: | ||
switch(where) { |
switch(where) { |
||
case 'liverevert': |
case 'liverevert': |
||
var wpSummary = |
var wpSummary = lang_menu[0].RVMES1 + ' [[Special:Contributions/' + user2 + '|' + user2 |
||
+ ']]; |
+ ']]; '+lang_menu[0].RVMES2+' [[User:' + user1 + '|' + user1 + ']]'; |
||
break; |
break; |
||
case 'livevandalism': |
/* case 'livevandalism': |
||
var wpSummary = 'LiveRC : Révocation de vandalisme par [[Special:Contributions/' + user2 + '|' + user2 |
var wpSummary = 'LiveRC : Révocation de vandalisme par [[Special:Contributions/' + user2 + '|' + user2 |
||
+ ']]; retour à la version de [[User:' + user1 + '|' + user1 + ']]'; |
+ ']]; retour à la version de [[User:' + user1 + '|' + user1 + ']]'; |
||
break; |
break; */ |
||
} |
} |
||
if (message) |
if (message) |
||
Zeile 347: | Zeile 369: | ||
function liveHist(page) { |
function liveHist(page) { |
||
var el = document.getElementById( 'livePreviewTitle' ); |
var el = document.getElementById( 'livePreviewTitle' ); |
||
el.innerHTML="<b |
el.innerHTML="<b style='text-decoration: blink;'>Hist : <span style='color:red'>"+page+"</span>...</b>"; |
||
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=' + |
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&action=history', onSuccess: getHist, message: page }); |
||
} |
} |
||
Zeile 364: | Zeile 386: | ||
} |
} |
||
var elt = document.getElementById( 'livePreviewTitle' ); |
var elt = document.getElementById( 'livePreviewTitle' ); |
||
elt.innerHTML='<b> |
elt.innerHTML='<b><a href="'+wgServer+'/wiki/'+encodeURIComponent(c)+'" target="_new">'+c+'</a></b>'; |
||
} |
|||
/* </pre> |
|||
=== LiveArticle === |
|||
<pre> */ |
|||
function liveArticle(page) { |
|||
var el = document.getElementById( 'livePreviewTitle' ); |
|||
el.innerHTML="<b style='text-decoration: blink;'><span style='color:red'>"+page+"</span>...</b>"; |
|||
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&redirect=no', onSuccess: getArticle, message: page }); |
|||
} |
|||
function getArticle(xmlreq, data) { |
|||
doc = gml_XMLParse(xmlreq.responseText); |
|||
bC = doc.getElementById('bodyContent') |
|||
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>'; |
|||
} |
} |
||
Zeile 375: | Zeile 425: | ||
function liveContrib(user) { |
function liveContrib(user) { |
||
var el = document.getElementById( 'livePreviewTitle' ); |
var el = document.getElementById( 'livePreviewTitle' ); |
||
el.innerHTML="<b |
el.innerHTML="<b style='text-decoration: blink;'><span style='color:red'>"+user+"</span>...</b>"; |
||
wpajax.http({url:wgServer + '/wiki/Special:Contributions/'+ |
wpajax.http({url:wgServer + '/wiki/Special:Contributions/'+encodeURIComponent(user), |
||
onSuccess: getContrib, message: user }); |
onSuccess: getContrib, message: user }); |
||
} |
} |
||
Zeile 402: | Zeile 452: | ||
var entete = document.getElementById( 'livePreviewTitle' ); |
var entete = document.getElementById( 'livePreviewTitle' ); |
||
entete.innerHTML='<b> |
entete.innerHTML='<b><a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a></b>'; |
||
entete.innerHTML = '<table width="100%" class="creator"><tr><td>'+entete.innerHTML + |
entete.innerHTML = '<table width="100%" class="creator"><tr><td>'+entete.innerHTML + |
||
'</td><td align="right"><small>' + |
'</td><td align="right"><small>' + |
||
'[<a href="javascript:var message=getLiveAverto(\''+utilde+'\');"> |
'[<a id="LiveAvertoLink" href="javascript:var message=getLiveAverto(\''+utilde+'\');">'+lang_menu[0].AVERTS+'</a>] : ' + |
||
'<select id="averto">' + optAvert + '</select>' + '</td></tr></table>'; |
'<select id="averto">' + optAvert + '</select>' + '</td></tr></table>'; |
||
} |
} |
||
Zeile 430: | Zeile 480: | ||
lstSysop.push(info); |
lstSysop.push(info); |
||
} |
} |
||
liveNS(); |
liveNS(); |
||
} |
|||
function liveWatch() { |
|||
wpajax.http({url:wgServer + '/wiki/Special:Watchlist/edit', |
|||
onSuccess: getWatch, message: "Récup watchlist" }); |
|||
} |
|||
function getWatch(xmlreq, data) { |
|||
var doc = gml_XMLParse(xmlreq.responseText); |
|||
var bC = doc.getElementById('bodyContent'); |
|||
var info=""; |
|||
var lstUL = bC.getElementsByTagName( 'ul' ); |
|||
var lenUL = lstUL.length; |
|||
for(var j=0; j < lenUL ; j++) { |
|||
var lstLI = lstUL[j].getElementsByTagName( 'li' ); |
|||
var lenLI = lstLI.length; |
|||
for(var i=0; i < lenLI ; i++) { |
|||
info=lstLI[i].getElementsByTagName( 'input' )[ 0 ].value; |
|||
lstSuivi.push(info); |
|||
lstSuiviHH.push("--:--"); |
|||
} |
|||
} |
|||
liveRC(); |
|||
} |
} |
||
Zeile 490: | Zeile 562: | ||
document.getElementById('selectNS').innerHTML = '<label for="showNS0">'+lang_menu[0].NAMESP+' </label><select id="showNS0">' + options + '</select>'; |
document.getElementById('selectNS').innerHTML = '<label for="showNS0">'+lang_menu[0].NAMESP+' </label><select id="showNS0">' + options + '</select>'; |
||
liveWatch(); |
|||
} |
} |
||
Zeile 505: | Zeile 577: | ||
if (quelLigne == '*') |
if (quelLigne == '*') |
||
els = tab.getElementsByTagName('tr'); |
els = tab.getElementsByTagName('tr'); |
||
else if (quelLigne == ' |
else if (quelLigne == 'd') { |
||
var _els = tab.getElementsByTagName('tr'); |
var _els = tab.getElementsByTagName('tr'); |
||
len = _els.length; |
len = _els.length; |
||
for (i=len-1; i>=0; i--) |
for (i=len-1; i>=0; i--) |
||
if (_els[i].firstChild.style.backgroundColor == 'rgb(255, 250, 205)') |
if (_els[i].firstChild.style.backgroundColor == 'rgb(255, 250, 205)') |
||
els.push(_els[i]); |
|||
} else if (quelLigne == 'r') { |
|||
var _els = tab.getElementsByTagName('tr'); |
|||
len = _els.length; |
|||
for (i=len-1; i>=0; i--) |
|||
if (_els[i].firstChild.style.backgroundColor == 'rgb(255, 228, 225)') |
|||
els.push(_els[i]); |
|||
} else if (quelLigne == 'n') { |
|||
var _els = tab.getElementsByTagName('tr'); |
|||
len = _els.length; |
|||
for (i=len-1; i>=0; i--) |
|||
if (_els[i].firstChild.style.backgroundColor == 'rgb(226, 242, 210)') |
|||
els.push(_els[i]); |
els.push(_els[i]); |
||
} else |
} else |
||
Zeile 554: | Zeile 638: | ||
var tz; |
var tz; |
||
var match, regex = new RegExp(); |
var match, regex = new RegExp(); |
||
if ( |
if (lrcTZ) { |
||
regex.compile(/^([-+])?(\d?\d):?(\d\d)$/); |
regex.compile(/^([-+])?(\d?\d):?(\d\d)$/); |
||
match = regex.exec( |
match = regex.exec(lrcTZ); |
||
if (!match) { |
if (!match) { |
||
//livercError(lang_error.TZ); |
//livercError(lang_error.TZ); |
||
Zeile 585: | Zeile 669: | ||
if (timestamp == 0) continue; |
if (timestamp == 0) continue; |
||
var utilde = user.replace(new RegExp(/\'/g), "\\'"); |
var utilde = user.replace(new RegExp(/\'/g), "\\'"); |
||
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+ |
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>'; |
||
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color: |
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:#43CD80">C</a>'; |
||
var uadmin = ''; |
|||
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>'; |
|||
if (lrcAdmin == true) { |
|||
var ligne = '<span id="contact-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + ' • </small>' + ueditor + '</span><br />'; |
|||
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>'; |
|||
} |
|||
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>'; |
|||
var ligne = '<span id="contact-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + uadmin + ' • </small>' + ueditor + '</span><br />'; |
|||
tempAr.push(ligne); |
tempAr.push(ligne); |
||
} |
} |
||
Zeile 604: | Zeile 692: | ||
var timestamp = lstRevoc[user].ts; |
var timestamp = lstRevoc[user].ts; |
||
var utilde = user.replace(new RegExp(/\'/g), "\\'"); |
var utilde = user.replace(new RegExp(/\'/g), "\\'"); |
||
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+ |
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>'; |
||
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color: |
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:#43CD80">C</a>'; |
||
var uadmin = ''; |
|||
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURI(user)+'">'+user+'</a>'; |
|||
if (lrcAdmin == true) { |
|||
var ligne = '<span id="revoc-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + ' • </small>' + ueditor + ' (' + lstRevoc[user].nb + ' '+lang_menu[0].XTIMES+')</span><br />'; |
|||
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>'; |
|||
} |
|||
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>'; |
|||
var ligne = '<span id="revoc-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + uadmin + ' • </small>' + ueditor + ' (' + lstRevoc[user].nb + ' '+lang_menu[0].XTIMES+')</span><br />'; |
|||
tempAr.push(ligne); |
tempAr.push(ligne); |
||
} |
} |
||
Zeile 672: | Zeile 764: | ||
var diff = ""; |
var diff = ""; |
||
var diffClose = ""; |
var diffClose = ""; |
||
if ( |
if (lrcAutoCloseDiff == 1) |
||
diffClose='supprLigne(\''+pageid+'_'+revid+'\');'; |
diffClose='supprLigne(\''+pageid+'_'+revid+'\');'; |
||
if (state & NEW) |
if (state & NEW) |
||
diff = '< |
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveArticle(\''+escTitle+'\');'+diffClose+'" style="color:green">New</a>'; |
||
else |
else |
||
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveDiff(\''+escTitle+'\','+revid+','+oldid+');'+diffClose+'" style="color:orange">Diff</a>'; |
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"> |
var hist = '<a href="javascript:;" onClick="liveHist(\''+escTitle+'\');" style="color:darkorange">H</a>'; |
||
var edit = '<a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=edit" target="_new" style="color:tomato">E</a>'; |
|||
var admin = ''; |
|||
if (lrcAdmin == true) { |
|||
admin = ' • <a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=delete" target="_new" style="color:orangered">S</a>'; |
|||
} |
|||
// Homonymie ? ; |
// Disambig / Homonymie ? ; |
||
//////////////// |
/////////////////////////// |
||
if (ns == 0 && state & HOMONYMIE) { |
if (ns == 0 && state & HOMONYMIE) { |
||
artiStyle = 'color: darkorange; font-weight: bold; font-style: italic;'; |
artiStyle = 'color: darkorange; font-weight: bold; font-style: italic;'; |
||
Zeile 733: | Zeile 830: | ||
postArti += '<sup style="color:crimson">(cat ?)</sup>'; |
postArti += '<sup style="color:crimson">(cat ?)</sup>'; |
||
// |
// Redirect ? ; |
||
////////////////// |
////////////////// |
||
if (state & REDIRECT) { |
if (state & REDIRECT) { |
||
Zeile 739: | Zeile 836: | ||
postArti += '<img src="/media/wikipedia/commons/thumb/b/b5/Redirectltr.png/20px-Redirectltr.png" width="20px" alt="Redirection" />'; |
postArti += '<img src="/media/wikipedia/commons/thumb/b/b5/Redirectltr.png/20px-Redirectltr.png" width="20px" alt="Redirection" />'; |
||
if (rc.redirect) { |
if (rc.redirect) { |
||
postArti += '<a href="'+wgServer+'/wiki/'+ |
// postArti += '<a href="'+wgServer+'/wiki/'+encodeURIComponent(rc.redirect)+'" target="_new">'+rc.redirect+'</a>'; |
||
postArti += '<a href="javascript:;" onClick="liveArticle(\''+rc.redirect+'\');">'+rc.redirect+'</a>'; |
|||
} else { |
} else { |
||
regex.compile(/^#REDIRECT\s*\[\[(.*)\]\]/i); |
regex.compile(/^#REDIRECT\s*\[\[(.*)\]\]/i); |
||
match = regex.exec(revisions[0].textContent); |
match = regex.exec(revisions[0].textContent); |
||
if (match) |
if (match) { |
||
postArti += '<a style="color: |
// 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 |
|||
} else { |
|||
postArti += '<a style="color: red;" href="'+wgServer+wgScriptPath+'/index.php?title='+encodeURI(title)+'&redirect=no">/!\\</a>'; |
|||
// 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">'+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 { |
} else { |
||
arti = '<a style="'+artiStyle+'" href="'+ |
arti = '<a style="'+artiStyle+'" href="javascript:;" onClick="liveArticle(\''+title+'\');">'+title+'</a>'; |
||
} |
} |
||
th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • </small>' |
th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • ' + edit + admin + ' • </small>' |
||
+ preArti + arti + postArti; |
+ preArti + arti + postArti; |
||
th1.className="creator-title"; |
th1.className="creator-title"; |
||
Zeile 760: | Zeile 862: | ||
// |
// EDITOR // |
||
//////////// |
|||
var discut = '<a href="'+wgServer+'/wiki/User talk:'+ |
var discut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>'; |
||
var contrib = '<a href="javascript:;" onClick="liveContrib(\''+escUser+'\');" style="color: |
var contrib = '<a href="javascript:;" onClick="liveContrib(\''+escUser+'\');" style="color:#43CD80">C</a>'; |
||
var editor = "", preEditor = ""; |
var editor = "", preEditor = ""; |
||
Zeile 776: | Zeile 878: | ||
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2c/Broom_icon.svg/16px-Broom_icon.svg.png" width="16px" /> '; |
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2c/Broom_icon.svg/16px-Broom_icon.svg.png" width="16px" /> '; |
||
// |
// Reverted ? ; |
||
///////////////// |
///////////////// |
||
if (state & REVERT) |
if (state & REVERT) |
||
preEditor = '<img src="/media/wikipedia/commons/thumb/2/2c/Nuvola_actions_undo.png/16px-Nuvola_actions_undo.png" width="16px" /> '; |
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2c/Nuvola_actions_undo.png/16px-Nuvola_actions_undo.png" width="16px" /> '; |
||
// TOR potentiel / AOL |
// TOR potentiel / AOL |
||
Zeile 786: | Zeile 888: | ||
preEditor += '<img src="/media/wikipedia/commons/thumb/6/6e/Dialog-warning.svg/16px-Dialog-warning.svg.png" width="16px" /> '; |
preEditor += '<img src="/media/wikipedia/commons/thumb/6/6e/Dialog-warning.svg/16px-Dialog-warning.svg.png" width="16px" /> '; |
||
editor = '<a href="'+wgServer+'/wiki/User:'+ |
editor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>'; |
||
var uadmin = ''; |
|||
td2.innerHTML = '<small>' + discut + ' • ' + contrib + ' • </small>' |
|||
if (lrcAdmin == true) { |
|||
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>'; |
|||
} |
|||
td2.innerHTML = '<small>' + discut + ' • ' + contrib + uadmin + ' • </small>' |
|||
+ preEditor + editor; |
+ preEditor + editor; |
||
td2.className="creator-name"; |
td2.className="creator-name"; |
||
Zeile 798: | Zeile 905: | ||
} |
} |
||
// |
// COMMENT // |
||
// Remplace lien [[xxx]] par <a> ; |
|||
var wcomment = comment.htmlize(); |
|||
regex.compile(/\[\[(([^\]\|]*)(.*?))\]\]/g); |
|||
wcomment = wcomment.replace(regex, "<a href='"+wgServer+wgScriptPath+"/index.php?title=$2&redirect=no' target='_new'>$1</a>"); |
|||
regex.compile(/\>[^\]\|<]*\|([^\]\|<]*)</g); |
|||
wcomment = wcomment.replace(regex, ">$1<"); |
|||
td3.innerHTML = "<small>" + |
td3.innerHTML = "<small>" + wcomment + "</small>"; |
||
td3.style.border = "1px"; |
td3.style.border = "1px"; |
||
td3.style.width = "40%"; |
td3.style.width = "40%"; |
||
Zeile 894: | Zeile 1.007: | ||
tab.appendChild(tr1); |
tab.appendChild(tr1); |
||
if (elold == null) { |
if (elold == null) { |
||
if (tab.childNodes.length > |
if (tab.childNodes.length > lrcRCLimit) { |
||
var idt = tab.lastChild.id; |
var idt = tab.lastChild.id; |
||
supprLigne(idt); |
supprLigne(idt); |
||
Zeile 905: | Zeile 1.018: | ||
// MISE A JOUR LISTES // |
// MISE A JOUR LISTES // |
||
var spos = lstSuivi.indexOf(title); |
|||
if(spos != -1) { |
if(spos != -1) { |
||
th0.style.border = "2px solid gold"; |
th0.style.border = "2px solid gold"; |
||
Zeile 911: | Zeile 1.024: | ||
th1.style.border = "2px solid gold"; |
th1.style.border = "2px solid gold"; |
||
th1.style.backgroundColor = "yellow"; |
th1.style.backgroundColor = "yellow"; |
||
lstSuiviHH[spos] = timestamp; |
lstSuiviHH[spos] = tsToHhMm(timestamp); |
||
var tempsAr = new Array(); |
var tempsAr = new Array(); |
||
var len = lstSuivi.length; |
var len = lstSuivi.length; |
||
Zeile 917: | Zeile 1.030: | ||
if(lstSuiviHH[n] == "--:--") continue; |
if(lstSuiviHH[n] == "--:--") continue; |
||
var cstilde = lstSuivi[n].replace(new RegExp(/\'/g), "\\'"); |
var cstilde = lstSuivi[n].replace(new RegExp(/\'/g), "\\'"); |
||
var sdiff = '<a href="javascript:;" onClick="liveDiff(\''+cstilde+'\', |
var sdiff = '<a href="javascript:;" onClick="liveDiff(\''+cstilde+'\','+revid+','+oldid+');" style="color:orange">Diff</a>'; |
||
var shist = '<a href="javascript:;" onClick="liveHist(\''+cstilde+'\');" style="color:darkorange"> |
var shist = '<a href="javascript:;" onClick="liveHist(\''+cstilde+'\');" style="color:darkorange">H</a>'; |
||
var sarti = '<a href="'+ |
var sarti = '<a href="javascript:;" onClick="liveArticle(\''+cstilde+'\');">'+lstSuivi[n]+'</a>'; |
||
var ligne='<small>' + lstSuiviHH[n] + ' • ' + sdiff + ' • ' + shist + ' • </small>' + sarti +'<br />'; |
var ligne='<small>' + lstSuiviHH[n] + ' • ' + sdiff + ' • ' + shist + ' • </small>' + sarti +'<br />'; |
||
tempsAr.push(ligne); |
tempsAr.push(ligne); |
||
Zeile 930: | Zeile 1.043: | ||
lvSuivi.innerHTML = lvSuivi.innerHTML + tempsAr[n]; |
lvSuivi.innerHTML = lvSuivi.innerHTML + tempsAr[n]; |
||
} |
} |
||
*/ |
|||
if (lstContact[user]) { |
if (lstContact[user]) { |
||
Zeile 1.032: | Zeile 1.145: | ||
case 'patrolled': |
case 'patrolled': |
||
rc.state += PATROLLED; |
rc.state += PATROLLED; |
||
break; |
|||
case 'bot': |
|||
rc.state += BOT; |
|||
break; |
break; |
||
case 'type': |
case 'type': |
||
Zeile 1.063: | Zeile 1.173: | ||
&& (rc.user != wgUserName)) continue; |
&& (rc.user != wgUserName)) continue; |
||
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + rc.title + '&what=redirects|categories&format=xml', |
wpajax.http({url: wgServer + wgScriptPath + '/query.php?titles=' + encodeURIComponent(rc.title) + '&what=redirects|categories&format=xml', |
||
onSuccess: getRedirCat, rc: rc }); |
onSuccess: getRedirCat, rc: rc }); |
||
} |
} |
||
Zeile 1.080: | Zeile 1.190: | ||
var rcns = document.getElementById('showNS0').value; |
var rcns = document.getElementById('showNS0').value; |
||
if (rcns == null) return; |
if (rcns == null) return; |
||
var rcshow; |
var rcshow = ""; |
||
if (document.getElementById('showBot').checked) rcshow = '&rcshow=!bot'; |
if (document.getElementById('showBot').checked) rcshow = '&rcshow=!bot'; |
||
Zeile 1.086: | Zeile 1.196: | ||
+ '/api.php?action=query&list=recentchanges&rcnamespace=' + rcns |
+ '/api.php?action=query&list=recentchanges&rcnamespace=' + rcns |
||
+ '&rcprop=user|comment|flags' + rcshow |
+ '&rcprop=user|comment|flags' + rcshow |
||
+ '&rcend=' + lasttimestamp + '&rclimit=' + |
+ '&rcend=' + lasttimestamp + '&rclimit=' + lrcRCLimit + '&format=xml', |
||
onSuccess: getRC, message: "Traitement en cours...\n\n" }); |
onSuccess: getRC, message: "Traitement en cours...\n\n" }); |
||
} |
} |
||
Zeile 1.117: | Zeile 1.227: | ||
var lvPreviewFoot = document.getElementById( 'livePreviewFoot' ); |
var lvPreviewFoot = document.getElementById( 'livePreviewFoot' ); |
||
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' + |
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' + |
||
'<a href="javascript:;" onClick="supprLigne(\' |
'<a href="javascript:;" onClick="supprLigne(\'d\');" style="color: rgb(255, 235, 71); font-weight: bold;">X</a>' + |
||
'<a href="javascript:;" onClick="supprLigne(\'r\');" style="color: rgb(255, 99, 83); font-weight: bold;">X</a>' + |
|||
'<a href="javascript:;" onClick="supprLigne(\'n\');" style="color: rgb(178, 243, 113); font-weight: bold;">X</a>' + |
|||
'<input id="stopLive" type="checkbox" value="true" />' + |
'<input id="stopLive" type="checkbox" value="true" />' + |
||
'<label for="stopLive">' + lang_menu[0].PAUSE + '</label>' + |
'<label for="stopLive">' + lang_menu[0].PAUSE + '</label>' + |
||
Zeile 1.133: | Zeile 1.245: | ||
'<label for="showIP">' + lang_menu[0].IPONLY + ' • </label>' + |
'<label for="showIP">' + lang_menu[0].IPONLY + ' • </label>' + |
||
'<span id="selectNS" />'; |
'<span id="selectNS" />'; |
||
if ( |
if (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight; |
||
var _lstContact = lstContact; |
var _lstContact = lstContact; |
||
Zeile 1.142: | Zeile 1.254: | ||
// Main |
// Main |
||
//liveWatch(); |
|||
liveSysop(); |
liveSysop(); |
||
} |
} |
Version vom 30. April 2007, 18:51 Uhr
/*
==LiveWP==
*Documentation : [[:fr:User:EDUCA33E/LiveRC/Documentation]]
*Authors : [[:fr:User:EDUCA33E]], [[:fr:User:TiChou]] & [[:pl:User:Leafnode]]
*Version: 0.3.5a (beta)
Version modifiée basée sur la version du 1er avril 2007 à 00:49 :
http://fr.wikipedia.org/w/index.php?title=User:EDUCA33E/LiveRC.js&oldid=15525649
=== Variables globales ===
<pre> */
if (wgTitle == "EDUCA33E/LiveRC") {
// Appel des paramètres par défaut de LiveRC ;
// ///////////////////////////////////////////
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:'+encodeURI(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(); // Sysop list;
var lstContact = new Array(); // Contact list;
var lstRevoc = new Array(); // Reverted list;
// Is user Sysop;
var lrcAdmin = false; // default value;
if(wgUserGroups.indexOf("sysop") != -1)
lrcAdmin = true;
// Watchlist;
var lstSuivi = new Array();
var lstSuiviHH = new Array();
}
/* </pre>
===Utilities===
<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);
}
}
};
// Parser
if (document.implementation.createDocument) {
var gml_xmlparser = new DOMParser();
}
function gml_XMLParse(string) {
if (document.implementation.createDocument) {
return gml_xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
gml_xmldoc.async = "false";
ret = gml_xmldoc.loadXML(string);
if (!ret)
return null;
return gml_xmldoc.documentElement;
}
return null;
}
// HTMLize
String.prototype.htmlize = function() {
var chars = new Array('&','<','>','"');
var entities = new Array('amp','lt','gt','quot');
var regex = new RegExp();
var string = this;
for (var i=0; i<chars.length; i++) {
regex.compile(chars[i], "g");
string = string.replace(regex, '&' + entities[i] + ';');
}
return string;
}
/* </pre>
=== LiveDiff ===
<pre> */
function liveDiff(page, id, oldid) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b style='text-decoration: blink;'>Diff : <span style='color:red'>"+page+"</span>...</b>";
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title='+encodeURIComponent(page)+'&diffonly=1&diff='+id+'&oldid='+oldid,
onSuccess: getDiff, mpage: page, mid: id, moldid:oldid});
}
function getDiff(xmlreq, data) {
var doc = gml_XMLParse(xmlreq.responseText);
var page=data.mpage;
var oldid=data.moldid;
var id=data.mid;
var bC = doc.getElementById('bodyContent');
var LP = document.getElementById( 'livePreview' );
var dLP = document.getElementById( 'divLivePreview' );
var lD = getElementsByClass('diff',bC,null);
var upage=page.replace(new RegExp(/\'/g), "\\'");
if (lD[0] == null)
LP.innerHTML = bC.innerHTML;
else {
if (document.getElementById('showDiffR').checked) {
var avantEl = getElementsByClass('diff-deletedline',bC,null);
var apresEl = getElementsByClass('diff-addedline',bC,null);
var avant = "";
var apres = "";
var lav = avantEl.length;
var lap = apresEl.length;
for(var n=0; n < lav ; n++)
avant = avant + avantEl[n].innerHTML + "<br />";
for(var n=0; n < lap ; n++)
apres = apres + apresEl[n].innerHTML + "<br />";
LP.innerHTML = "<table width='100%'><tr><td width='50%' class='diff-deletedline'>"+avant+"</td><td class='diff-addedline'>"+apres+"</td></tr></table>";
}
else {
LP.innerHTML = "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>"+lD[0].innerHTML+"</table>";
}
}
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><a href="'+wgServer + '/wiki/' + encodeURI(page) + '" target="_new">' + page + '</a></b> • ' +
'(<a href="javascript:;" onClick="liveHist(\''+upage+'\');" style="color:darkorange">Hist</a>)';
var asNextDiff = doc.getElementById("differences-nextlink");
if(asNextDiff == null) {
var optAvert = "";
var optl = lstAvert.length;
for (j=0; j<optl; j++) {
optAvert += '<option value="'+lstAvert[j].template;
if(lstAvert[j].hasPage) optAvert += '|'+upage;
optAvert += '">'+lstAvert[j].string+'</option>';
}
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',doc,'td');
if (user1 != null && user1[0] != null)
user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',doc,'td');
if (user2 != null && user2[0] != null)
user2 = user2[0].getElementsByTagName('a')[2].innerHTML;
if (user2 == "défaire") {
user2 = getElementsByClass('diff-ntitle',doc,'td');
user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
}
user1=user1.replace(new RegExp(/\'/g), "\\'");
user2=user2.replace(new RegExp(/\'/g), "\\'");
entete.innerHTML = '<table width="100%" class="creator"><tr><td>' + entete.innerHTML +
'</td><td align="right"><small>' +
// Verifier avant si le patrouilleur peut modifier cette page ? (query.php?what=permissions&titles=page)
'[<a id="LiveRevertLink" href="javascript:getLiveMessage(\'liverevert\',\''+user1+'\',\''+user2+'\',\''+upage+'\',\''+oldid+'\');" >' + lang_menu[0].UNDORC+'</a>] • ' +
lang_menu[0].REASON+' : <input id="LiveRevertMessage" /> ••• ' +
'[<a id="LiveAvertoLink" href="javascript:getLiveAverto(\''+user2+'\');">'+lang_menu[0].AVERTS+'</a>] : ' +
'<select id="averto">' + optAvert + '</select>' +
'</td></tr></table>';
document.getElementById('LiveRevertMessage').focus();
}
}
function getLiveAverto(user) {
var link = document.getElementById('LiveAvertoLink');
link.href = "javascript:;";
link.style.color = "silver";
link.style.cursor = "default";
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 postLiveAverto(xmlreq, data) {
var parser = new DOMParser();
var doc = parser.parseFromString(xmlreq.responseText, 'application/xhtml+xml');
var user = data.user;
var message = data.message;
var wpTextbox1 = encodeURIComponent('{{subst:' + message + '}} ~~~~\n' + doc.getElementById('wpTextbox1').value);
var inputs = doc.getElementById('editform').getElementsByTagName('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']);
var wpSummary = encodeURIComponent('LiveRC : Avertissement ! ' + message.replace(new RegExp(/\|(.*)/), ' sur [[$1]]') + ' !');
var headers = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=User_Talk:' + encodeURI(user) + '&action=submit',
method: "POST", headers: headers,
data: 'wpSave=1&wpTextbox1=' + wpTextbox1 + '&wpStarttime=' + wpStarttime + '&wpEdittime=' + wpEdittime
+ '&wpEditToken=' + wpEditToken + '&wpSummary=' + wpSummary});
}
function getLiveMessage(where, user1, user2, page, oldid) {
var links = [ document.getElementById('LiveRevertLink') ];
var i,len=links.length;
for (i=0; i<len; i++) {
links[i].href = "javascript:;";
links[i].style.color = "silver";
links[i].style.cursor = "default";
links[i].style.textDecoration = "none";
}
document.getElementById('LiveRevertMessage').disabled = true;
var message = document.getElementById('LiveRevertMessage').value;
wpajax.http({ url: wgServer + wgScriptPath + '/index.php?title=' + encodeURI(page) + '&action=edit&oldid=' + oldid,
onSuccess: postLiveRevert,
where: where, page: page, user1: user1, user2: user2, message: message });
}
function postLiveRevert(xmlreq, data) {
var parser = new DOMParser();
var doc = parser.parseFromString(xmlreq.responseText, 'application/xhtml+xml');
var where = data.where;
var page = data.page;
var user1 = data.user1;
var user2 = data.user2;
var message = data.message;
var wpTextbox1 = encodeURIComponent(doc.getElementById('wpTextbox1').value);
var inputs = doc.getElementById('editform').getElementsByTagName('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 = lang_menu[0].RVMES1 + ' [[Special:Contributions/' + user2 + '|' + user2
+ ']]; '+lang_menu[0].RVMES2+' [[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 ===
<pre> */
function liveHist(page) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b style='text-decoration: blink;'>Hist : <span style='color:red'>"+page+"</span>...</b>";
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&action=history', onSuccess: getHist, message: page });
}
function getHist(xmlreq, data) {
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
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/'+encodeURIComponent(c)+'" target="_new">'+c+'</a></b>';
}
/* </pre>
=== LiveArticle ===
<pre> */
function liveArticle(page) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b style='text-decoration: blink;'><span style='color:red'>"+page+"</span>...</b>";
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(page) + '&redirect=no', onSuccess: getArticle, message: page });
}
function getArticle(xmlreq, data) {
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
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>';
}
/* </pre>
=== LiveContrib ===
<pre> */
function liveContrib(user) {
var el = document.getElementById( 'livePreviewTitle' );
el.innerHTML="<b style='text-decoration: blink;'><span style='color:red'>"+user+"</span>...</b>";
wpajax.http({url:wgServer + '/wiki/Special:Contributions/'+encodeURIComponent(user),
onSuccess: getContrib, message: user });
}
function getContrib(xmlreq, data) {
doc = gml_XMLParse(xmlreq.responseText);
bC = doc.getElementById('bodyContent')
var user=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 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><a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a></b>';
entete.innerHTML = '<table width="100%" class="creator"><tr><td>'+entete.innerHTML +
'</td><td align="right"><small>' +
'[<a id="LiveAvertoLink" href="javascript:var message=getLiveAverto(\''+utilde+'\');">'+lang_menu[0].AVERTS+'</a>] : ' +
'<select id="averto">' + optAvert + '</select>' + '</td></tr></table>';
}
/* </pre>
=== LiveSuivi ===
<pre> */
function liveSysop() {
wpajax.http({url:wgServer + wgScriptPath + '/index.php?title=Special:Listusers&limit=500&group=sysop',
onSuccess: getSysop, message: "Récup sysoplist" });
}
function getSysop(xmlreq, data) {
var doc = gml_XMLParse(xmlreq.responseText);
var bC = doc.getElementById('bodyContent');
var lstSys = bC.getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' );
var info="";
var len = lstSys.length
for(var i=0; i < len ; i++) {
info=lstSys[i].getElementsByTagName( 'a' )[ 0 ].innerHTML;
lstSysop.push(info);
}
liveNS();
}
function liveWatch() {
wpajax.http({url:wgServer + '/wiki/Special:Watchlist/edit',
onSuccess: getWatch, message: "Récup watchlist" });
}
function getWatch(xmlreq, data) {
var doc = gml_XMLParse(xmlreq.responseText);
var bC = doc.getElementById('bodyContent');
var info="";
var lstUL = bC.getElementsByTagName( 'ul' );
var lenUL = lstUL.length;
for(var j=0; j < lenUL ; j++) {
var lstLI = lstUL[j].getElementsByTagName( 'li' );
var lenLI = lstLI.length;
for(var i=0; i < lenLI ; i++) {
info=lstLI[i].getElementsByTagName( 'input' )[ 0 ].value;
lstSuivi.push(info);
lstSuiviHH.push("--:--");
}
}
liveRC();
}
/* function liveWatch() {
wpajax.http({url:wgServer + wgScriptPath + '/api.php?action=query&list=watchlist&wllimit=500&format=xml',
onSuccess: getWatch, message: "Récup watchlist" });
}
function getWatch(xmlreq, data) {
var a=xmlreq.responseText;
var c=data.message;
var i;
// document.getElementById('debug').innerHTML = a+"<br />**************************";
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;
} */
function liveNS() {
wpajax.http({url: wgServer + wgScriptPath + '/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml',
onSuccess: getNS, message: "Récup NS" });
}
function getNS(xmlreq, data) {
var api = xmlreq.responseXML;
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;
var options = "";
var lstNs = new Array();
for (i=0; i<len; i++) {
id = nss[i].getAttribute('id');
ns = nss[i].textContent;
if (id < 0) continue;
if (id == 0) ns = "Article";
options += '<option value="' + id + '">' + ns + '</option>';
lstNs.push(id);
}
options = '<option value="' + lstNs.join('|') + '">*</option>' + options;
document.getElementById('selectNS').innerHTML = '<label for="showNS0">'+lang_menu[0].NAMESP+' </label><select id="showNS0">' + options + '</select>';
liveWatch();
}
/* </pre>
=== LiveRC ===
<pre> */
function supprLigne(quelLigne) {
var i,len;
var tab = document.getElementById('tabRC');
var els = new Array();
if (quelLigne == '*')
els = tab.getElementsByTagName('tr');
else if (quelLigne == 'd') {
var _els = tab.getElementsByTagName('tr');
len = _els.length;
for (i=len-1; i>=0; i--)
if (_els[i].firstChild.style.backgroundColor == 'rgb(255, 250, 205)')
els.push(_els[i]);
} else if (quelLigne == 'r') {
var _els = tab.getElementsByTagName('tr');
len = _els.length;
for (i=len-1; i>=0; i--)
if (_els[i].firstChild.style.backgroundColor == 'rgb(255, 228, 225)')
els.push(_els[i]);
} else if (quelLigne == 'n') {
var _els = tab.getElementsByTagName('tr');
len = _els.length;
for (i=len-1; i>=0; i--)
if (_els[i].firstChild.style.backgroundColor == 'rgb(226, 242, 210)')
els.push(_els[i]);
} else
els.push(document.getElementById(quelLigne));
len = els.length;
for (i=len-1; i>=0; i--)
if (els[i] != null)
tab.removeChild(els[i]);
}
function changeLigne(quelLigne) {
var el = document.getElementById(quelLigne);
var els1 = el.getElementsByTagName('th');
var els2 = el.getElementsByTagName('td');
var len = els1.length;
for (var i=len-1; i>=0; i--)
if (els1[i] != null)
els1[i].style.backgroundColor = "#FFFACD";
var len = els2.length;
for (var i=len-1; i>=0; i--)
if (els2[i] != null)
els2[i].style.backgroundColor = "#FFFFE0";
}
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;
}
function tsToHhMm(timestamp) {
var tz;
var match, regex = new RegExp();
if (lrcTZ) {
regex.compile(/^([-+])?(\d?\d):?(\d\d)$/);
match = regex.exec(lrcTZ);
if (!match) {
//livercError(lang_error.TZ);
return 'xx:xx';
}
tz = match[2]*60 + match[3]*1;
tz = match[1] == '-' ? -tz : tz;
} else {
var now = new Date();
tz = -now.getTimezoneOffset();
}
regex.compile(/^\d\d\d\d-\d\d-\d\dT(\d\d):(\d\d):\d\dZ$/);
match = regex.exec(timestamp);
if (!match) {
//livercError(lang_error.timestamp);
return 'xx:xx';
}
var tt = (match[1]*60 + match[2]*1 + tz + 1440) % 1440;
var mm = tt % 60;
var hh = (tt - mm) / 60 % 24;
return hh + ':' + (mm < 10 ? '0' : '') + mm;
}
function updateFollowContact() {
var tempAr = new Array();
for (var user in lstContact) {
var timestamp = lstContact[user].ts;
if (timestamp == 0) continue;
var utilde = user.replace(new RegExp(/\'/g), "\\'");
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>';
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:#43CD80">C</a>';
var uadmin = '';
if (lrcAdmin == true) {
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>';
}
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>';
var ligne = '<span id="contact-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + uadmin + ' • </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 tempAr = new Array();
for (var user in lstRevoc) {
var timestamp = lstRevoc[user].ts;
var utilde = user.replace(new RegExp(/\'/g), "\\'");
var udiscut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>';
var ucontrib = '<a href="javascript:;" onClick="liveContrib(\''+utilde+'\');" style="color:#43CD80">C</a>';
var uadmin = '';
if (lrcAdmin == true) {
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>';
}
var ueditor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>';
var ligne = '<span id="revoc-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib + uadmin + ' • </small>' + ueditor + ' (' + lstRevoc[user].nb + ' '+lang_menu[0].XTIMES+')</span><br />';
tempAr.push(ligne);
}
tempAr.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];
if (api.firstChild.nodeName == "error") return;
var match, regex = new RegExp();
var rc = data.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 timestamp = rc.timestamp;
var ns = rc.ns;
var state = rc.state;
regex.compile(/\'/g);
var escTitle = title.replace(regex, "\\'");
var escUser = user.replace(regex, "\\'");
var revisions = api.getElementsByTagName('query')[0].getElementsByTagName('pages')[0].getElementsByTagName('page')[0].getElementsByTagName('revisions')[0].getElementsByTagName('rev');
var oldsize = (state & NEW ? 0 : revisions[1].textContent.length);
var newsize = revisions[0].textContent.length
var sizediff = newsize - oldsize;
// INITIALISATION LIGNE RC //
var tr1 = document.createElement('tr');
var th0 = document.createElement('th');
var th1 = document.createElement('th');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
var td4 = document.createElement('td');
// SUPPR. LIGNE //
th0.innerHTML = '<a href="javascript:;" onClick="supprLigne(\''+pageid+'_'+revid+'\');" style="color:red">X</a>';
// ARTICLE //
var arti = "", artiStyle = "";
var preArti = "", postArti = "";
var diff = "";
var diffClose = "";
if (lrcAutoCloseDiff == 1)
diffClose='supprLigne(\''+pageid+'_'+revid+'\');';
if (state & NEW)
diff = '<a href="javascript:;" onClick="changeLigne(\''+pageid+'_'+revid+'\');liveArticle(\''+escTitle+'\');'+diffClose+'" style="color:green">New</a>';
else
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 edit = '<a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=edit" target="_new" style="color:tomato">E</a>';
var admin = '';
if (lrcAdmin == true) {
admin = ' • <a href="' + wgServer + wgScriptPath + '/index.php?title='+encodeURI(escTitle)+'&action=delete" target="_new" style="color:orangered">S</a>';
}
// Disambig / Homonymie ? ;
///////////////////////////
if (ns == 0 && state & HOMONYMIE) {
artiStyle = 'color: darkorange; font-weight: bold; font-style: italic;';
preArti += '<img src="/media/wikipedia/commons/thumb/7/72/Disambig.svg/16px-Disambig.svg.png" width="16px" alt="Homonymie" /> '
}
// Page protégée ? ;
////////////////////
if (state & FULLLOCK)
preArti += '<img src="/media/wikipedia/commons/thumb/4/48/Padlock-red.svg/16px-Padlock-red.svg.png" width="16px" alt="Article protégé"/> ';
if (state & LOCK)
preArti += '<img src="/media/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="/media/wikipedia/commons/thumb/b/b0/Copyright.svg/16px-Copyright.svg.png" width="16px" alt="Copyright" /> ';
// PàS ? ;
//////////////////
if (state & PAS)
preArti += '<img src="/media/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="/media/wikipedia/commons/thumb/9/99/FireIcon.svg/12px-FireIcon.svg.png" height="12px" alt="Intervention Wikipompiers" /> ';
// Adq ? ;
//////////
if (state & ADQ)
postArti += '<sup><img src="/media/wikipedia/commons/thumb/c/c7/Fairytale_bookmark_gold.png/10px-Fairytale_bookmark_gold.png" width="10px" alt="Adq" /></sup>';
// Bon article ? ;
//////////////////
if (state & BA)
postArti += '<sup><img src="/media/wikipedia/commons/thumb/8/8a/Fairytale_bookmark_silver_light.png/10px-Fairytale_bookmark_silver_light.png" width="10px" alt="Bon article" /></sup>';
// Article potentiellement de qualité ? ;
/////////////////////////////////////////
if (state & APDQ)
postArti += '<sup><img src="/media/wikipedia/commons/thumb/9/9a/Fairytale_bookmark_light.png/10px-Fairytale_bookmark_light.png" width="10px" alt="Article potentiellement de qualité" /></sup>';
// Article catégorisé ? ;
/////////////////////////
var isCategorized = "";
if (!(state & REDIRECT)
&& !(state & HOMONYMIE)
&& ns == 0
&& !(state & CATEGORIZED))
postArti += '<sup style="color:crimson">(cat ?)</sup>';
// Redirect ? ;
//////////////////
if (state & REDIRECT) {
artiStyle = 'color: green; font-weight: bold; font-style: italic;';
postArti += '<img src="/media/wikipedia/commons/thumb/b/b5/Redirectltr.png/20px-Redirectltr.png" width="20px" alt="Redirection" />';
if (rc.redirect) {
// postArti += '<a href="'+wgServer+'/wiki/'+encodeURIComponent(rc.redirect)+'" target="_new">'+rc.redirect+'</a>';
postArti += '<a href="javascript:;" onClick="liveArticle(\''+rc.redirect+'\');">'+rc.redirect+'</a>';
} else {
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>';
}
th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • ' + edit + admin + ' • </small>'
+ preArti + arti + postArti;
th1.className="creator-title";
th1.style.border="1px";
th1.style.width="40%";
// EDITOR //
////////////
var discut = '<a href="'+wgServer+'/wiki/User talk:'+encodeURIComponent(user)+'" style="color:seagreen" target="_new">T</a>';
var contrib = '<a href="javascript:;" onClick="liveContrib(\''+escUser+'\');" style="color:#43CD80">C</a>';
var editor = "", preEditor = "";
// Bot ? ;
//////////
if (state & BOT)
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2a/Nuvola_apps_kservices.png/16px-Nuvola_apps_kservices.png" width="16px" /> ';
// Sysop ? ;
////////////
if (state & SYSOP)
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2c/Broom_icon.svg/16px-Broom_icon.svg.png" width="16px" /> ';
// Reverted ? ;
/////////////////
if (state & REVERT)
preEditor += '<img src="/media/wikipedia/commons/thumb/2/2c/Nuvola_actions_undo.png/16px-Nuvola_actions_undo.png" width="16px" /> ';
// TOR potentiel / AOL
var isTOR = regex.compile(/172\.\d+\.\d+\.\d+/);
if (isTOR.test(user))
preEditor += '<img src="/media/wikipedia/commons/thumb/6/6e/Dialog-warning.svg/16px-Dialog-warning.svg.png" width="16px" /> ';
editor = '<a href="'+wgServer+'/wiki/User:'+encodeURIComponent(user)+'" target="_new">'+user+'</a>';
var uadmin = '';
if (lrcAdmin == true) {
uadmin = ' • <a href="'+wgServer+'/wiki/Special:Blockip/'+encodeURI(user)+'" target="_new" style="color:seagreen">B</a>';
}
td2.innerHTML = '<small>' + discut + ' • ' + contrib + uadmin + ' • </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>'
}
// COMMENT //
// Remplace lien [[xxx]] par <a> ;
var wcomment = comment.htmlize();
regex.compile(/\[\[(([^\]\|]*)(.*?))\]\]/g);
wcomment = wcomment.replace(regex, "<a href='"+wgServer+wgScriptPath+"/index.php?title=$2&redirect=no' target='_new'>$1</a>");
regex.compile(/\>[^\]\|<]*\|([^\]\|<]*)</g);
wcomment = wcomment.replace(regex, ">$1<");
td3.innerHTML = "<small>" + wcomment + "</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="/media/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 > lrcRCLimit) {
var idt = tab.lastChild.id;
supprLigne(idt);
}
} else {
supprLigne(pageid+"_"+oldid);
}
// MISE A JOUR LISTES //
var spos = lstSuivi.indexOf(title);
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] = tsToHhMm(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+'\','+revid+','+oldid+');" style="color:orange">Diff</a>';
var shist = '<a href="javascript:;" onClick="liveHist(\''+cstilde+'\');" style="color:darkorange">H</a>';
var sarti = '<a href="javascript:;" onClick="liveArticle(\''+cstilde+'\');">'+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]) {
lstContact[user].ts = timestamp;
updateFollowContact();
}
if (state & REVERT) {
regex.compile(/\[\[Special:Contributions\/([^\]\|]+)/);
match = regex.exec(comment);
if (match) {
var userR = match[1];
if (userR != user && userR != wgUserName) {
if (!lstRevoc[userR]) lstRevoc[userR] = { ts: 0, nb: 0 };
lstRevoc[userR].ts = timestamp;
lstRevoc[userR].nb += 1;
updateFollowRevoc();
}
}
}
}
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;
if (page.getElementsByTagName('redirect')[0].getElementsByTagName('to').length)
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 api = xmlreq.responseXML.getElementsByTagName('api')[0];
if (api.firstChild.nodeName == "error") return;
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 '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=' + encodeURIComponent(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 refresh = 10;
timer= setTimeout("liveRC()",refresh*1000);
if (document.getElementById('stopLive').checked) return;
var rcns = document.getElementById('showNS0').value;
if (rcns == null) return;
var rcshow = "";
if (document.getElementById('showBot').checked) rcshow = '&rcshow=!bot';
wpajax.http({url:wgServer + wgScriptPath
+ '/api.php?action=query&list=recentchanges&rcnamespace=' + rcns
+ '&rcprop=user|comment|flags' + rcshow
+ '&rcend=' + lasttimestamp + '&rclimit=' + lrcRCLimit + '&format=xml',
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
ofils.style.display="none";
}
addOnloadHook(function () {
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' );
top.style.display = "none";
siteSub.style.display = "none";
contentSub.style.display = "none";
if (rtb != null) rtb.style.display = "none";
if (rt != null) rt.style.display = "none";
if (pca != null) pca.style.display = "none";
var lvPreviewFoot = document.getElementById( 'livePreviewFoot' );
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' +
'<a href="javascript:;" onClick="supprLigne(\'d\');" style="color: rgb(255, 235, 71); font-weight: bold;">X</a>' +
'<a href="javascript:;" onClick="supprLigne(\'r\');" style="color: rgb(255, 99, 83); font-weight: bold;">X</a>' +
'<a href="javascript:;" onClick="supprLigne(\'n\');" style="color: rgb(178, 243, 113); 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 (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight;
var _lstContact = lstContact;
var _len = lstContact.length;
lstContact = new Array();
for (var _i=0; _i<_len; _i++)
lstContact[_lstContact[_i]] = { ts: 0 };
// Main
liveSysop();
}
});
/* </pre> */