Utilisateur:Matteo1234321/common.js

Aller à la navigation Aller à la recherche

Note : après avoir enregistré tes préférences, tu devras forcer le rechargement complet du cache de ton navigateur pour voir les changements. Mozilla Firefox / Safari : maintiens la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou presse Maj-Ctrl-R (Maj-Cmd-R sur Apple Mac) ; Internet Explorer / Opera : maintiens la touche Ctrl en cliquant sur le bouton Actualiser ou presse Ctrl-F5.

mw.loader.load('https://fr.vikidia.org/w/index.php?title=Utilisateur:Matteo1234321/SwitchSkins.js&action=raw&ctype=text/javascript');
mw.loader.load('https://fr.vikidia.org/w/index.php?title=Utilisateur:Bulest85/blocage1.js&action=raw&ctype=text/javascript');
mw.loader.load('https://fr.vikidia.org/w/index.php?title=Utilisateur:Matteo1234321/AutoRefreshRC.js&action=raw&ctype=text/javascript');

//Suppression des liens des balises Modification par mobile et Éditeur Visuel (normal et basculé), sur lesquels on clique toujours sans faire exprès sur mobile {{mdr}}
$('.mw-tag-marker-mobile_edit a').removeAttr('href').css('color', '#222');
$('.mw-tag-marker-visualeditor a').removeAttr('href').css('color', '#222');
$('.mw-tag-marker-visualeditor-switched a').removeAttr('href').css('color', '#222');
//Suppression du lien vers le coin des relecteurs
$('#n-Coin-des-relecteurs').remove();

//Afficher un bouton qui ajoute <code>?/&uselang=qqx</code> sur les pages, pour voir les messages système, ainsi qu'un bouton pour accéder au journal des relectures depuis les modifications récentes
var url = location.href;
var nurl, $paragraph;
if (~url.indexOf('?uselang=qqx')) {
	nurl = url.replace('?uselang=qqx', '');
} else if (~url.indexOf('&uselang=qqx')) {
	nurl = url.replace('&uselang=qqx', '');
} else if (~url.indexOf('?')) {
	nurl = url.padEnd(url.length + 12, '&uselang=qqx');
} else {
	nurl = url.padEnd(url.length + 12, '?uselang=qqx');
}
if (mw.config.get('wgCanonicalNamespace') == 'Special' || ~url.indexOf('action=') || ~url.indexOf('Fichier')) {
	$paragraph = $('#top');
	$paragraph.append('<input type="button" id="qqxAdder" onclick="location.href = nurl" value="Messages système" />');
}
if (location.href.match(/^(?:https:\/\/)?fr\.vikidia\.org\/w(?:iki)?\/(?:index\.php\?title=)?Sp(?:%C3%A9|é)cial:Modifications_r(?:%C3%A9|é)centes/)) {
	$paragraph.append('-');
    $paragraph.append('<input type="button" id="patrolLogBtn" onclick="location.href = \'https://fr.vikidia.org/wiki/Spécial:Journal?type=patrol&user=&page=&year=&month=-1&tagfilter=&hide_thanks_log=1&hide_patrol_log=1&hide_tag_log=1\'" value="Journal des relectures" />');
}
//Stylistique #top
var brElement = document.createElement("br");
var topId = document.getElementById("top");
topId.appendChild(brElement);
topId.appendChild(brElement);

/* //Config du gadget LastContrib
window.lastContribNiveau1 = 180;
window.lastContribNiveau2 = 600;
window.lastContribNiveau3 = 3600; */

//Ajoute des liens utiles personnalisables (code de Rififi sous licence CC0)
mw.loader.using ( "mediawiki.util", (function(){ //Fonction pour afficher les liens
	window.MyTools = {};
	window.MyTools.Purge = function(pageName) {
		var Api = new mw.Api();
		Api.post({
			titles: pageName,
			format: "json",
			action: "purge"
		}).then(function(){
			location.reload();
		});
	};

	var ArticleFullPath = "https://fr.vikidia.org/wiki/"; //Raccourci pour les liens
	var ArticleFullPath2 = "https://fr.vikidia.org/w/index.php?"; //Idem
	function AddLink(href, text, where){ //Fonction pour indiquer où les placer
		var pos = ["p-Navigation"/* Sidebar : en-haut (section "Navigation") */, "p-Contribuer"/* Sidebar : section "Contribuer" */, "p-personal"/* En-haut, à côté ou en-dessous de "Déconnexion" */, "p-tb" /* Sidebar : Section "Outils" */, "p-cactions" /* Liste "Plus" en-haut des pages */, "p-views" /* Onglets */];
		mw.util.addPortletLink(pos[where], href, text);
	}

AddLink(ArticleFullPath + 'Vikidia:Demandes_aux_administrateurs', 'Demandes aux admins', 0); //Le 0 signifie "section "Navigation"".
AddLink(ArticleFullPath + 'Vikidia:Demandes_aux_bureaucrates', 'Demandes aux bubus', 0);
AddLink(ArticleFullPath + 'Vikidia:Demandes_aux_vérificateurs d\'utilisateurs', 'Demandes aux CU', 0);
AddLink(ArticleFullPath + 'Vikidia:Bulletin_des_patrouilleurs', 'Bulletin des patrols', 0);
AddLink(ArticleFullPath + 'Vikidia:Bulletin_des_administrateurs', 'Bulletin des admins', 0);
AddLink(ArticleFullPath + 'Vikidia:Bavardages', 'Bavardages', 1); //Le 1 signifie "section "Contribuer"".
AddLink(ArticleFullPath + 'Modèle:Messages_anti-vandales', 'Messages anti-vandales', 1);
AddLink(ArticleFullPath + 'Utilisateur:Matteo1234321/Bac_à_sable', 'Mon bac à sable', 1);
AddLink(ArticleFullPath + 'Vikidia:Bac_à_sable', 'Bac à sable VD', 1);
AddLink(ArticleFullPath + 'Utilisateur:Matteo1234321/common.js', 'Common.js', 1);
AddLink('https://www.mediawiki.org/wiki/Help:Magic_words', 'Mots magiques MW', 2); //Le 2 signifie "Au-dessus des pages".
AddLink('https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions', 'Fonctions d\'analyse MW', 2);
AddLink('https://www.mediawiki.org/wiki/ResourceLoader/Core_modules', 'Core modules MW', 2);
AddLink('http://wikipedia.ramselehof.de/wikiblame.php?user_lang=fr&lang=fr&project=vikidia&tld=org&article=&needle=&skipversions=0&ignorefirst=0&limit=500&offtag=26&offmon=5&offjahr=2022&searchmethod=int&order=desc&user=', 'WikiBlame', 2);
//AddLink(ArticleFullPath + 'Utilisateur:Matteo1234321/Grille d\'évaluation du VikiConcours avril 2022', 'Grille VKCC', 2);
AddLink(ArticleFullPath + 'Spécial:Messages_système', 'Messages système', 3); //Le 3 signifie "section "Outils"".
AddLink(ArticleFullPath + 'Spécial:ApiSandbox', 'Bac à sable de l\'API', 3);
   if (mw.config.get('wgCanonicalNamespace') != 'Special') {
AddLink(ArticleFullPath2 + 'action=edit&preload=Vikidia%3ASuper+article%2FModèle+élection&editintro=Vikidia%3ASuper+article%2FIntro+élection&title=Vikidia%3ASuper+article%2FÉlection%2F' + mw.util.wikiUrlencode ( mw.config.get('wgPageName') ) + '&create=Créer+la+page+de+vote%C2%A0%21', 'SA', 4); //Le 4 signifie "Dans la liste déroulante en-haut des pages".
AddLink(ArticleFullPath2 + 'action=edit&preload=Modèle:Vote_proposition_de_suppression&title=Vikidia:Pages_à_supprimer/' + mw.util.wikiUrlencode ( mw.config.get('wgPageName') ) + '&create=Créer+la+page+de+vote%C2%A0%21', 'PàS', 4);
   }
})());

