Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
//Gadget DJ
var DJparam_sidebarlink = false;
importScript('Utilisateur:0x010C/script/DrapeauJaune.js');
//Avertit du niveau de vandalisme à l'arrivée sur wikipédia
//Crédits : Créé par [[Utilisateur:0x010C]] (adapté d'un précédent code de [[Utilisateur:Dr Brains]])
//Documentation : [[Utilisateur:0x010C/script#PopupVandalism.js]]

function PopVand_GetVand()
{
    $.post(mw.config.get("wgScript"), { title: "Utilisateur:0x010C/script/PopupVandalism.js/box", action: "purge" }, function (Response)
    {
        if (PopVand_Mode == "text" || PopVand_Mode == "Text") {
            PopVand_DisplayVandText(Response);
        } else if (PopVand_Mode == "box" || PopVand_Mode == "Box") {
            PopVand_DisplayVandBox(Response);
        } else {
            PopVand_DisplayVandText(Response);
            PopVand_DisplayVandBox(Response);
        }
    });
}

function PopVand_DisplayVandBox(Response)
 {
    var Content = document.getElementById("content");
    var Div = document.createElement('div');
    Div.style.display = "none";
    Content.insertBefore(Div, Content.firstChild);
    Div.innerHTML = Response;
    var box = Div.getElementsByClassName("ModeleBUtilisateur")[0];
    Div.innerHTML = "";
    Div.appendChild(box);
    Div.style.display = "";
    Div.setAttribute("style", "float:right;");
}
function PopVand_DisplayVandText(Response){
	var li = document.createElement('li');
	li.innerHTML = Response;
	var lvl = li.getElementsByClassName("ModeleBUtilisateurImgTexte")[0].getElementsByTagName("b")[0].innerHTML;
    li.innerHTML = "";
    li.style.display = "";

	var spancolor;
	if(PopVand_Color === true)
	{
		switch(lvl)
		{
			case "1":
				spancolor = '<span style="color:white;background:red;">';
				break;
			case "2":
				spancolor = '<span style="color:red;">';
				break;
			case "3":
				spancolor = '<span style="color:orange;">';
				break;
			case "4":
				spancolor = '<span style="color:green;">';
				break;
			case "5":
				spancolor = '<span style="color:blue;">';
				break;
		}
	}
	else
		spancolor = '<span>';
    li.innerHTML = '<a href="/wiki/Modèle:Alerte_vandalisme" title="Alerte vandalisme">' + spancolor + 'Vandalisme ' + lvl + '</span></a>';

    document.getElementById("p-navigation").getElementsByTagName("ul")[0].appendChild(li);
}

if (typeof PopVand_Mode == "undefined") {
    var PopVand_Mode = "both";
}
if (typeof PopVand_Color == "undefined") {
    var PopVand_Color = true;
}

