User:Jldupont~enwiki/LiveRC.js

/*

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

LiveDiff
";   }    else {      LP.innerHTML = " ";    }  }  if (dLP.style.display == "none") {    var elcb = document.getElementById( 'shidPrev' );    elcb.checked="true";    dLP.style.display = "inline";  }

var entete = document.getElementById( 'livePreviewTitle' ); entete.innerHTML='' + page + ' • ' + '(Hist)';

var asNextDiff = doc.getElementById("differences-nextlink"); if(asNextDiff == null) { var optAvert = ""; var optl = lstAvert.length; for (j=0; j'+lstAvert[j].string+' '; }

// Get username of submitter var user1 = getElementsByClass('diff-otitle',doc,'td'); if (user1 != null && user1[0] != null) { var usertmp=user1[0].innerHTML; user1 = usertmp.replace(new RegExp(/(.*)(.*)<\/a> \((.*)<\/a>  \(<a(.*)/g), "$3"); }   user1=user1.replace(new RegExp(/\'/g), "\\'"); user2=user2.replace(new RegExp(/\'/g), "\\'");

entete.innerHTML = ' '; 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: mw.config.get('wgServer') + mw.config.get('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.replace(new RegExp(/\\'/g),"'"); // Message au début // var wpTextbox1 = encodeURIComponent(' ~\n' + doc.getElementById('wpTextbox1').value);

var wpTextbox1 = encodeURIComponent(doc.getElementById('wpTextbox1').value + '\n\n ~\n');

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 wpSummary = encodeURIComponent('LiveRC : Warning following edits ! ' + message.replace(new RegExp(/\|(.*)/), ' on $1') + ' !');

var headers = new Array; headers['Content-Type'] = 'application/x-www-form-urlencoded'; wpajax.http({ url: mw.config.get('wgServer') + mw.config.get('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: mw.config.get('wgServer') + mw.config.get('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 + ' ' + user2       + '; '+lang_menu[0].RVMES2+' ' + user1 + ''; break; /*   case 'livevandalism': var wpSummary = 'LiveRC : Révocation de vandalisme par ' + user2       + '; retour à la version de ' + 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: mw.config.get('wgServer') + mw.config.get('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}); }

/*

LiveContrib
'; }

/*

LiveRC
*/