//Auto-sauvegarde en cas de conflit de modifications sur une même page.
//Code de [[user:Scratcheur-2020send]] sous licence CC-BY-SA 3.0

if (document.getElementById('mw-twocolconflict-changes-header')){
	x = document.getElementsByClassName('oo-ui-inputWidget-input')[0] ;
	if (x.value == your){
		x.click() ;
	}
	x = document.getElementsByClassName('oo-ui-buttonElement-button')[0] ;
	if (x.innerHTML.includes('OK')){
		x.click() ;
	}
	x =  document.getElementById('wpSummary').value ;
	document.getElementById('wpSummary').value = [x,' (conflit de modification)'].join() ;
	document.getElementById('wpSave').click() ;
}


	window.ResumeDeluxe_liens = [
			[ 'Créa stub', 'Créa ébauche' ],
	        [ 'Créa en cours', 'Créa en travaux' ],
			[ 'Ortho', 'Orthographe' ],
			[ 'Typo', 'Typographie' ],
			'Faute de frappe',
			[ 'Erreur de c-c', 'Erreur de copié-collé' ],
			[ 'Vikif', 'Vikification' ],
	        [ 'Mef', 'Mise en forme' ],
	        [ 'Mep', 'Mise en page' ],
	        [ 'WKCD aéré', 'Aération du wikicode' ],
	        [ 'Exist', '{{Existence}}' ],
	        [ 'Portail', 'Ajout de portail(s)' ],
	        [ 'Categ', 'Ajout de catégorie(s)' ],
			'Relecture',
	        'Réorganisation',
	        [ '////////', '' ],
			'Test',
	        [ 'Oups', 'Oups...' ],
	        [ 'Grrr', '[[Ours|Grrr...]]' ],
	        [ '////////', '' ],
	        '+',
	        '+ 1',
	        '+ 2',
	        '+ 3',
	        [ '////////', '' ],
	        [ 'MàJ', 'Mise à jour' ],
	        [ 'Bandeau', 'Mise à jour du bandeau de maintenance' ],
	        'Maintenance',
	        [ 'IW inexist', 'Interwiki inexistant' ],
	        [ 'Img inexist', 'Image inexistante' ],
	        [ '////////', '' ],
	        [ 'Mieux', 'Amélioration' ],
            [ 'Harmonie', 'Harmonisation' ],
	        'Image',
	        'Liens',
	        'Références',
	        'Infobox',
	        [ '////////', '' ],
	        'Réponse',
	        [ 'Indent', 'Indentation' ],
	        [ '////////', '' ],
	        'Retouche de la modification précédente',
            [ 'BVN', 'Bienvenue !' ],
            [ 'BDAY', 'Joyeux anniversaire !'],
	        [ 'MW pages', 'MediaWiki : Traduction, correction, relecture, retouche ou tutoiement.' ]
  	        ];


//Smart patrol (code de Vivi-1 sous licence CC-BY-SA 3.0)

/*
* This script adds a tab which allows a mass patrolling on the current page. Because it was pointless to mark as patrolled 10 intermediate versions when we can read the difference between the first and the last
*/

var totalRevisions;
var treatedRevisions = 0;

if (mw.config.get('wgNamespaceNumber') >= 0) {
  mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'mediawiki.notify', 'oojs-ui' ], function() {
    mw.util.addPortletLink( 'p-views', 'javascript:markAllAsPatrolled()', 'Smart patrol', 'Smart patrol' );
  } );
}

function markAllAsPatrolled() {
  new OO.ui.confirm('Veux-tu marquer toutes les révisions de cette page comme relues ?').then( function( response ) {
    if ( response === true ) {
        getRevisionsList();
    }
  } );
}

function getRevisionsList() {
  var api = new mw.Api();
  api.get( {
	'action': 'query',
	'format': 'json',
	'prop': 'revisions',
	'titles': mw.config.get( 'wgPageName' ),
	'formatversion': '2',
	'rvprop': 'ids|user',
	'rvlimit': 'max'
  } ).then( function ( data ) {
    var revisions = data.query.pages[ 0 ].revisions;
    console.table(data); 
    //var user = revisions[ 0 ].user;
    totalRevisions = revisions.length;
    revisions.forEach( function ( revision ) {
      treatedRevisions++;
      //if ( user === revision.user ) {
        markRevAsPatrolled( revision.revid );
      //}
    } );

  } ).fail( function ( error ) {
      mw.notification.notify( 'Something went wrong: ' + error, { title: 'Smart Patrol', type: 'error' } );
  } );
}

function markRevAsPatrolled( revid ) {
  var api = new mw.Api();
  api.postWithToken( 'patrol', {
	'action': 'patrol',
	'revid': revid

  } ).then( function ( info ) {
    console.log( 'Success for ' + revid, { title: 'Smart Patrol', type: 'info' } );
    if ( totalRevisions == treatedRevisions ) { window.location.reload(); }

  } ).fail( function ( error ) {
    console.log( 'Something went wrong: ' + error, { title: 'Smart Patrol', type: 'error' } );
  } );
}

mw.loader.load('/w/index.php?title=Utilisateur:Matteo1234321/sandbox.js&action=raw&ctype=text/javascript');

/* ***************************************************************************************************************

Code source de Dr Brains de Wikipédia

Fonction : Renommage/vidage de catégorie

* Ajoute un onglet "renommer" en haut d'une page de catégorie.

* Détail du fonctionnement :
   1. modification/retrait¹ automatique de lien catégorie dans les pages et les sous-catégories d'une catégorie;
   2. si nécessaire² : copie du contenu de l'ancienne catégorie dans la nouvelle + crédit des auteurs en page de discussion;
   3. si nécessaire² : suppression de l'ancienne catégorie³;

 ¹ basé sur la partie "édition" du gadget [[MediaWiki:Gadget-HotCats.js]], plusieurs pop-up permettent de définir les paramètres.
 ² après une pop-up de confirmation
 ³ si utilisateur sysop uniquement

* Documentation complète : [[Projet:JavaScript/Notices/RenommageCategorie]]

* Licence : Domaine public

{{Catégorisation JS|RenommageCategorie}}
******************************************************************************************************************* */
//<source lang=javascript><pre><nowiki>