$(PopVand_GetVand);
//<nowiki>
C.tag = {
  dialog: null,
  config: {
    'modal-title': 'C helper - Ajouter/retirer des bandeaux de maintenance',
    'submit': 'Valider la requête',
    'c-tag-checkbox-class': 'c-tag-checkbox',
    'c-tag-radio-class': 'c-tag-radio',
    'notify-success': 'Les bandeaux ont bien été ajoutés.',
    'notify-no-reason': 'Vous n\'avez fait aucun changement.',
    'notify-not-a-page': 'Impossible de gérer les bandeaux d\'une page inexistante.',
    'notify-protected': 'Impossible de gérer les bandeaux de cette page, celle-ci est protégée.',
    'add-summary': 'Ajout de $1',
    'template-link-summary': '{{[[Modèle:$1|$1]]}}',
  },
  categories: [
  	{display:"Les plus utilisés", node:null}, //0
  	{display:"Admissibilité", node:null}, //1
  	{display:"Neutralité", node:null},    //2
  	{display:"Mise en forme", node:null}, //3
  	{display:"Sourçage", node:null}, //4
  ],
  /*
    {category:, display:'', template:'', help:'', reason:'', extra:''},
	Magic words :
		* $(page)
		* $(diff)
		* $(user)
		* $(day) $(month) $(year)
		* $(reason)
		* $(extra)
  */
  templates: [
	{category:3, display:'À catégoriser', template:'{{À catégoriser}}', help:''},
	{category:3, display:'À dater', template:'{{À dater}}', help:''},
	{category:3, display:'À déjargoniser', template:'{{À déjargoniser}}', help:''},
	{category:3, display:'À délister', template:'{{À délister}}', help:''},
	{category:3, display:'À désacadémiser', template:'{{À désacadémiser}}', help:''},
	{category:3, display:'À désangliciser', template:'{{À désangliciser}}', help:''},
	{category:3, display:'À fusionner', template:'{{À fusionner|$(extra)}}', extra:'Liste des articles à fusionner, séparés par des « | » :', help:''},
	{category:3, display:'À illustrer', template:'{{À illustrer}}', help:''},
	{category:3, display:'À recycler', template:'{{À recycler|date=$(month) $(year)}}', help:''},
	{category:0, display:'À sourcer', template:'{{À sourcer|date=$(month) $(year)}}', help:''},
	{category:3, display:'À TeXifier', template:'{{À TeXifier}}', help:''},
	{category:4, display:'À vérifier', template:'{{À vérifier}}', help:''},
	{category:0, display:'À wikifier', template:'{{À wikifier|date=$(month) $(year)}}', help:''},
	{category:0, display:'Admissibilité à vérifier', template:'{{Admissibilité à vérifier|date=$(month) $(year)|motif=$(reason)}}', reason:'Motif :', help:''},
	{category:3, display:'Alerte langue', template:'{{Alerte langue|$(reason)|$(extra)}}', extra:'Nom de la langue, tel qu’utilisé dans l’article relatif à cette langue :', reason:'nom de la langue utilisée ainsi qu’au moins une lettre de cette langue qui pourrait poser des problèmes d’affichage :', help:''},
	{category:2, display:'Anecdotes', template:'{{Anecdotes}}', help:''},
	{category:2, display:'Anthropocentrisme', template:'{{Anthropocentrisme|date=$(month) $(year)}}', help:''},
	{category:3, display:'Article court', template:'{{Article court|$(extra)}}', extra:'Article dans lequel le sujet est plus développé :', help:''},
	{category:0, display:'Article en sursis', template:'{{Article en sursis|timestamp={{subst:' + 'CURRENTTIMESTAMP}}}}', help:''},
	{category:0, display:'Article incompréhensible', template:'{{Article incompréhensible|date=$(month) $(year)}}', help:''},
	{category:3, display:'Article mal proportionné', template:'{{Article mal proportionné}}', help:''},
	{category:2, display:'Article non neutre', template:'{{Article non neutre|date=$(month) $(year)}}', help:''},
	{category:3, display:'Av. J.-C.', template:'{{Av. J.-C.}}', help:''},
	{category:0, display:'Avantage non déclaré', template:'{{Avantage non déclaré|date=$(month) $(year)}}', help:''},
	{category:3, display:'Avertissement Liste', template:'{{Avertissement Liste|$(reason)|$(extra)}}', extra:'Catégorie liée à la liste (sans le préfixe Catégorie: ; facultatif) :', reason:'Éléments référencés :', help:''},
	{category:3, display:'Avertissement liste wikidata', template:'{{Avertissement liste wikidata}}', help:''},
	{category:3, display:'Confusion', template:'{{Confusion|$(reason)}}', reason:'Lien(s) vers un ou plusieurs autres articles, séparés par des « | » :', help:''},
	{category:4, display:'Conventions bibliographiques', template:'{{Conventions bibliographiques|date=$(month) $(year)}}', help:''},
	{category:0, display:'Copie à vérifier', template:'{{Copie à vérifier|1=$(reason)|date=$(month) $(year)}}', reason:'Adresse du site copié :', help:''},
	{category:3, display:'Copie de site', template:'{{Copie de site|1=$(reason)}}', reason:'Adresse du site copié : ', help:''},
	{category:2, display:'Désaccord de neutralité', template:'{{Désaccord de neutralité|date=$(month) $(year)}}', help:''},
	{category:2, display:'Désaccord de pertinence', template:'{{Désaccord de pertinence|date=$(month) $(year)}}', help:''},
	{category:4, display:'Détournement de sources', template:'{{Détournement de sources}}', help:''},
	{category:0, display:'En travaux', template:'{{En travaux|$(user)|date=$(day) $(month) $(year)|commentaire=$(extra)}}', extra:'Commentaire facultatif :', help:''},
	{category:3, display:'Fusion d\'Historique', template:'{{Fusion d\'Historique|$(reason)|~~~}}', extra:'', reason:'Motif de la fusion :', help:''},
	{category:3, display:'Fusion technique', template:'{{Fusion technique|$(extra)}}', extra:'Liste des articles qui font l\'objet de la fusion, sparés par des « | » :', help:''},
	{category:0, display:'Internationaliser', template:'{{Internationaliser|date=$(month) $(year)}}', help:''},
	{category:2, display:'Introduction régionale', template:'{{Introduction régionale|date=$(month) $(year)}}', help:''},
	{category:4, display:'Lien internet incomplet', template:'{{Lien internet incomplet}}', help:''},
	{category:3, display:'Lire d\'abord', template:'{{Lire d\'abord|$(extra)}}', extra:'Liste des articles à lire d\'abord, séparés par des « | » :', reason:'', help:''},
	{category:0, display:'Mettre à jour', template:'{{Mettre à jour|$(reason)|date=$(month) $(year)|commentaire=$(extra)}}', extra:'Justification de la présence du bandeau (facultatif) :', reason:'Date de dernière mise à jour (facultatif) :', help:''},
	{category:1, display:'Notoriété art', template:'{{Notoriété art|date=$(month) $(year)}}', help:''},
	{category:0, display:'Orthographe', template:'{{Orthographe|date=$(month) $(year)}}', help:''},
	{category:4, display:'Pas de liens externes', template:'{{Pas de liens externes}}', help:''},
	{category:3, display:'Plan', template:'{{Plan|date=$(month) $(year)}}', help:''},
	{category:3, display:'Plusieurs en cours', template:'{{Plusieurs en cours}}', help:''},
	{category:2, display:'Point de vue interne', template:'{{Point de vue interne|date=$(month) $(year)}}', help:''},
	{category:1, display:'Pour Wikiquote', template:'{{Pour Wikiquote}}', help:''},
	{category:2, display:'POV fork', template:'{{POV fork}}', help:''},
	{category:0, display:'Promotionnel', template:'{{Promotionnel|date=$(month) $(year)}}', help:''},
	{category:0, display:'R3R', template:'{{R3R|1=~~~~}}', help:''},
	{category:3, display:'Redirect confusion', template:'{{Redirect confusion|$(reason)|$(extra)}}', extra:'Confusion possible avec l\'article :', reason:'Nom de la redirection :', help:''},
	{category:3, display:'Résumé introductif', template:'{{Résumé introductif|date=$(month) $(year)}}', help:''},
	{category:3, display:'Résumé introductif trop court', template:'{{Résumé introductif trop court|date=$(month) $(year)}}', help:''},
	{category:3, display:'Résumé introductif trop long', template:'{{Résumé introductif trop long|date=$(month) $(year)}}', help:''},
	{category:4, display:'Sans source', template:'{{Sans source|date=$(month) $(year)}}', help:''},
	{category:2, display:'Scrutin en cours', template:'{{Scrutin en cours}}', help:''},
	{category:4, display:'Sources à lier', template:'{{Sources à lier|date=$(month) $(year)}}', help:''},
	{category:4, display:'Sources obsolètes', template:'{{Sources obsolètes|date=$(month) $(year)}}', help:''},
	{category:0, display:'Sources secondaires', template:'{{Sources secondaires|date=$(month) $(year)}}', help:''},
	{category:0, display:'Style non encyclopédique', template:'{{Style non encyclopédique|date=$(month) $(year)}}', help:''},
	{category:0, display:'Suppression', template:'{{Suppression|date=$(month) $(year)}}', help:'Attention, il faut à la suite de la pose de ce bandeau ouvrir manuellement la procédure de PàS. Suivez les explications qui apparaîtront sur le bandeau.'},
	{category:3, display:'Synopsis', template:'{{Synopsis|date=$(month) $(year)}}', help:''},
	{category:3, display:'Titre incorrect', template:'{{Titre incorrect|1=$(reason)}}', reason:'Titre souhaité :', help:''},
	{category:0, display:'Travail inédit', template:'{{Travail inédit|date=$(month) $(year)|Cet article peut contenir}}', help:''},
	{category:3, display:'Trop d\'images', template:'{{Trop d\'images|date=$(month) $(year)}}', help:''},
	{category:3, display:'Trop de citations', template:'{{Trop de citations|date=$(month) $(year)}}', help:''},
	{category:3, display:'Trop de liens', template:'{{Trop de liens|date=$(month) $(year)}}', help:''},
	{category:3, display:'Trop de wikiliens', template:'{{Trop de wikiliens|date=$(month) $(year)}}', help:''},
	{category:3, display:'Trop long', template:'{{Trop long}}', help:''},
	{category:0, display:'Typographie', template:'{{Typographie|date=$(month) $(year)}}', help:''},
	{category:1, display:'Vérifiabilité', template:'{{Vérifiabilité|date=$(month) $(year)}}', help:''},
	{category:1, display:'Vie privée', template:'{{Vie privée|date=$(month) $(year)}}', help:''},
  ],
  categories_container: null,
  alphabetic_container: null,
  current_display_mode: "categories",

  init: function() {
  },
  launch: function() {
  	if(mw.config.get('wgArticleId') === 0) {
    	mw.notify(C.tag.config['notify-not-a-page'], {title:'C-helper', type:'error'});
    	return;
  	}
  	if(mw.config.get('wgRestrictionEdit') == ["sysop"]) {
    	mw.notify(C.tag.config['notify-protected'], {title:'C-helper', type:'error'});
    	return;
  	}
	if(this.dialog === null) {
		this.build_dialog();
	}
	this.dialog.dialog("open");
  },
  "build_dialog": function() {
    this.dialog = $('<div>', {title:this.config['modal-title']});
    var form = $('<form>');
    this.dialog.append(form);
    //Radio
    $("<div>").text("Trier par ")
               .append($("<input>", {type:"radio",name:"C-tag-display-mode", value:"categories", id:"C-tag-display-mode-categories", class:this.config['c-tag-radio-class'], checked: "checked"}))
               .append($("<label>", {"for":"C-tag-display-mode-categories"}).text("Catégories"))
               .append($("<input>", {type:"radio",name:"C-tag-display-mode", value:"alphabetic", id:"C-tag-display-mode-alphabetic", class:this.config['c-tag-radio-class']}))
               .append($("<label>", {"for":"C-tag-display-mode-alphabetic"}).text("Ordre alphabétique"))
               .appendTo(form);

    //Create sections
    this.alphabetic_container = $("<div>", {id:"C-tag-alphabetic-container"});
    this.categories_container = $("<div>", {id:"C-tag-categories-container"});
    for(var i=0; i<this.categories.length; i++) {
    	this.categories[i].node = $("<div>").append($("<h3>").text(this.categories[i].display)).appendTo(this.categories_container);
   
  }
    for(var i=0; i<this.templates.length; i++) {
		this.templates[i].node = $("<div>");
		this.templates[i].node.append($("<input>", {type:"checkbox", id:"C-tag-"+i, tag_id:i, class:this.config['c-tag-checkbox-class']}));
		this.templates[i].node.append($("<label>", {"for":"C-tag-"+i}).text(this.templates[i].display));
		
		if(this.templates[i].help !== '') {
			this.templates[i].node.append(C.util.construct_help_icon(this.templates[i].help));
		}
		if(this.templates[i].hasOwnProperty('reason')) {
			this.templates[i].node.append($('<span>', {id:'C-tag-reason-'+i, class:this.config['c-tag-reason-class']})
			                      		.hide()
			                      		.append($('<br>'))
			                            .append($('<label>', {"for":'C-tag-reason-input-'+i}).html(this.templates[i].reason))
			                            .append("&nbsp;")
			    						.append($('<input>', {type:'text', id:'C-tag-reason-input-'+i})));
		}
		if(this.templates[i].hasOwnProperty('extra')) {
			this.templates[i].node.append($('<span>', {id:'C-tag-extra-'+i, class:this.config['c-tag-extra-class']})
			                      		.hide()
			                      		.append($('<br>'))
			                            .append($('<label>', {"for":'C-tag-extra-input'+i}).html(this.templates[i].extra))
			                            .append("&nbsp;")
			    						.append($('<input>', {type:'text', id:'C-tag-extra-input'+i})));
		}
		
		this.categories[this.templates[i].category].node.append(this.templates[i].node);
    }
    form.append(this.alphabetic_container);
    form.append(this.categories_container);
    
    this.dialog.dialog({
      autoOpen: false,
      height: 400,
      width: 600,
      modal: true,
      buttons: [
        {
          text: C.tag.config['submit'],
          click: function() {
            C.tag.dialog.dialog("close");
            C.tag.validate();
          },
        },
      ],
    dialogClass: 'c-helper-dialog',
    });
    $('.'+this.config['c-tag-radio-class']).change(function() {
    	C.tag.switch_display_mode($(this).val());
    });
	$('.'+this.config['c-tag-checkbox-class']).change(function() {
		if($(this).is(":checked")) {
			$('#C-tag-reason-'+$(this).attr('tag_id')).show();
			$('#C-tag-extra-'+$(this).attr('tag_id')).show();
		}
		else {
			$('#C-tag-reason-'+$(this).attr('tag_id')).hide();
			$('#C-tag-extra-'+$(this).attr('tag_id')).hide();
		}
	});
  },
  switch_display_mode: function(new_mode) {
  	if(this.current_display_mode != new_mode) {
  		if(new_mode == "categories") {
  			$("#C-tag-categories-container").show();
  			for(var i=0; i<this.templates.length; i++) {
				this.categories[this.templates[i].category].node.append(this.templates[i].node);
			}
			$("#C-tag-alphabetic-container").hide();
  		}
  		else {
			$("#C-tag-alphabetic-container").show();
  			for(var i=0; i<this.templates.length; i++) {
				this.alphabetic_container.append(this.templates[i].node);
			}
  			$("#C-tag-categories-container").hide();
  		}
  		this.current_display_mode = new_mode;
  	}
  },
  validate: function() {
  	var to_prepend = "";
  	var summary_array = [];
  	for(var i=0; i<this.templates.length; i++) {
  		if($('#C-tag-'+i).is(':checked')) {
  			var tmp = this.templates[i].template.replace(/\$\(day\)/g, "{{subst:CURRENTDAY}}")
  			                             .replace(/\$\(month\)/g, "{{subst:CURRENTMONTHNAME}}")
  			                             .replace(/\$\(year\)/g, "{{subst:CURRENTYEAR}}")
  			                             .replace(/\$\(page\)/g, mw.config.get('wgPageName'))
  			                             .replace(/\$\(diff\)/g, mw.config.get('wgRevisionId'))
  			                             .replace(/\$\(user\)/g, mw.config.get('wgUserName'));
  			if($('#C-tag-reason-input-'+i).length > 0) {
  				tmp = tmp.replace(/\$\(reason\)/g, $('#C-tag-reason-input-'+i).val());
  			}
  			if($('#C-tag-extra-input'+i).length > 0)
  				tmp = tmp.replace(/\$\(extra\)/g, $('#C-tag-extra-input'+i).val());
  				
  			to_prepend += tmp+'\n';
  			summary_array.push(this.templates[i].display);
  		}
  	}
  	if(summary_array.length > 0) {
  		var template_links = summary_array.map(function(item) {
  			return this.config['template-link-summary'].replace(/\$1/g, item);
  		}, this);
  		var summary = this.config['add-summary'].replace(/\$1/g, C.util.array_to_text(template_links));
  		C.util.prepend(null, to_prepend, summary, function() {
  			mw.notify(C.tag.config['notify-success'], {title:'C-helper', type:'info'});
	    	C.util.reload();
  		});
  	}
  },
};

