« MediaWiki:Gadget-RevertDiff.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Dr Brains (discuter | contributions)
m fix temporaire
Migration vers ResourceLoader
Ligne 9 :
*/
//<nowiki>
var RevertDiffParams = new Object();
RevertDiffParams.Text = new Object();
RevertDiffParams.Text.Annul = "Annuler";
RevertDiffParams.Text.AnnulResume = 'Annulation des modifications de [[Special:Contributions/$2|$2]] (retour à la précédente version de [[Special:Contributions/$1|$1]])';
RevertDiffParams.Text.Message = "Message";
RevertDiffParams.Text.MessageAlert = 'Quel message faut-il laisser ?';
RevertDiffParams.Text.Revert = "Révoquer";
RevertDiffParams.Text.RevertResume = 'Révocation des modifications de [[Special:Contributions/$2|$2]] (retour à la précédente version de [[Special:Contributions/$1|$1]])';
RevertDiffParams.Text.Warn = "Avertir";
 
if (typeof window.RevertDiffParams === 'undefined') {
RevertDiffParams.Warn = [
var window.RevertDiffParams = new Object();
{urlparam:"warn=01", text:"Maladresse", template:'{{subst:Test 0|$page|user=$user}}'},
 
{urlparam:"warn=02", text:"Vandalisme", template:'{{subst:Test 1|$page|user=$user}}'},
window.RevertDiffParams.Text = new Object();
{urlparam:"warn=03", text:"Test2", template:'{{subst:Test 2}} ~~~~'},
window.RevertDiffParams.Text.Annul = "Annuler";
{urlparam:"warn=04", text:"Test3", template:'{{subst:Test 3}} ~~~~'},
window.RevertDiffParams.Text.AnnulResume = 'Annulation des modifications de [[Special:Contributions/$2|$2]] (retour à la précédente version de [[Special:Contributions/$1|$1]])';
{urlparam:"warn=05", text:"Test4", template:'{{subst:Seul avertissement}} ~~~~'},
window.RevertDiffParams.Text.Message = "Message";
{urlparam:"warn=06", text:"Lien externe", template:'{{subst:Bienvenue spammeur|$page|user=$user}}'},
window.RevertDiffParams.Text.MessageAlert = 'Quel message faut-il laisser ?';
{urlparam:"warn=07", text:"Faut sourcer", template:'{{subst:Faut sourcer|$page|user=$user}}'},
window.RevertDiffParams.Text.Revert = "Révoquer";
{urlparam:"warn=08", text:"Bienvenue", template:'{{Bienvenue nouveau|sign=~~~~}}'},
window.RevertDiffParams.Text.RevertResume = 'Révocation des modifications de [[Special:Contributions/$2|$2]] (retour à la précédente version de [[Special:Contributions/$1|$1]])';
{urlparam:"warn=09", text:"BienvenueIP", template:'{{Bienvenue IP}} ~~~~'},
window.RevertDiffParams.Text.Warn = "Avertir";
{urlparam:"warn=10", text:"MerciIP", template:'{{Bienvenue IP méritante|sign=~~~~}}'}
 
];
 
window.RevertDiffParams.Warn = [
{urlparam:"warn=01", text:"Maladresse", template:'{{subst:Test 0|$page|user=$user}}'},
{urlparam:"warn=02", text:"Vandalisme", template:'{{subst:Test 1|$page|user=$user}}'},
{urlparam:"warn=03", text:"Test2", template:'{{subst:Test 2}} ~~~~'},
{urlparam:"warn=04", text:"Test3", template:'{{subst:Test 3}} ~~~~'},
{urlparam:"warn=05", text:"Test4", template:'{{subst:Seul avertissement}} ~~~~'},
{urlparam:"warn=06", text:"Lien externe", template:'{{subst:Bienvenue spammeur|$page|user=$user}}'},
{urlparam:"warn=07", text:"Faut sourcer", template:'{{subst:Faut sourcer|$page|user=$user}}'},
{urlparam:"warn=08", text:"Bienvenue", template:'{{Bienvenue nouveau|sign=~~~~}}'},
{urlparam:"warn=09", text:"BienvenueIP", template:'{{Bienvenue IP}} ~~~~'},
{urlparam:"warn=10", text:"MerciIP", template:'{{Bienvenue IP méritante|sign=~~~~}}'}
];
}
 
 
function getURLParameters(x) {
var questionMark = x.indexOf('?');
if (questionMark == -1) return {}
var fieldsArray = x.substr(questionMark + 1).split('&');
var fields = {};
for (var i = 0; i < fieldsArray.length; i++) {
var field = fieldsArray[i];
Ligne 52 ⟶ 55 :
return fields;
}
 
_GET = getURLParameters(location.href);
 
function window.getMessage = function(chemin, where, user1, user2) {
var message = prompt (window.RevertDiffParams.Text.MessageAlert, '');
if (message) {
window.location = chemin + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
};
 
$(document).ready(function (){
if (location.href.match(/diff=/)) {
Ligne 68 ⟶ 71 :
var user2TD = $('td.diff-ntitle')[0];
if(!user1TD || !user2TD) return;
 
// Récupération du chemin vers la version à rétablir
var chemin = encodeURI(user1TD.getElementsByTagName('a')[1].href);
 
var user1 = $(user1TD).find('a.mw-userlink')[0].innerHTML;
var user2 = $(user2TD).find('a.mw-userlink')[0].innerHTML;
 
var Annul = '('
+ '<a href="'+chemin+'&annul=1&user1='+user1+'&user2='+user2+'">'+window.RevertDiffParams.Text.Annul+'</a>'
+ ' / '
+ '<a href="javascript:window.getMessage(\''+chemin+'\',\'annul\',\''+user1+'\',\''+user2+'\');">'+window.RevertDiffParams.Text.Message+'</a>'
+ ')';
 
var Revert = '('
+ '<a href="'+chemin+'&revert=1&user1='+user1+'&user2='+user2+'">'+window.RevertDiffParams.Text.Revert+'</a>'
+ ' / '
+ '<a href="javascript:window.getMessage(\''+chemin+'\',\'revert\',\''+user1+'\',\''+user2+'\');">'+window.RevertDiffParams.Text.Message+'</a>'
+ ')';
 
var Warn = '('+window.RevertDiffParams.Text.Warn+' : ';
var SiteURL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=';
for(var a=0,l=window.RevertDiffParams.Warn.length;a<l;a++){
if(a!=0) Warn += ' / ';
Warn += '<a href="'+SiteURL+'User_talk:'+user2+'&action=edit&section=new'
+ '&'+window.RevertDiffParams.Warn[a].urlparam+'" '
+ 'title="'+window.RevertDiffParams.Warn[a].template+'" '
+ '>'+window.RevertDiffParams.Warn[a].text+'</a>';
}
Warn += ')';
document.getElementById('contentSub').innerHTML = Annul + " " + Revert + " " + Warn;
 
}else if (location.href.match(/annul=1/)) {
document.getElementById('wpSummary').value = window.RevertDiffParams.Text.AnnulResume.split("$1").join(_GET['user1']).split("$2").join(_GET['user2']);
document.getElementById('editform').submit();
}else if (location.href.match(/annul=2/)) {
document.getElementById('wpSummary').value =
window.RevertDiffParams.Text.AnnulResume.split("$1").join(_GET['user1']).split("$2").join(_GET['user2']) + ' : '+_GET['message'];
document.getElementById('editform').submit();
}else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = window.RevertDiffParams.Text.RevertResume.split("$1").join(_GET['user1']).split("$2").join(_GET['user2']);
document.getElementById('editform').submit();
}else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value =
window.RevertDiffParams.Text.RevertResume.split("$1").join(_GET['user1']).split("$2").join(_GET['user2']) + ' : '+_GET['message'];
document.getElementById('editform').submit();
}else{
for(var a=0,l=window.RevertDiffParams.Warn.length;a<l;a++){
var Warn = window.RevertDiffParams.Warn[a];
if (location.href.match(new RegExp(Warn.urlparam))) {
var Template = Warn.template;