////////////////////////////////////////////// TEXTES GLOBAUX ///////////////////////////

// Libellé de l'onglet
window.RenommageCategorie_Text_Move = 'Renommer';

// Pop-up paramètres
window.RenommageCategorie_Text_PopRemoveCat = 'Catégorie à supprimer';
window.RenommageCategorie_Text_PopAddCat = 'Catégorie à ajouter';
window.RenommageCategorie_Text_PopConfirm = 'Enregistrer sans confirmation manuelle ?';
window.RenommageCategorie_Text_PopWatch = 'Suivre les pages modifiées ?';
window.RenommageCategorie_Text_PopButtonOKText = 'Valider';
window.RenommageCategorie_Text_PopButtonOKTitle = 'Lancer les modifications';
window.RenommageCategorie_Text_PopButtonCancelText = 'Annuler';
window.RenommageCategorie_Text_PopButtonCancelTitle = 'Annuler';
window.RenommageCategorie_Text_PopMoveOnlyCat = 'Renommer uniquement la catégorie';

// Pop-up de confirmation
window.RenommageCategorie_Text_Modif = "Vous vous apprêtez à modifier $1 pages.\n\n"
                                  + "Continuer  ?\n";                                  // Confirmation édition (<50 pages)
window.RenommageCategorie_Text_GrosseModif = "Vous vous apprêtez à modifier $1 pages.\n"
                                        + "Cette action d'envergure devrait être effectuée de préférence par un bot.\n\n"
                                        + "Continuer quand même ?\n";                  // Confirmation grosse édition (>50 pages)
window.RenommageCategorie_Text_Delay = "(Un délai de $1 secondes s'écoulera entre deux modifications)";
window.RenommageCategorie_Text_ConfirmEdit = "$1 -> $2\n\nRésumé de modification : $3";  // Confirmation édition
window.RenommageCategorie_Text_ConfirmMove = "Recopier le contenu de $1 dans $2 ?";      // Copie
window.RenommageCategorie_Text_ConfirmMoveS = "Renommer $1 en $2 ?";                     // Déplacement
window.RenommageCategorie_Text_ConfirmMoveBis = 'Enregistrer la modification ?';          // Confirmation Copie
window.RenommageCategorie_Text_ConfirmWikidata = 'Transférer l\'entrée wikidata de $1 vers $2 ?'; // Copie de l'entrée wikidata
window.RenommageCategorie_Text_ConfirmDelete = "Supprimer la catégorie $1 ?";            // Suppression

// Pop-up lors d'un problème
window.RenommageCategorie_Text_AlertSameCat = "Les catégories à supprimer et à ajouter sont identiques";
window.RenommageCategorie_Text_AlertEditPb1 = "Impossible de trouver la catégorie « $1 » - elle est peut-être incluse via un modèle.";
window.RenommageCategorie_Text_AlertEditPb2 = "La catégorie « $1 » est déjà présente.";
window.RenommageCategorie_Text_AlertEditPb3 = "Plusieurs occurrences de la catégorie « $1 » trouvées.";
window.RenommageCategorie_Text_AlertEditTryAgain = 'Problème !\n\nRéessayer ?';
window.RenommageCategorie_Text_AlertEditNextPage = 'Page suivante ?';

// Résumés de modification
window.RenommageCategorie_Text_ResumeEditModif = "Modification de la catégorie [[$1]] → [[$2]]";
window.RenommageCategorie_Text_ResumeEditDelete = "Retrait de la catégorie [[$1]]";
window.RenommageCategorie_Text_ResumeMove = "Transfert du contenu depuis [[$1]]";
window.RenommageCategorie_Text_ResumeMoveHist = "Crédit des auteurs depuis [[$1]]";
window.RenommageCategorie_Text_ResumeDelete = "Catégorie remplacée par [[$2]]";
window.RenommageCategorie_Text_ResumeDeleteBis = "Catégorie vide et obsolète";

// --------------------------------------------------------------------------------------------
// Variables par défaut

window.RenommageCategorie_RemoveCat = mw.config.get('wgTitle');    // Catégorie à enlever
window.RenommageCategorie_AddCat = mw.config.get('wgTitle');       // Catégorie à ajouter
window.RenommageCategorie_Autoconfirm = false;    // Publication automatique
window.RenommageCategorie_AutoWatch = false;      // Suivi automatique
window.RenommageCategorie_TimeOut = 10;           // Délai par défaut après publication

window.RenommageCategorie_CanMoveCat = false;
window.RenommageCategorie_WikidataId = false;

if( (mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)){
   var RenommageCategorie_APILimit = 4999;
}else{
   var RenommageCategorie_APILimit = 499;
}
if(mw.config.get('wgUserGroups').indexOf("bot")!=-1){
   var RenommageCategorie_IsBot = true;
}else{
   var RenommageCategorie_IsBot = false;
}

// --------------------------------------------------------------------------------------------
// Fonction de requête

window.RenommageCategorie_ajax = {
  http:function(bundle){ 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){ RenommageCategorie_ajax.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){ try{ xmlhttp.setRequestHeader(field,bundle.headers[field]); }catch(err){}}}; 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{ }}
};

// --------------------------------------------------------------------------------------------
// Ajout du lien "Renommer"

window.RenommageCategorie_AddLink = function(){
     if(typeof(RenommageCategorie_LangCustom)=="function") RenommageCategorie_LangCustom();
     if(typeof(RenommageCategorie_SiteCustom)=="function") RenommageCategorie_SiteCustom();
     if(typeof(RenommageCategorie_UserCustom)=="function") RenommageCategorie_UserCustom();
     var OngletMove = document.getElementById('ca-move');
     if(OngletMove){
          var movelink = OngletMove.getElementsByTagName('a')[0];
          if(movelink){
               RenommageCategorie_CanMoveCat = true;
               movelink.href = "javascript:RenommageCategorie_OpenMenu();";
          }
     }
     if(!RenommageCategorie_CanMoveCat){
          var OngletsCactions = document.getElementById('p-cactions');
          if(OngletsCactions){
               var CactionsUl = OngletsCactions.getElementsByTagName('ul')[0];
               CactionsUl.innerHTML += '<li id="ca-move"><a href="javascript:RenommageCategorie_OpenMenu();">'+RenommageCategorie_Text_Move+'</a></li>';
               $(OngletsCactions).removeClass("emptyPortlet");
          }
     }
};

// --------------------------------------------------------------------------------------------
// Création du menu