C.modules.tag.callback = C.tag;
//</nowiki>
mportScript('Utilisateur:0x010C/script/editlib.js');

var DJvars_CheckPage = "Wikipédia:Patrouille RC/Modifications à relire";
var DJvars_ScriptPage = "Utilisateur:0x010C/script/DrapeauJaune.js";

var DJvars_Texts = {
 "flagsrc"               : "//upload.wikimedia.org/wikipedia/commons/6/69/Flag_icon_-_yellow.svg",
 "flagtitle"             : "Une demande de relecture a été faite pour cette modification",
 "flagalt"               : "Drapeau Jaune",
 "flagheight"            : "20",
 "waitsrc"               : "//upload.wikimedia.org/wikipedia/commons/b/b4/Loading_Animation.gif",
 "waittitle"             : "Wait",
 "waitalt"               : "",
 "notifdone"             : "Demande de seconde relecture envoyée !",
 "notifremoved"          : "Marquage retiré !",
 "notiferror"            : "Une erreur est survenue... Recharger la page pour vérifier si la modification a été effectuée ou non.",
 "notifmissingportals"   : "Demande de seconde relecture envoyée ! (la sous-page de certains portails semble cependant manquante)",
 "notifportalmaymiss"    : "Un de ces portails peut ne pas exister : ",
 "notifalreadyasked"     : "Une demande de seconde relecture a déjà été faite.",
 "notifnotasked"         : "Il n'y a pas de demande de seconde relecture pour cette modification. Elle vient peut-être d'être retirée par un autre contributeur.",
 "resumescript"          : "DJ",
 "resumeadd"             : "[[Special:Diff/$1|$2]] = Marquée comme douteuse ($3)",
 "resumerm"              : "[[Special:Diff/$1|$2]] = Marquée comme relue ($3)",
 "askreviewlinktext"     : "Demander une seconde relecture",
 "askremovelinktext"     : "Retirer le marquage",
 "sidebartext"           : "$1 modification$2 à relire",
 "sidebarlink"           : "/wiki/Wikipédia:Patrouille_RC/Modifications_à_relire"
};

