User:Gz260/LiveRC.js

/*

LiveWP

 * Documentation : fr:User:EDUCA33E/LiveRC/Documentation
 * Author : fr:User:EDUCA33E
 * Dev & enhancements : fr:User:TiChou, pl:User:Leafnode & it:User:Jalo
 * Version: 0.3.7 (beta)

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) && lrcPatrol) { var optAvert = ""; var optl = lstAvert.length; for (j=0; j'+lstAvert[j].string+' '; }

// Get username of submitter var user1 = doc.getElementById( 'mw-diff-otitle2' ); if (user1 != null) { var usertmp=user1.innerHTML; // user1 = usertmp.replace(new RegExp(/(.*)<\/a> \((.*)<\/a>(.*)\((.*)\)/g), "$2");      user1 = user1.replace(new RegExp(/(.*)<(.*)>/g), "$1");    }    var user2 = doc.getElementById( 'mw-diff-ntitle2' );    if (user2 != null) {      var usertmp=user2.innerHTML;      // user2 = usertmp.replace(new RegExp(/(.*)<\/a>  \((.*)<\/a>(.*)\([éditeur précédent identique] ";    }

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 : « ' + message.replace(new RegExp(/\|(.*)/), ' » suite aux modifications 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 a 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
*/