window.RenommageCategorie_OpenMenu = function(){
    if(document.getElementById('RenommageCategorie_Menu')) return;

    var agt=navigator.userAgent.toLowerCase();
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    if(is_ie){
        var LargeurEcran = parseInt(screen.width);
        var HauteurEcran = parseInt(screen.height);
    }else{
        var LargeurEcran = parseInt(window.innerWidth);
        var HauteurEcran = parseInt(window.innerHeight);
    }

    var Menu = document.createElement('div');
    Menu.id='RenommageCategorie_Menu';
    Menu.className ='RenommageCategorie_Menu';
    Menu.style.position='fixed';
    Menu.style.zIndex= 500;
    Menu.style.padding='5px';
    Menu.style.backgroundColor='white';
    Menu.style.border='3px double black';
    Menu.style.width= '450px';
    Menu.style.height= '100px';
    document.body.appendChild(Menu);
    PositionGauche = parseInt((LargeurEcran-Menu.clientWidth)/2) ;
    PositionHaut = parseInt((HauteurEcran-Menu.clientHeight)/3) ;
    Menu.style.left=PositionGauche + 'px';
    Menu.style.top=PositionHaut + 'px';
    var StandardMoveLink = '<input type="button" style="cursor:pointer;" '
                         + 'onclick="RenommageCategorie_StandardMove();" '
                         + 'onselect="RenommageCategorie_StandardMove();" '
                         + 'title="Special:Movepage/'+mw.config.get('wgPageName')+'" '
                         + 'value="'+RenommageCategorie_Text_PopMoveOnlyCat+'"/>';
    var MenuContent = ''
    + '<input type="text" id="RemoveCat" value="'+mw.config.get('wgTitle')+'" disabled="disabled" size="50"/>'
    + '<label for="RemoveCat">'+RenommageCategorie_Text_PopRemoveCat+'</label>'
    + '<br />'
    + '<input type="text" id="AddCat" value="'+mw.config.get('wgTitle')+'" size="50" />'
    + '<label for="AddCat">'+RenommageCategorie_Text_PopAddCat+'</label>'
    + '<br />'
    + '<input type="checkbox" id="Autoconfirm" style="cursor:pointer;" '+(RenommageCategorie_Autoconfirm ? 'checked="checked"' : '') +'/>'
    + '<label for="Autoconfirm">'+RenommageCategorie_Text_PopConfirm+'</label>'
    + '&nbsp;&nbsp;'
    + '<input type="checkbox" id="AutoWatch" style="cursor:pointer;" '+(RenommageCategorie_AutoWatch ? 'checked="checked"' : '')+'/>'
    + '<label for="AutoWatch">'+RenommageCategorie_Text_PopWatch+'</label>'
    + '<br />'
    + '<br />'
    + '<center>'
    + ( RenommageCategorie_CanMoveCat ? StandardMoveLink + '&nbsp;&nbsp;' : '' )
    + '<input type="button" style="cursor:pointer;" '
    + ' value="'+RenommageCategorie_Text_PopButtonOKText+'" title="'+RenommageCategorie_Text_PopButtonOKTitle+'" '
    + ' onclick="RenommageCategorie_CheckMenu();" onselect="RenommageCategorie_CheckMenu();"/>'
    + '&nbsp;&nbsp;'
    + '<input type="button" style="cursor:pointer;" '
    + ' value="'+RenommageCategorie_Text_PopButtonCancelText+'" title="'+RenommageCategorie_Text_PopButtonCancelTitle+'" '
    + ' onclick="RenommageCategorie_CloseMenu();" onselect="RenommageCategorie_CloseMenu();"/>'
    + '</center>';
    Menu.innerHTML = MenuContent;
    document.getElementById("AddCat").focus();
};

// --------------------------------------------------------------------------------------------
// Annulation du menu

window.RenommageCategorie_CloseMenu = function(){
    var Menu = document.getElementById('RenommageCategorie_Menu');
    if(Menu) RenommageCategorie_DeleteElement(Menu);
};

// --------------------------------------------------------------------------------------------
// Renommage standard

window.RenommageCategorie_StandardMove = function(){
     var URL = mw.config.get('wgServer') + mw.config.get('wgArticlePath').split("$1").join("Special:Movepage/"+encodeURIComponent(mw.config.get('wgPageName')));
     window.location = URL;
}

// --------------------------------------------------------------------------------------------
// Validation du menu

window.RenommageCategorie_CheckMenu = function(){
     var AddCat = document.getElementById('AddCat');
     var Autoconfirm = document.getElementById('Autoconfirm');
     var AutoWatch = document.getElementById('AutoWatch');
     if( (!AddCat)||(!Autoconfirm)||(!AutoWatch) ) return;

     RenommageCategorie_AddCat = RenommageCategorie_deleteUnwantedUnicodeChars(AddCat.value);
     if(RenommageCategorie_AddCat == RenommageCategorie_RemoveCat){
          alert(RenommageCategorie_Text_AlertSameCat);
          return;
     }
     if(Autoconfirm.checked) RenommageCategorie_Autoconfirm = true;
     else RenommageCategorie_Autoconfirm = false;
     if(AutoWatch.checked) RenommageCategorie_AutoWatch = true;
     else RenommageCategorie_AutoWatch = false;
     RenommageCategorie_CloseMenu();
     RenommageCategorie_getWikidataId();
     RenommageCategorie_ListPages();
}

// --------------------------------------------------------------------------------------------
// Récupère l'id de l'entrée Wikidata si elle existe