var DJ_maxTimeout = 5;




/*
==========================================
	Affichage si souhaité d'un lien dans la sidebar
==========================================
*/

function showSidebarLink(content) {
	if(content === null) {
		$.get( mw.util.wikiScript( 'api' ), {
			format: 'xml',
			action: 'query',
			titles: DJvars_CheckPage,
			prop: 'revisions',
			rvprop: 'content'
		} ).done( function(r) {
			showSidebarLink($(r).find('rev').text());
		});
	}
	else {
		var nbDiff = content.split('\n').length - 1;
		$("#p-navigation ul").first().append('<li><a href="'+DJvars_Texts['sidebarlink']+'">'+DJvars_Texts['sidebartext'].split('$1').join(nbDiff).split('$2').join(nbDiff > 1 ? 's' : '')+'</a></li>');
	}
}




/*
==========================================
	Initialisation commune à l'ajout et au retrait de diffs à la liste des modifs douteuses
==========================================
*/

/*
	# Fonction executé sur toutes les pages de diff
	Vérifie si la dif est marqué comme douteuse
	-> Si oui, alors cela récupère et affiche le commentaire, et met le lien pour retirer le marquage
	-> Si non, met le lien pour marquer la diff comme douteuse
*/
$(function() {
	if($(".diff").length) {
		$(".diff-ntitle").append('<div id="dj-diff-ntitle6"></div>');
		$.get( mw.util.wikiScript( 'api' ), {
			format: 'xml',
			action: 'query',
			titles: DJvars_CheckPage,
			prop: 'revisions',
			rvprop: 'content'
		} ).done( function(r) {
			var comment = "";
			var wikicode = $(r).find('rev').text();
			if(typeof DJparam_sidebarlink !=='undefined') {
				if(DJparam_sidebarlink)
					showSidebarLink(wikicode);
			}
			var oldid = mw.config.get('wgRevisionId');
			var pattern = new RegExp("\\* ?\\[\\[Sp(é|e)cial:Diff\\/"+oldid+"\\|[^\\[\\]]+\\]\\]");
			if(pattern.test(wikicode)){
				var lines = wikicode.split('\n');
				for(var i=0; i<lines.length;i++) {
					if(pattern.test(lines[i])) {
						comment = lines[i].match("^\\* ?\\[\\[Sp(?:é|e)cial:Diff\\/"+oldid+"\\|[^\\[\\]]+\\]\\](.*)")[1];
						break;
					}
				}
				$("#dj-diff-ntitle6").html('<img alt="'+DJvars_Texts['flagalt']+'" src="'+DJvars_Texts['flagsrc']+'" height="'+DJvars_Texts['flagheight']+'" title="'+DJvars_Texts['flagtitle']+'"/> '+DJ_parselink(comment)+'<br/><span id="DJlink">[<a href="javascript:DJ_rm_show()">'+DJvars_Texts['askremovelinktext']+'</a>]</span>');
			}
			else
				$("#dj-diff-ntitle6").html('<span id="DJlink">[<a href="javascript:DJ_add_show()">'+DJvars_Texts["askreviewlinktext"]+'</a>]</span>');
		});
	}
	else if(typeof DJparam_sidebarlink !=='undefined') {
		if(DJparam_sidebarlink)
			showSidebarLink(null);
	}
});