window.RenommageCategorie_getWikidataId = function(){
      var WikidataLi = $.makeArray($(document).find('li.wbc-editpage'))[0];
      if(!WikidataLi) return;
      var WikidataLink = WikidataLi.getElementsByTagName('a')[0];
      if(WikidataLink && WikidataLink.href){
            if(!WikidataLink.className || (" "+WikidataLink.className+" ").indexOf(" new ")==-1)
            RenommageCategorie_WikidataId = WikidataLink.href.replace(/.*\/wiki\//ig, "");
      }
}

// --------------------------------------------------------------------------------------------
// Listage des pages de la catégorie cible

window.RenommageCategorie_ListPages = function(CatArray, category, categorycontinue){
     if(!CatArray) CatArray = new Array();
     if(!category) category = mw.config.get('wgPageName');
     if(!categorycontinue) categorycontinue = '';
     var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&list=categorymembers'
             + '&cmlimit=' + RenommageCategorie_APILimit
             + '&cmtitle=' + encodeURIComponent(category)
             + categorycontinue;

     RenommageCategorie_ajax.http({
          url: URL,
          cat: category,
          catlist: CatArray,
          onSuccess:RenommageCategorie_ListPagesDone
     });
}

window.RenommageCategorie_ListPagesDone = function(Req, data){
     var CatArray = data.catlist;
     var category = data.cat;
     var ElementTraitement = Req.responseXML;
     var Pages = ElementTraitement.getElementsByTagName('cm');
     for(a=0;a<Pages.length;a++){
          var TitrePage = Pages[a].getAttribute('title');
          if(CatArray.indexOf(TitrePage)==-1) CatArray.push(TitrePage);
     }
     var CatContinue = ElementTraitement.getElementsByTagName('query-continue')[0];
     if(CatContinue){
          var AutreRequeteContinue = '&cmcontinue=' + encodeURIComponent(CatContinue.firstChild.getAttribute("cmcontinue"));
          RenommageCategorie_ListPages(CatArray, category, AutreRequeteContinue);
     }else{
          RenommageCategorie_SortList(CatArray);
      }
}

// --------------------------------------------------------------------------------------------
// Triage des pages de la catégorie cible

window.RenommageCategorie_CatList = new Array();

window.RenommageCategorie_SortList = function(CatArray){
      while(RenommageCategorie_CatList[0]) RenommageCategorie_CatList.pop();
      var PagesTemp = CatArray.sort();
      for(var a=0;a<PagesTemp.length;a++){
           if(PagesTemp[a]!=PagesTemp[(a+1)]){
                 RenommageCategorie_CatList.push(PagesTemp[a]);
           }
      }
      var Length = RenommageCategorie_CatList.length;
      if(!RenommageCategorie_IsBot){
            if(Length<10) RenommageCategorie_TimeOut = (RenommageCategorie_TimeOut/2);
            if(Length>50){
                  RenommageCategorie_TimeOut = (RenommageCategorie_TimeOut*2);
                  var Text = ''
                           + RenommageCategorie_Text_GrosseModif.split('$1').join(Length)
                           + RenommageCategorie_Text_Delay.split('$1').join(RenommageCategorie_TimeOut)
                  var GrosseModif = confirm(Text);
                  if(!GrosseModif) window.location.reload();
            }else if(Length>0){
                  var Text = ''
                           + RenommageCategorie_Text_Modif.split('$1').join(Length)
                           + RenommageCategorie_Text_Delay.split('$1').join(RenommageCategorie_TimeOut)
                  var Modif = confirm(Text);
                  if(!Modif) window.location.reload();
            }
      }
      RenommageCategorie_ModifCat(0);
}

window.RenommageCategorie_gettag = function(){
  if(!RenommageCategorie_Tag || !RenommageCategorie_TagGroup) return false;
  var UserGroups = mw.config.get('wgUserGroups');
  if(UserGroups === null) UserGroups = ["*"];
  if(UserGroups.indexOf(RenommageCategorie_TagGroup) !== -1) return RenommageCategorie_Tag;
  return false;
}

// --------------------------------------------------------------------------------------------
// Changement de catégorie dans une page

window.RenommageCategorie_ModifCat = function(position){
     var Page = RenommageCategorie_CatList[position];
     if(!Page){
          var CreateNewCat_SurEtCertain = false;
          if(RenommageCategorie_AddCat!='') CreateNewCat_SurEtCertain = confirm( ( RenommageCategorie_CanMoveCat ? RenommageCategorie_Text_ConfirmMoveS : RenommageCategorie_Text_ConfirmMove ).split('$1').join(RenommageCategorie_RemoveCat).split('$2').join(RenommageCategorie_AddCat));
          if(!CreateNewCat_SurEtCertain){
               var urlOldCat = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title='
                             + mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_RemoveCat);
               var DeleteOldCat_SurEtCertain = confirm(RenommageCategorie_Text_ConfirmDelete.split('$1').join(RenommageCategorie_RemoveCat));
               if(DeleteOldCat_SurEtCertain){
                    if(mw.config.get('wgUserGroups').indexOf('sysop')!=-1){
                         RenommageCategorie_ajax.http({
                              url: urlOldCat + '&action=delete',
                              onSuccess:RenommageCategorie_DeleteOldCat
                         });
                    }else{
                         RenommageCategorie_ajax.http({
                              url: urlOldCat + '&action=edit',
                              onSuccess:RenommageCategorie_DoDeletionRequest
                         });
                    }
               }else{
                    window.location.reload();
               }
          }else{
               if(!RenommageCategorie_CanMoveCat) RenommageCategorie_CreateNewCat();
               else RenommageCategorie_MoveCat();
          }
          return;
     }
     watchStatusQuery = {'format': 'json', 'action': 'query', 'prop': 'info', 'inprop': 'watched', 'titles': Page};
     $.getJSON(mw.util.wikiScript('api'), watchStatusQuery, function(obj) {
          var watchStatus = false;
          for (var pageid in obj.query.pages) {
               watchStatus = typeof obj.query.pages[pageid].watched != 'undefined';
               break;
          }
          var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(Page) + '&action=edit';
          RenommageCategorie_ajax.http({
               url: URL,
               watchStatus: watchStatus,
               pos: position,
               onSuccess:RenommageCategorie_ModifCatRunning
          });
     });
}

window.RenommageCategorie_ModifCatRunning = function(Req, data){
     var position = data.pos;
     while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
     document.body.innerHTML = Req.responseText;
     var TextArea = document.getElementById('wpTextbox1');
     if(!TextArea){
          var Problem = confirm( url + '\n\n' + RenommageCategorie_Text_AlertEditTryAgain );
          if(Problem){
               RenommageCategorie_ModifCat(position);
          }else{
               var NextPage = confirm(RenommageCategorie_Text_AlertEditNextPage);
               if(NextPage) RenommageCategorie_ModifCat((position+1));
          }
          return;
     }
     var OldText = TextArea.value;
     var Sommaire = '';
     if ( RenommageCategorie_RemoveCat != "" ) {
          OldText = RenommageCategorie_CleanCats(OldText);
          var OldCatRegExp = RenommageCategorie_CreateRegExp(RenommageCategorie_RemoveCat);
          var OldCatmatches = OldText.match(OldCatRegExp);
          var AddCatRegExp = RenommageCategorie_CreateRegExp(RenommageCategorie_AddCat);
          var NewCatmatches = OldText.match(AddCatRegExp);
          if (NewCatmatches == null && OldCatmatches != null && OldCatmatches.length == 1) { // Found one occurrence of the category - good!
               if(RenommageCategorie_AddCat != ""){
                    OldText = OldText.replace(OldCatRegExp, "$1[["+mw.config.get('wgFormattedNamespaces')[14]+":" + RenommageCategorie_AddCat + "$6]]");
                    Sommaire = RenommageCategorie_Text_ResumeEditModif.split('$1').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_RemoveCat).split('$2').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_AddCat);
               } else {
                    OldText = OldText.replace(OldCatRegExp, "");
                    Sommaire = RenommageCategorie_Text_ResumeEditDelete.split('$1').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_RemoveCat);
               }
          } else {
               var Error;
               if(NewCatmatches!=null){
                    Error = RenommageCategorie_Text_AlertEditPb2.split('$1').join(RenommageCategorie_AddCat);
               }else if(OldCatmatches==null){
                    Error = RenommageCategorie_Text_AlertEditPb1.split('$1').join(RenommageCategorie_RemoveCat);
               }else if(OldCatmatches.length>1){
                    Error = RenommageCategorie_Text_AlertEditPb3.split('$1').join(RenommageCategorie_RemoveCat);
               }
               var Suivante = confirm(Error + "\n\n" + RenommageCategorie_Text_AlertEditNextPage);
               if(!Suivante){
                    window.location.reload();
               }else{
                    RenommageCategorie_ModifCat(position + 1);
               }
               return;
          }
     }
     var TexteFinal = OldText;
     var SommaireFinal = Sommaire ;
     document.getElementById('wpTextbox1').value = TexteFinal;
     document.getElementById('wpSummary').value = RenommageCategorie_Text_Script+SommaireFinal;
     var Minor = document.getElementById('wpMinoredit');
     if(Minor) Minor.checked = "checked";
     if(RenommageCategorie_AutoWatch || data.watchStatus) document.getElementById('wpWatchthis').checked = "checked";
     else document.getElementById('wpWatchthis').checked = "";
     if(!RenommageCategorie_Autoconfirm){
          var SurEtCertain = confirm(RenommageCategorie_Text_ConfirmEdit.split('$1').join(RenommageCategorie_RemoveCat).split('$2').join(RenommageCategorie_AddCat).split('$3').join(Sommaire));
          if(!SurEtCertain){
               var SurEtCertainBis = confirm(RenommageCategorie_Text_AlertEditNextPage);
               if(!SurEtCertainBis){
                    window.location.reload();
               }else{
                    RenommageCategorie_ModifCat((position+1));
               }
               return;
          }
     }
     var datas = {
          action    : 'edit',
          title     : RenommageCategorie_CatList[position],
          text      : TexteFinal,
          summary   : RenommageCategorie_Text_Script + SommaireFinal,
          minor     : 1,
          watchlist : "nochange",
          token     : document.editform.wpEditToken.value
     };
     var EditTag = RenommageCategorie_gettag();
     if(EditTag){
          datas.summary = SommaireFinal;
          datas.tags = EditTag;
     }
     var api = new mw.Api();
     api.post( datas, {'contentType':'application/x-www-form-urlencoded'} ).then( function ( data ) {
          if(RenommageCategorie_IsBot){
               RenommageCategorie_ModifCat((position+1));
          }else{
               while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
               var P = document.createElement('p');
               P.style.textAlign = "center";
               P.innerHTML = RenommageCategorie_Text_Delay.split("$1").join(RenommageCategorie_TimeOut);
               document.body.appendChild(P);
               setTimeout("RenommageCategorie_ModifCat("+(position+1)+")",RenommageCategorie_TimeOut*1000);
          }
     });
}

// --------------------------------------------------------------------------------------------
// Création d'une nouvelle catégorie par déplacement

window.RenommageCategorie_MoveCat = function(){
     watchStatusQuery = {'format': 'json', 'action': 'query', 'prop': 'info', 'inprop': 'watched', 'titles': mw.config.get('wgPageName')};
     $.getJSON(mw.util.wikiScript('api'), watchStatusQuery, function(obj) {
          var watchStatus = false;
          for (var pageid in obj.query.pages) {
               watchStatus = typeof obj.query.pages[pageid].watched != 'undefined';
               break;
          }
          var URL = mw.config.get('wgServer') + mw.config.get('wgArticlePath').split("$1").join("Special:Movepage/"+encodeURIComponent(mw.config.get('wgPageName')));
          RenommageCategorie_ajax.http({
               url: URL,
               onSuccess:RenommageCategorie_MoveCat_Process
          });
     });
}

window.RenommageCategorie_MoveCat_Process = function(Req, data){
     while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
     document.body.innerHTML = Req.responseText;
     document.getElementById("watch").checked = (RenommageCategorie_AutoWatch || data.watchStatus ? "checked" : false);
     document.getElementById("wpNewTitleMain").value = RenommageCategorie_AddCat;
     document.getElementById("wpReason").value = RenommageCategorie_Text_Script;
     var CanDeleteCat = document.getElementById("wpLeaveRedirect");
     if(CanDeleteCat)  CanDeleteCat.checked = false;
     var ThisIsTheEnd = false;
     var TheLastStep = false;
     var DeleteOldCat_SurEtCertain = confirm(RenommageCategorie_Text_ConfirmDelete.split('$1').join(RenommageCategorie_RemoveCat));
     if(DeleteOldCat_SurEtCertain){
          if(CanDeleteCat){
               ThisIsTheEnd = true;
          }else{
               TheLastStep = function(){
                    RenommageCategorie_ajax.http({
                          url:mw.config.get('wgServer')+mw.config.get('wgScript')+'?title=' 
                              + mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_RemoveCat)+'&action=edit',
                         onSuccess:RenommageCategorie_DoDeletionRequest
                    });
               }
          }
     }else{
          if(CanDeleteCat) CanDeleteCat.checked = "checked";
          ThisIsTheEnd = true;
     }
     var MoveForm = document.getElementById('movepage');
     var SubmitAjaxFunction = function(){
          if(ThisIsTheEnd){
               MoveForm.submit();
               return;
          }
          var action = MoveForm.action;
          var headers = new Array();
          headers['Content-Type'] = 'application/x-www-form-urlencoded';
          RenommageCategorie_ajax.http({
               url: action,
               method: "POST",
               headers: headers,
               data: RenommageCategorie_GetPostValues(),
               onSuccess:TheLastStep
          });
     }
     if(RenommageCategorie_Autoconfirm){
          SubmitAjaxFunction();
     }else{
          var SurEtCertain = confirm(RenommageCategorie_Text_ConfirmMoveBis);
          if(SurEtCertain){
               SubmitAjaxFunction();
          }
     }
}

// --------------------------------------------------------------------------------------------
// Création nouvelle catégorie par copie

window.RenommageCategorie_CreateNewCat = function(){
     var URLOldCat = mw.config.get('wgServer')+mw.config.get('wgScript')+'?title='+mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_RemoveCat)+'&action=raw';
     RenommageCategorie_ajax.http({
          url: URLOldCat,
          onSuccess:RenommageCategorie_CreateNewCat_GetOldText

     });
}

window.RenommageCategorie_CreateNewCat_GetOldText = function(Req, data){
     var Text = Req.responseText;
     var URLNewCat = mw.config.get('wgServer')+mw.config.get('wgScript')+'?title='+mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_AddCat)+'&action=edit';
     RenommageCategorie_ajax.http({
          url: URLNewCat,
          onSuccess:RenommageCategorie_CreateNewCatProcess,
          text:Text
     });
}