/*
==========================================
	Fonctions gérant l'ajout de diffs à la liste des modifs douteuses
==========================================
*/

/*
	# Fonction executé lors du clic sur le lien "[Demander une seconde relecture]"
	Affiche à la place du lien une zone de saisie et un bouton, auquel elle ajoute un évènement lors du clic
	Cet évènement récupère, formatte et transmet les informations de diff et de la zone de saisie à la fonction ''DJ_add_check''
*/
function DJ_add_show() {
	$("#dj-diff-ntitle6").html('<input type="text" id="DJinput" class="mw-ui-input" maxlength="255"/><input type="button" value="Flag!" id="DJbutton" class="mw-ui-button mw-ui-progressive" style="background: #ffb50d; border-color: #ffb50d;"/>');
	$("#DJinput").focus();
	$("#DJbutton").click(function() {
		oldid = mw.config.get('wgRevisionId');
		page = mw.config.get('wgTitle');
		comment = $("#DJinput").val().substr(0, 255);
		DJ_add_check(oldid, page, comment);
	});
}

/*
	# Fonction executé après la validation du marquage
	Vérifie si la diff n'a pas été marqué entre temps par quelqu'un d'autre
	-> Si elle n'est pas marqué, alors on la marque en appelant la fonction ''DJ_add_write''
*/
function DJ_add_check(oldid, page, comment) {
	$.get( mw.util.wikiScript( 'api' ), {
		format: 'xml',
		action: 'query',
		titles: DJvars_CheckPage,
		prop: 'revisions',
		rvprop: 'content'
	} ).done( function(r) {
		var wikicode = $(r).find('rev').text();
		var pattern = new RegExp("\\* ?\\[\\[Sp(e|é)cial:Diff\\/"+oldid+"\\|[^\\[\\]]+\\]\\]");
		if(pattern.test(wikicode))
			mw.notify(DJvars_Texts["notifalreadyasked"]);
		else
			DJ_add_write(oldid, page, comment);
	} );
}

/*
	# Executé après validation du marquage, et une fois les vérifications effectués
	Ajoute la diff à la liste des diffs à relire
*/
function DJ_add_write(oldid, page, comment) {
	$("#dj-diff-ntitle6").html('<img alt="'+DJvars_Texts["waitalt"]+'" src="'+DJvars_Texts["waitsrc"]+'" title="'+DJvars_Texts["waittitle"]+'"/>');
	editlib_addBottom(DJvars_CheckPage, "\n* [[Special:Diff/"+oldid+"|"+page+" <small>(oldid="+oldid+")</small>]] : "+comment, "[["+DJvars_ScriptPage+"|"+DJvars_Texts["resumescript"]+"]] : "+DJvars_Texts["resumeadd"].split("$1").join(oldid).split("$2").join(page).split("$3").join(comment));
	DJ_add_isFinished(1, 0, comment);
}

/*
	# Executé une fois la requête pour ajouter la diff à la liste envoyé
	Attend et vérifie que l'ajout c'est bien passé (ou non)
*/
function DJ_add_isFinished(nbToWait, nbLoop, comment) {
	if(editcount == nbToWait) {
		mw.notify(DJvars_Texts["notifdone"]);
		$("#dj-diff-ntitle6").html('<img alt="'+DJvars_Texts["flagalt"]+'" src="'+DJvars_Texts["flagsrc"]+'" height="'+DJvars_Texts["flagheight"]+'" title="'+DJvars_Texts["flagtitle"]+'"/> '+DJ_parselink(comment));
	}
	else if(nbLoop < DJ_maxTimeout)
		setTimeout(function(){DJ_add_isFinished(nbToWait, nbLoop+1, comment)},1000);
	else {
		$("#dj-diff-ntitle6").html('');
		mw.notify(DJvars_Texts["notiferror"]);
	}
}




/*
==========================================
	Fonctions gérant le retrait de diffs à la liste des modifs douteuses
==========================================
*/

/*
	# Fonction executé lors du clic sur le lien "[Retirer le marquage]"
	Affiche à la place du lien une zone de saisie et un bouton, auquel elle ajoute un évènement lors du clic
	Cet évènement récupère, formatte et transmet les informations de diff et de la zone de saisie à la fonction ''DJ_rm_check''
*/
function DJ_rm_show() {
	$("#DJlink").remove();
	$("#dj-diff-ntitle6").append('<input type="text" id="DJinput" class="mw-ui-input" maxlength="255"/><input type="button" value="Unflag!" id="DJbutton" class="mw-ui-button mw-ui-progressive" style="background: #ffb50d; border-color: #ffb50d;"/>');
	$("#DJinput").focus();
	$("#DJbutton").click(function() {
		oldid = mw.config.get('wgRevisionId');
		page = mw.config.get('wgTitle');
		comment = $("#DJinput").val().substr(0, 255);
		DJ_rm_check(oldid, page, comment);
	});
}

/*
	# Fonction executé après avoir récupéré le commentaire de retrait
	Vérifie si la diff n'a pas été retiré entre temps par quelqu'un d'autre
	-> Si ce n'est pas le cas, alors on retire la marque en appelant la fonction ''DJ_rm_takeoff''
*/
function DJ_rm_check(oldid, page, comment) {
	$.get( mw.util.wikiScript( 'api' ), {
		format: 'xml',
		action: 'query',
		titles: DJvars_CheckPage,
		prop: 'revisions',
		rvprop: 'content'
	} ).done( function(r) {
		var wikicode = $(r).find('rev').text();
		var pattern = new RegExp("\\* ?\\[\\[Sp(e|é)cial:Diff\\/"+oldid+"\\|[^\\[\\]]+\\]\\]");
		if(!pattern.test(wikicode))
			mw.notify(DJvars_Texts["notifnotasked"]);
		else
			DJ_rm_takeoff(oldid, page, wikicode, comment);
	} );
}

/*
	# Executé après clic sur retirer le marquage, et une fois les vérifications effectués
	Retire la diff à la liste des diffs à relire
*/
function DJ_rm_takeoff(oldid, page, wikicode, comment) {
	$("#dj-diff-ntitle6").html('<img id="DJwait" alt="'+DJvars_Texts["waitalt"]+'" src="'+DJvars_Texts["waitsrc"]+'" title="'+DJvars_Texts["waittitle"]+'"/>');
	var pattern = new RegExp("\\* ?\\[\\[Sp(e|é)cial:Diff\\/"+oldid+"\\|[^\\[\\]]+\\]\\][^\n]*\n?");
	wikicode = wikicode.replace(pattern, "");
	editlib_replace(DJvars_CheckPage, wikicode, "[["+DJvars_ScriptPage+"|"+DJvars_Texts["resumescript"]+"]] : "+DJvars_Texts["resumerm"].split("$1").join(oldid).split("$2").join(page).split("$3").join(comment));
	DJ_rm_isFinished(1, 0);
}

/*
	# Executé une fois la requête pour retirer la diff de la liste envoyé
	Attend et vérifie que le retrait c'est bien passé (ou non)
*/
function DJ_rm_isFinished(nbToWait, nbLoop) {
	if(editcount == nbToWait) {
		mw.notify(DJvars_Texts["notifremoved"]);
		$("#dj-diff-ntitle6").html('');
	}
	else if(nbLoop < DJ_maxTimeout)
		setTimeout(function(){DJ_rm_isFinished(nbToWait, nbLoop+1)},1000);
	else {
		$("#dj-diff-ntitle6").html('');
		mw.notify(DJvars_Texts["notiferror"]);
	}
}




/*
==========================================
	Fonctions annexes
==========================================
*/

/*
	Converti les liens internes écrit avec la syntaxe wikicode contenu dans "chaine" en HTML
*/
function DJ_parselink(chaine) {
	var reg = new RegExp("\\[\\[([^\\[\\]]+)\\|([^\\[\\]]+)\\]\\]");
	do {
		precedent = chaine;
		chaine = chaine.replace(reg, '<a href="'+mw.config.get('wgServer')+mw.config.get('wgArticlePath')+'">$2</a>');
	} while(chaine != precedent);
	reg = new RegExp("\\[\\[([^\\[\\]]+)\\]\\]");
	do {
		precedent = chaine;
		chaine = chaine.replace(reg, '<a href="'+mw.config.get('wgServer')+mw.config.get('wgArticlePath')+'">$1</a>');
	} while(chaine != precedent);
	return chaine;
}
/*
	Echape les meta-caractère d'une chaine pour que cela ne pose pas de problème dans une regex
*/
RegExp.escape = function(s) {
    return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
};
/*
 * BlockMessage
 *
 * Permet d'ajouter un modèle notifiant le blocage d'un utilisateur en un clic,
 * une fois le blocage réussi.
 *
 * Auteur : [[User:0x010C]]
 * {{Projet:JavaScript/Script|BlockMessage}}
 */

// Customisation
var templatesList = {
	finite: [
		{
			label: "Bloqué",
			data: '{ "template": "Bloqué|$1|$2" }'
		}, {
			label: "Bloqué sans avertissement",
			data: '{ "template": "Bloqué sans avertissement|$1|$2" }'
		}, {
			label: "Insultes",
			data: '{ "template": "Insultes|$1|$2" }'
		}, {
			label: "IP partagée bloquée",
			data: '{ "template": "IP partagée bloquée|$1|$2" }'
		}, {
			label: "Vandale scolaire bloqué",
			data: '{ "template": "Vandale scolaire bloqué" }',
			'autoselect-time': '15 july 2018'
		}, {
			label: "Proxy",
			data: '{ "template": "Proxy", "default-subst": false }',
			'autoselect-reason': '[[Wikipédia:Proxy ouvert|Proxy ouvert]]'
		}, {
			label: "IP bloquée pour 3 jours",
			data: '{ "template": "Adresse IP bloquée pour trois jours|$3|$1|$2" }'
		},
	],
	infinite: [
		{
			label: "Compte bloqué indéfiniment",
			data: '{ "template": "Compte bloqué indéfiniment|$3", "default-clean": true }'
		}, {
			label: "Vandale banni",
			data: '{ "template": "Vandale banni", "default-clean": true }'
		}, {
			label: "Vandale banni sans avertissement",
			data: '{ "template": "Vandale banni sans avertissement", "default-clean": true }'
		}, {
			label: "Bot banni",
			data: '{ "template": "Bot banni" }'
		},
	]
};

// I18n
var blockMessageMessages = {
	'en': {
		'blockmessage-default-header': 'Block user',
		'blockmessage-success-header': 'Block succeeded',
		'blockmessage-form-legend': 'Notify the user of the block',
		'blockmessage-username-label': 'Username',
		'blockmessage-template-label': 'Template',
		'blockmessage-expiry-label': 'Duration',
		'blockmessage-subst-label': 'Substitute the template',
		'blockmessage-clean-label': 'Clear the talk page before putting the template',
		'blockmessage-extra-label': 'Add a custom message under the template',
		'blockmessage-extraTextareaLabel': '(be careful, the signature is no longer automatically added)',
		'blockmessage-submit-label': 'Notify',
		'blockmessage-message-summary': 'Block',
		'blockmessage-message-tags': '0xBlockMessage',
		'blockmessage-section-title': 'Block',
		'blockmessage-successnotif': 'The message has been correctly added to the talk page.',
		'blockmessage-time-label': 'Duration',
		'blockmessage-unit-label': 'Unit',
		'blockmessage-hour': 'hour',
		'blockmessage-hours': 'hours',
		'blockmessage-day': 'day',
		'blockmessage-days': 'days',
		'blockmessage-week': 'week',
		'blockmessage-weeks': 'weeks',
		'blockmessage-month': 'month',
		'blockmessage-months': 'months',
		'blockmessage-year': 'year',
		'blockmessage-years': 'years',
	},
	'fr': {
		'blockmessage-default-header' : 'Bloquer l’utilisateur',
		'blockmessage-success-header' : 'Blocage réussi',
		'blockmessage-form-legend': 'Avertir du blocage',
		'blockmessage-username-label': 'Utilisateur',
		'blockmessage-template-label': 'Modèle',
		'blockmessage-expiry-label': 'Expiration',
		'blockmessage-subst-label': 'Substituer le modèle',
		'blockmessage-clean-label': 'Effacer la PdD avant de mettre le modèle',
		'blockmessage-extra-label': 'Rajouter un message sous le modèle',
		'blockmessage-extraTextareaLabel': '(attention, la signature n\'est plus apposée automatiquement)',
		'blockmessage-submit-label': 'Avertir',
		'blockmessage-message-summary': 'Blocage',
		'blockmessage-message-tags': '0xBlockMessage',
		'blockmessage-section-title': 'Blocage',
		'blockmessage-successnotif': 'La pose du message a réussi',
		'blockmessage-time-label': 'Durée',
		'blockmessage-unit-label': 'Unité',
		'blockmessage-hour': 'heure',
		'blockmessage-hours': 'heures',
		'blockmessage-day': 'jour',
		'blockmessage-days': 'jours',
		'blockmessage-week': 'semaine',
		'blockmessage-weeks': 'semaines',
		'blockmessage-month': 'mois',
		'blockmessage-months': 'mois',
		'blockmessage-year': 'année',
		'blockmessage-years': 'années',
	}
};