window.RenommageCategorie_CreateNewCatProcess = function(Req, data){
     var TexteFinal = data.text;
     while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
     document.body.innerHTML = Req.responseText;
     var TextArea = document.getElementById('wpTextbox1');
     if(!TextArea){
          var Problem = confirm( data.url + '\n\n' + RenommageCategorie_Text_AlertEditTryAgain );
          if(Problem){
               RenommageCategorie_CreateNewCat();
          }
          return;
     }
     var WikidataTag = "";
     if(RenommageCategorie_WikidataId){
          var Alert = RenommageCategorie_Text_ConfirmWikidata;
          Alert = Alert.split('$1').join(RenommageCategorie_RemoveCat);
          Alert = Alert.split('$2').join(RenommageCategorie_AddCat);
          if(confirm(Alert)){
               WikidataTag = RenommageCategorie_Text_WikidataTemplate;
               WikidataTag = WikidataTag.split("$1").join(RenommageCategorie_WikidataId)+"\n";
          }
     }
     TexteFinal = WikidataTag + TexteFinal;
     var SommaireFinal = RenommageCategorie_Text_ResumeMove.split('$1').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_RemoveCat);
     document.getElementById('wpTextbox1').value = TexteFinal;
     document.getElementById('wpSummary').value = RenommageCategorie_Text_Script + SommaireFinal;
     var Minor = document.getElementById('wpMinoredit');
     if(Minor) Minor.checked = "checked";
     if(!RenommageCategorie_Autoconfirm){
          var SurEtCertainNewCat = confirm(RenommageCategorie_Text_ConfirmMoveBis);
          if(!SurEtCertainNewCat){
               return;
          }
     }
     var datas = {
          action    : 'edit',
          title     : mw.config.get('wgFormattedNamespaces')[14]+':'+RenommageCategorie_AddCat,
          text      : TexteFinal,
          summary   : RenommageCategorie_Text_Script + SommaireFinal,
          minor     : 1,
          watchlist : "nochange",
          token     : document.editform.wpEditToken.value
     };
     var EditTag = RenommageCategorie_gettag();
     if(EditTag){
          datas.summary = SommaireFinal;
          datas.tags = EditTag;
     }
     var api = new mw.Api();
     api.post( datas, {'contentType':'application/x-www-form-urlencoded'} ).then( function ( data ) {
          while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
          var P = document.createElement('p');
          P.style.textAlign = "center";
          P.innerHTML = RenommageCategorie_Text_ResumeMoveHist.split("$1").join(mw.config.get('wgFormattedNamespaces')[14]+':'+RenommageCategorie_RemoveCat);
          document.body.appendChild(P);
          RenommageCategorie_GetUsers();
     });
}

// --------------------------------------------------------------------------------------------
// Crédit des auteurs de l'ancienne catégorie : recherche des auteurs

window.RenommageCategorie_GetUsers = function(Users, UserContinue){
      if(!Users) Users = new Array();
      if(!UserContinue) UserContinue = "";
      var URL = mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php?format=xml&action=query&prop=revisions'
              + '&rvlimit='+RenommageCategorie_APILimit
              + '&rvprop=user'
              + '&titles='+mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_RemoveCat)
              + UserContinue;
     RenommageCategorie_ajax.http({
          url: URL,
          onSuccess:RenommageCategorie_GetUsersDone,
          users:Users
     });
}

window.RenommageCategorie_GetUsersDone = function(Req, data){
     var Users = data.users;
     var Reponse = Req.responseXML;
     var RevUsers = Reponse.getElementsByTagName("rev");
     for(var a=0;a<RevUsers.length;a++){
          var ThisUser = RevUsers[a].getAttribute("user");
          if(Users.indexOf(ThisUser)==-1) Users.push(ThisUser);
     }
     var RevContinue = Reponse.getElementsByTagName("query-continue")[0];
     if(RevContinue){
          var Cont = "&rvstartid=" + encodeURIComponent(RevContinue.firstChild.getAttribute("rvstartid"));
          RenommageCategorie_GetUsers(Users, Cont);
     }else{
          var urlTalkNewCat = mw.config.get('wgServer')+mw.config.get('wgScript')+'?title='+mw.config.get('wgFormattedNamespaces')[15]+':'+encodeURIComponent(RenommageCategorie_AddCat)+'&action=edit';
          RenommageCategorie_ajax.http({
               url: urlTalkNewCat,
               onSuccess:RenommageCategorie_UpDateCatTalkPage,
               users:Users
          });
     }
}

// --------------------------------------------------------------------------------------------
// Crédit des auteurs de l'ancienne catégorie : édition de la page de discussion

window.RenommageCategorie_UpDateCatTalkPage = function(Req, data){
     var Users = data.users;
     while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
     document.body.innerHTML = Req.responseText;
     var TextArea = document.getElementById('wpTextbox1');
     if(!TextArea){
          var Problem = confirm( urlTalkNewCat + '\n\n' + RenommageCategorie_Text_AlertEditTryAgain );
          if(Problem){
               RenommageCategorie_UpDateCatTalkPage(Users);
          }
          return;
     }
     var OldContent = TextArea.value;
     var NewTemplate = RenommageCategorie_Text_HistTemplate.split('$1').join(RenommageCategorie_RemoveCat);
     var UserList = "";
     for(var a=0;a<Users.length;a++){
          if(a!=0) UserList += ", ";
          UserList += RenommageCategorie_Text_UserTemplate.split('$1').join(Users[a]);
     }
     NewTemplate = NewTemplate.split('$2').join(UserList);

     var TexteFinal = NewTemplate + OldContent;
     var SommaireFinal = RenommageCategorie_Text_ResumeMoveHist.split('$1').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_RemoveCat);

     document.getElementById('wpTextbox1').value = TexteFinal;
     document.getElementById('wpSummary').value = RenommageCategorie_Text_Script + SommaireFinal;
     var Minor = document.getElementById('wpMinoredit');
     if(Minor) Minor.checked = "checked";
     if(!RenommageCategorie_Autoconfirm){
          var SurEtCertainNewCat = confirm(RenommageCategorie_Text_ConfirmMoveBis);
          if(!SurEtCertainNewCat){
               return;
          }
     }
     var datas = {
          action    : 'edit',
          title     : mw.config.get('wgFormattedNamespaces')[15]+':'+RenommageCategorie_AddCat,
          text      : TexteFinal,
          summary   : RenommageCategorie_Text_Script + SommaireFinal,
          minor     : 1,
          watchlist : "nochange",
          token     : document.editform.wpEditToken.value
     };
     var EditTag = RenommageCategorie_gettag();
     if(EditTag){
          datas.summary = SommaireFinal;
          datas.tags = EditTag;
     }
     var api = new mw.Api();
     api.post( datas, {'contentType':'application/x-www-form-urlencoded'} ).then( function ( data ) {
          while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
          var P = document.createElement('p');
          P.style.textAlign = "center";
          document.body.appendChild(P);
          RenommageCategorie_UpDateCatTalkPageDone();
     });
}

window.RenommageCategorie_UpDateCatTalkPageDone = function(){
     var urlOldCat = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title='
                   + mw.config.get('wgFormattedNamespaces')[14]+':'+encodeURIComponent(RenommageCategorie_RemoveCat)
     var DeleteOldCat_SurEtCertain = confirm(RenommageCategorie_Text_ConfirmDelete.split('$1').join(RenommageCategorie_RemoveCat));
     if(DeleteOldCat_SurEtCertain){
          if(mw.config.get('wgUserGroups').indexOf('sysop')!=-1){
               RenommageCategorie_ajax.http({
                    url: urlOldCat + '&action=delete',
                    onSuccess:RenommageCategorie_DeleteOldCat
               });
          }else{
               RenommageCategorie_ajax.http({
                    url: urlOldCat + '&action=edit',
                    onSuccess:RenommageCategorie_DoDeletionRequest
               });
          }
     }else{
          window.location.reload;
          return;
     }
}