mw.messages.set( blockMessageMessages[ 'en' ] );
var lang = mw.config.get( 'wgUserLanguage' );
if ( lang !== 'en' && lang in blockMessageMessages ) {
	mw.messages.set( blockMessageMessages[ lang ] );
}

var blockMessageUnits = [
	{ en: 'hour', data: mw.msg( 'blockmessage-hour' ), label: mw.msg( 'blockmessage-hour' ) },
	{ en: 'hours', data: mw.msg( 'blockmessage-hours' ), label: mw.msg( 'blockmessage-hours' ) },
	{ en: 'day', data: mw.msg( 'blockmessage-day' ), label: mw.msg( 'blockmessage-day' ) },
	{ en: 'days', data: mw.msg( 'blockmessage-days' ), label: mw.msg( 'blockmessage-days' ) },
	{ en: 'week', data: mw.msg( 'blockmessage-week' ), label: mw.msg( 'blockmessage-week' ) },
	{ en: 'weeks', data: mw.msg( 'blockmessage-weeks' ), label: mw.msg( 'blockmessage-weeks' ) },
	{ en: 'month', data: mw.msg( 'blockmessage-month' ), label: mw.msg( 'blockmessage-month' ) },
	{ en: 'months', data: mw.msg( 'blockmessage-months' ), label: mw.msg( 'blockmessage-months' ) },
	{ en: 'year', data: mw.msg( 'blockmessage-year' ), label: mw.msg( 'blockmessage-year' ) },
	{ en: 'years', data: mw.msg( 'blockmessage-years' ), label: mw.msg( 'blockmessage-years' ) }
];



$( function ( $ ) {
	// Load the script only on the Block special page
	if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special' && mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Block' ) {
		mw.loader.using( [ 'mediawiki.cookie', 'mediawiki.util', 'oojs-ui' ], function() {
		
			// On the Block page
			if ( $( '#firstHeading' ).html() === mw.msg( 'blockmessage-default-header' ) ) {
				$( 'form.mw-htmlform' ).submit( function( event ) {
					if ( $( '#mw-input-wpExpiry select' ).val() === 'other' ) {
						mw.cookie.set( 'blockmessage-expiry', $( 'input[name="wpExpiry-other"]' ).val() );
					}
					else {
						mw.cookie.set( 'blockmessage-expiry', $( '#mw-input-wpExpiry select' ).val() );
					}
					if ( $( '#mw-input-wpReason-select select' ).val() === 'other' ) {
						mw.cookie.set( 'blockmessage-reason', $( 'input[name="wpReason-other"]' ).val() );
					}
					else if ( $( 'input[name="wpReason-other"]' ).val() !== '' ) {
						mw.cookie.set( 'blockmessage-reason', $( '#mw-input-wpReason-select select' ).val() + ' : ' + $( 'input[name="wpReason-other"]' ).val() );
					}
					else {
						mw.cookie.set( 'blockmessage-reason', $( '#mw-input-wpReason-select select' ).val() );
					}
				} );
			}
			
			// When the user has successfully blocked someone.
			// wgRelevantUserName may be null for IP ranges.
			else if ( $( '#firstHeading' ).html() === mw.msg( 'blockmessage-success-header' ) &&
			          mw.cookie.get( 'blockmessage-expiry' ) !== null &&
			          mw.config.get( 'wgRelevantUserName' ) !== null ) {
				window.blockMessage = new BlockMessage( mw.config.get( 'wgRelevantUserName' ), mw.cookie.get( 'blockmessage-reason' ), mw.cookie.get( 'blockmessage-expiry' ) );
			}
		
		} );
	}
});

/**
 * @class BlockMessage
 * @constructor
 * @private
 * @param {String} targetUser
 * @param {String} reason
 * @param {String} duration
 */
var BlockMessage = function(targetUser, reason, duration) {
	this.targetUser = targetUser;
	this.reason = reason;
	this.duration = duration;
	
	this.usernameInput;
	this.templateDropdownInput;
	this.expiryInput;
	this.substCheckboxInput;
	this.cleanCheckboxInput;
	this.extraCheckboxInput;
	this.extraTextarea;
	this.submitInput;
	
	this.expiryField;
	this.extraTextareaField;
	this.form;
	
	
	// Initialize the form
	this.createWidgets();
	this.addEventHandlers();
	this.initializeWidgets();
	
	// Add the form to the page once all is ready
	$( '#mw-content-text' ).append( this.form.$element );
};

/**
 * Create all the OOjs-ui widgets and organise them into a field layout
 */
BlockMessage.prototype.createWidgets = function() {
	this.usernameInput = new OO.ui.TextInputWidget( {
		name: 'username',
		disabled: 'disabled'
	} );
	this.templateDropdownInput = new OO.ui.DropdownInputWidget();
	this.expiryInput = new mw.widgets.SelectWithInputWidget( {
		or: false,
		dropdowninput: {
			label: mw.msg( 'blockmessage-unit-label' ),
			options: blockMessageUnits,
		},
		textinput: {
			placeholder: mw.msg( 'blockmessage-time-label' )
		}
	} );
	this.substCheckboxInput = new OO.ui.CheckboxInputWidget( {
		name: '',
		selected: true
	} );
	this.cleanCheckboxInput = new OO.ui.CheckboxInputWidget( {
		name: '',
		selected: false
	} );
	this.extraCheckboxInput = new OO.ui.CheckboxInputWidget( {
		name: '',
		selected: false
	} );
	this.extraTextarea = new OO.ui.MultilineTextInputWidget( {
		rows: 10,
		autosize: true,
	} );
	this.submitInput = new OO.ui.ButtonInputWidget( {
		type: 'submit',
		label: mw.msg( 'blockmessage-submit-label' ),
		flags: [ 'primary', 'destructive' ],
	} );
	
	this.expiryField = new OO.ui.FieldLayout( this.expiryInput, {
		align: 'top',
		label: mw.msg( 'blockmessage-expiry-label' )
	} );
	this.extraTextareaField = new OO.ui.FieldLayout( this.extraTextarea, {
		align: 'top',
		label: $( '<small>' ).text( mw.msg( 'blockmessage-extraTextareaLabel' ) )
	} );
	
	this.form = new OO.ui.FieldsetLayout( {
		id: 'demo-section-formLayout',
		label: mw.msg( 'blockmessage-form-legend' ),
		items: [
			new OO.ui.FieldLayout( this.usernameInput, {
				align: 'top',
				label: mw.msg( 'blockmessage-username-label' )
			} ),
			new OO.ui.FieldLayout( this.templateDropdownInput, {
				align: 'top',
				label: mw.msg( 'blockmessage-template-label' )
			} ),
			this.expiryField,
			new OO.ui.FieldLayout( this.substCheckboxInput, {
				align: 'inline',
				label: mw.msg( 'blockmessage-subst-label' )
			} ),
			new OO.ui.FieldLayout( this.cleanCheckboxInput, {
				align: 'inline',
				label: mw.msg( 'blockmessage-clean-label' )
			} ),
			new OO.ui.FieldLayout( this.extraCheckboxInput, {
				align: 'inline',
				label: mw.msg( 'blockmessage-extra-label' )
			} ),
			this.extraTextareaField,
			new OO.ui.FieldLayout( this.submitInput )
		]
	} );
};

/**
 * Add some handlers to the widgets to manage the post-submit stage
 * and to enhance the user experience
 */
BlockMessage.prototype.addEventHandlers = function() {
	var self = this;
	
	// Launch the postMessage method when the user submit the form
	this.submitInput.on( 'click', function() {
		self.submitInput.setDisabled(true);
		self.postMessage();
	} );
	
	// Auto (un)check the checkboxes when the user change the selected template
	this.templateDropdownInput.on( 'change', function (value) {
		value = JSON.parse(value);
		if ( value.hasOwnProperty( 'default-subst' ) ) {
			self.substCheckboxInput.setSelected( value[ 'default-subst' ] );
		}
		if ( value.hasOwnProperty( 'default-clean' ) ) {
			self.cleanCheckboxInput.setSelected( value[ 'default-clean' ] );
		}
	} );
	
	// Display or hide the extra textarea when the user (un)check the extra checkbox
	this.extraCheckboxInput.on( 'change', function ( checked ) {
		self.extraTextareaField.toggle( checked );
	} );
};

/**
 * Populate and adapt parameters from the widgets
 */
BlockMessage.prototype.initializeWidgets = function() {
	var templates;
	if ( this.duration === 'infinite' ) {
		// Hide the expiry field when the duration is infinite (it's irrelevant)
		this.expiryField.toggle( false );
		templates = templatesList.infinite;
	}
	else {
		templates = templatesList.finite;
		
		// Parse the expiry parameter and populate the expiration fields
		if ( this.duration !== null ) {
			var splitedDuration = this.duration.split( ' ' );
			if ( splitedDuration.length === 2 && !isNaN( splitedDuration[ 0 ] ) ) {
				for ( var i=0; i<blockMessageUnits.length; i++) {
					if ( splitedDuration[ 1 ] === blockMessageUnits[ i ].en ) {
						this.expiryInput.dropdowninput.setValue( blockMessageUnits[ i ].data );
						this.expiryInput.textinput.setValue( splitedDuration[ 0 ] );
						this.expiryField.toggle( false );
						break;
					}
				}
			}
		}
	}
	
	// Populate the template dropdown with the appropriate templates names
	this.templateDropdownInput.setOptions( templates );
	
	// Autoselect a template depending of the reasons or the duration
	for ( var i=0; i<templates.length; i++ ) {
		if ( 'autoselect-reason' in templates[ i ] ) {
			if ( templates[ i ][ 'autoselect-reason' ] === this.reason ) {
				this.templateDropdownInput.setValue( templates[ i ].data );
				break;
			}
		}
		if ( 'autoselect-duration' in templates[ i ] ) {
			if ( templates[ i ][ 'autoselect-duration' ] === this.duration ) {
				this.templateDropdownInput.setValue( templates[ i ].data );
				break;
			}
		}
	}
	
	// Fill the username field with the username of the blocked user
	this.usernameInput.setValue( this.targetUser );
	
	// By default, hide the extra textarea
	this.extraTextareaField.toggle( false );
};

/**
 * Use the datas set in the form to prepare and post a blocking notification
 * to the target user's talk page.
 * Called when the user click on the submit button.
 */
BlockMessage.prototype.postMessage = function() {
	var subst = '';
	if ( this.substCheckboxInput.isSelected() ) {
		subst = 'subst:';
	}
	var extra = ' ~~' + '~~';
	if ( this.extraCheckboxInput.isSelected() ) {
		extra = '\n\n' + this.extraTextarea.getValue();
	}
	
  	// Prepare the template
    var template = JSON.parse( this.templateDropdownInput.getValue() ).template;
    template = template.replace( '$1', this.expiryInput.textinput.getValue() );
    template = template.replace( '$2', this.expiryInput.dropdowninput.getValue() );
    template = template.replace( '$3', this.reason );
    
    // Prepare the payload which will be send to the API
    var data = {
		action: 'edit',
		title: 'User talk:' + this.targetUser,
		text: '{{' + subst + template + '}}' + extra,
		summary: mw.msg( 'blockmessage-message-summary' ),
		tags: mw.msg( 'blockmessage-message-tags' ),
    };
    if ( ! this.cleanCheckboxInput.isSelected() ) {
		data.section = "new";
		data.sectiontitle = mw.msg( 'blockmessage-section-title' );
    }
    
    // Send the payload
	new mw.Api().postWithToken( 'csrf', data ).then( this.onMessagePosted.bind( this ) );
};

BlockMessage.prototype.onMessagePosted = function ( data ) {
	// Display a visual information to the admin to confirm that the talk page has been edited
	mw.notify( mw.msg( 'blockmessage-successnotif' ) );
	
	// Clean the cookies
	mw.cookie.set( 'blockmessage-expiry', null );
	mw.cookie.set( 'blockmessage-reason', null );
	
	// Redirect the admin to the target's talk page after a short delay
	var self = this;
	setTimeout( function() {
		document.location.href = mw.util.getUrl( 'User talk:' + self.targetUser + '#footer' );
	}, 750 );
};
PaStec