// --------------------------------------------------------------------------------------------
// Suppression de l'ancienne catégorie

window.RenommageCategorie_DeleteOldCat = function(Req, data){
      while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
      var ElementTraitement = document.createElement('div');
      document.body.appendChild(ElementTraitement);
      ElementTraitement.innerHTML = Req.responseText;
      var InputReason = document.getElementById('wpReason');
      if(RenommageCategorie_AddCat==''){
            InputReason.value = RenommageCategorie_Text_Script+RenommageCategorie_Text_ResumeDeleteBis;
      }else{
            InputReason.value = RenommageCategorie_Text_Script+RenommageCategorie_Text_ResumeDelete.split('$2').join(mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_AddCat);
      }
      var CheckWatch = document.getElementById('wpWatch');
      CheckWatch.checked = '';
      var DeleteForm = document.getElementById('deleteconfirm');
      if(RenommageCategorie_Autoconfirm){
            DeleteForm.submit();
      }else{
            var SurEtCertain = confirm(RenommageCategorie_Text_ConfirmDelete.split('$1').join(RenommageCategorie_RemoveCat));
            if(SurEtCertain) DeleteForm.submit();
      }
}

// --------------------------------------------------------------------------------------------
// Demande de suppression de l'ancienne catégorie

window.RenommageCategorie_DoDeletionRequest = function(Req, data){
      while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
      var ElementTraitement = document.createElement('div');
      document.body.appendChild(ElementTraitement);
      ElementTraitement.innerHTML = Req.responseText;
      var EditForm = document.getElementById('editform');
      EditForm.style.display = "none";
      var Reason = "";
      if(RenommageCategorie_AddCat==''){
            Reason = RenommageCategorie_Text_Script+RenommageCategorie_Text_ResumeDeleteBis;
      }else{
            Reason = RenommageCategorie_Text_Script+RenommageCategorie_Text_ResumeDelete.split('$2').join(":"+mw.config.get('wgFormattedNamespaces')[14]+":"+RenommageCategorie_AddCat);
      }
      var DeleteTemplate = RenommageCategorie_Text_DeleteTemplate;
      DeleteTemplate = DeleteTemplate.split("$1").join(Reason).split("$2").join("~"+"~~");
      document.getElementById('wpTextbox1').value = DeleteTemplate;
      document.getElementById('wpSummary').value = Reason;
      var Minor = document.getElementById('wpMinoredit');
      if(Minor) Minor.checked = "checked";
      EditForm.submit();
}

// --------------------------------------------------------------------------------------------
// FONCTION : Récupération des paramètres de publications


window.RenommageCategorie_GetPostValues = function(){
      var data="";
      var Params = new Array("wpTextbox1", "wpSection", "wpSummary", "wpWatchthis", "wpMinoredit", "wpStarttime", "wpEdittime", "wpEditToken");
      for(var a=0,l=Params.length;a<l;a++){
            var Element = document.getElementById(Params[a]);
            if(!Element) Element = document.getElementsByName(Params[a])[0];
            if(Element){
                  if(!(Element.tagName && Element.tagName.toLowerCase()=='input' && Element.type == 'checkbox' && !Element.checked)){
                        data += '&'+Params[a]+'=' + encodeURIComponent(Element.value);
                  }
            }
      }
      return (data+'&wpsave=1');
}

// FONCTION : Suppression d'un élément

window.RenommageCategorie_DeleteElement = function(OldElement){
    var agt=navigator.userAgent.toLowerCase();
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    if(is_ie){
        OldElement.removeNode(true);
    }else{
        if(OldElement.parentNode){document=OldElement.parentNode.removeChild(OldElement);}
    }
}

window.RenommageCategorie_CleanCats = function(OldText){
    var CatRegExp = new RegExp("\\[\\[(?:"+mw.config.get('wgFormattedNamespaces')[14]+"|Category):[^\\]]+\\]\\]", "ig");
    var CatNSRegExp = new RegExp("("+mw.config.get('wgFormattedNamespaces')[14]+"|Category) *: *", "ig");
    var Matches = OldText.match(CatRegExp);
    if(Matches==null) return OldText;
    for(var a=0,l=Matches.length;a<l;a++){
        var Newcat = Matches[a].replace(/_/g, " ");
        var catNSmatch = Newcat.match(CatNSRegExp);
        if(catNSmatch!=null){
            for(var b=0,m=catNSmatch.length;b<m;b++){
                Newcat = Newcat.replace(catNSmatch[b], mw.config.get('wgFormattedNamespaces')[14]+":");
            }
        }
        var Index = Newcat.indexOf(mw.config.get('wgFormattedNamespaces')[14]);
        if(Index!=-1){
            Index = (Index + mw.config.get('wgFormattedNamespaces')[14].length + 1);
            var StartCat = Newcat.substring(0, Index);
            var EndCat = Newcat.substring(Index, Newcat.length);
            EndCat = ( RenommageCategorie_CaseSensitive ? EndCat : EndCat.ucFirst() );
            Newcat = StartCat + EndCat;
        }
        OldText = OldText.replace(Matches[a], Newcat);
    }
    return OldText;
}

// FONCTION : création RegExp

window.RenommageCategorie_CreateRegExp = function(Cat){
    Cat = (RenommageCategorie_CaseSensitive ? Cat : Cat.ucFirst() );
    var CatRegExp = new RegExp("(\\s*)\\[\\[( |_)*(?:"+mw.config.get('wgFormattedNamespaces')[14]+"|Category)( |_)*:( |_)*" + Cat.replace(/([\\\^\$\*\+\?\.\|\{\}\[\]\(\)])/g, "\\$1")+"( |_)*(\\|[^\\]]*)?\\]\\]", "g");
    return CatRegExp;
}

// FONCTION : première lettre en majuscule

String.prototype.ucFirst = function () {
    return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}

// FONCTION : première lettre en minuscule

String.prototype.lcFirst = function () {
    return this.substr(0,1).toLowerCase() + this.substr(1,this.length);
}
 
// Retrait de caractères unicode indésirables
 
window.RenommageCategorie_deleteUnwantedUnicodeChars = function(Text){
  return Text.replace(/\u200E|\u200F|\u202A|\u202B|\u202C|\u202D|\u202E/g, '');
}


// --------------------------------------------------------------------------------------------
// Lancement

if(mw.config.get('wgNamespaceNumber')==14 && mw.config.get('wgUserGroups') && mw.config.get('wgUserGroups').indexOf("autoconfirmed")!=-1){
    mw.loader.implement( "RenommageCategorieLangs", ['//fr.wikipedia.org/w/index.php?title=Mediawiki:Gadget-RenommageCategorieLang.js&action=raw&ctype=text/javascript'], {}, {}, {} );
    mw.loader.using("RenommageCategorieLangs", function(){ $(RenommageCategorie_AddLink); });
}
// </nowiki></pre></source>