Utilisateur:Dr Brains/ListAllPortals.js

Une page de Wikipédia, l'encyclopédie libre.
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.
/* 
__NOTOC__
<center><h2 style="margin-top:-1.5em;"> Mise à jour des listes de portails</h2></center>
{| width="100%" style="background:white;border:1px solid gray;"
| width="200px" valign="middle" align="center" style="background:white;border:1px solid silver;" |
<span id="ListAllPortals_Link">[[Image:Crystal Clear action exit.svg|100px|Démarrer la mise à jour|link=]]</span>
| rowspan="2" align="left" valign="top" style="background:white;border:1px solid silver;" |
<div style="height:250px;overflow-y:scroll;padding:0;padding-left:1em;padding-right:1em;">
{{Special:Recentchangeslinked/{{FULLPAGENAME}}}}
</div>
|--------------------------------------------------------------------------------
| align="left" valign="middle" style="background:white;border:1px solid silver;" |
# {{nobr|[[Wikipédia:Liste des portails#Liste des portails|Liste des portails]]}}
# {{nobr|[[Wikipédia:Liste des portails#Portails à améliorer|Portails à améliorer]]}}
# {{nobr|{{m|Portail au hasard}}}}
# {{nobr|{{m|Portail ébauché au hasard}}}}
# {{nobr|{{m|Nombre de portails}}}}
|}


{{#ifeq:{{{showdoc|}}}|non||
<center><h2> Documentation</h2></center>
{{Aide détaillée|Projet:JavaScript/Notices/ListAllPortals}}
<div style="border:2px dashed green;padding:1.5em;">Pour utiliser ce programme : 
# ajouter à votre [[Special:Mypage/common.js|common.js]] le code : 
#* '''<code>mw.loader.load('//fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-ListAllPortals.js&action=raw&ctype=text/javascript');</code>'''
# ajouter dans n'importe quelle page de l'[[Aide:espace de noms|espace de noms]] <code>Utilisateur:</code> ou <code>MediaWiki:</code> le code :
#* '''<code><nowiki>{{MediaWiki:Gadget-ListAllPortals.js}}</nowiki></code>'''
# Purger le cache de votre navigateur
# Cliquer sur le gros bouton rouge ci-dessus.
</div>}}


{{#ifeq:{{{showscript|}}}|oui|
<center><h2>Script</h2></center>
<center><h5>[[MediaWiki:Gadget-ListAllPortals.js]] (Licence : [[Domaine public (propriété intellectuelle)|Domaine public]])</h5></center>
<!--
*/
//-->{{Boîte déroulante début|titre=Variables}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_CommStart ='<!-- DÉBUT LISTE -->';
window.ListAllPortals_CommEnd ='<!-- FIN LISTE -->';
window.ListAllPortals_Resume = '[[MediaWiki:Gadget-ListAllPortals/Run|Mise à jour de la liste des portails]]';

window.ListAllPortals_APILimit = ( ((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) ? 4999 : 499 );

// API URL
window.ListAllPortals_APIURL_AllPortals = '//fr.wikipedia.org/w/api.php?format=xml&action=query&list=allpages&aplimit='+ListAllPortals_APILimit+'&apnamespace=100&apfilterredir=nonredirects';
window.ListAllPortals_APIURL_StubPortals = '//fr.wikipedia.org/w/api.php?format=xml&action=query&list=categorymembers&cmlimit='+ListAllPortals_APILimit+'&cmtitle=Catégorie:Wikipédia:ébauche Portail:';
window.ListAllPortals_APIURL_PdQPortals = '//fr.wikipedia.org/w/api.php?format=xml&action=query&list=categorymembers&cmlimit='+ListAllPortals_APILimit+'&cmtitle=Catégorie:Portail de qualité';
window.ListAllPortals_APIURL_BPPortals = '//fr.wikipedia.org/w/api.php?format=xml&action=query&list=categorymembers&cmlimit='+ListAllPortals_APILimit+'&cmtitle=Catégorie:Bon portail';

// Edit URL
window.ListAllPortals_ListURL = '//fr.wikipedia.org/w/index.php?title=Wikipédia:Liste_des_portails&action=edit&section=1';
window.ListAllPortals_StubListURL = '//fr.wikipedia.org/w/index.php?title=Wikipédia:Liste_des_portails&action=edit&section=3';
window.ListAllPortals_RandomListURL = '//fr.wikipedia.org/w/index.php?title=Modèle:Portail_au_hasard&action=edit';
window.ListAllPortals_RandomStubListURL = '//fr.wikipedia.org/w/index.php?title=Modèle:Portail_ébauché_au_hasard&action=edit';
window.ListAllPortals_NumberOfPortalsURL = '//fr.wikipedia.org/w/index.php?title=Modèle:Nombre_de_portails&action=edit';

window.ListAllPortals_ExceptionArray = new Array();         // Portails listés manuellement (présence d'un slash)
ListAllPortals_ExceptionArray.push("Portail:GNU/Linux");


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=FONCTION : Fonctions Ajax}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_Ajax = 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){
                if (xmlhttp.status == 200 || xmlhttp.status == 302) {
                    if (bundle.onSuccess) bundle.onSuccess(xmlhttp,bundle);
                } else {
                    if (bundle.onFailure) bundle.onFailure(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;
};
 
window.ListAllPortals_GetPage = function(URL, NextFunc){
    ListAllPortals_Ajax({ url: URL,
                          onSuccess:NextFunc
    });
}

window.ListAllPortals_SavePage = function(NextFunc){
    //if(!confirm("OK ?")) return;
    var Form = document.getElementById('editform');
    var action = Form.action;
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    ListAllPortals_Ajax({ url: action,
                          method: "POST",
                          headers: headers,
                          data: ListAllPortals_createURLFromParams(ListAllPortals_getFormParams(Form)),
                          onSuccess:(NextFunc ? NextFunc : function(){ window.location.reload(); } )
    });
}



//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=FONCTION : Suppression des accents pour le tri}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_NoAccent = function(text){
      text=text.toLowerCase();
      text=text.replace(/â/g,"a");
      text=text.replace(/å/g,"a");
      text=text.replace(/é/g,"e");
      text=text.replace(/è/g,"e");
      text=text.replace(/ê/g,"e");
      text=text.replace(/ë/g,"e");
      text=text.replace(/î/g,"i");
      text=text.replace(/ï/g,"i");
      text=text.replace(/ô/g,"o");
      text=text.replace(/œ/g,"oe");
      text=text.replace(/ç/g,"c");
      text=text.replace(/š/g,"s");
      text=text.replace(/-/g," ");
      text=text.replace(/'/g," ");
      text=text.replace(/:les /i,":");
      text=text.replace(/:la /i,":");
      return text;
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=FONCTION : Suppression des caractères HTML}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_HTMLDecode = function(text){
      var EncodedCharacter = new Array();
      var DecodedCharacter = new Array();
      var CharacterCount = 0;
 
      EncodedCharacter[CharacterCount] = "&amp;";
      DecodedCharacter[CharacterCount] = "&";
      CharacterCount++;
      EncodedCharacter[CharacterCount] = "&#039;";
      DecodedCharacter[CharacterCount] = "'";
      CharacterCount++;
      EncodedCharacter[CharacterCount] = "&quot;";
      DecodedCharacter[CharacterCount] = '"';
      CharacterCount++;
 
      for(var a=0;a<EncodedCharacter.length;a++){
            while(text.indexOf(EncodedCharacter[a])!=-1){
                  text = text.split(EncodedCharacter[a]).join(DecodedCharacter[a]);
                  if(text.indexOf(EncodedCharacter[a])==-1) break;
            }
      }
      return text;
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=FONCTION : suivi du process}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_Alert = function(Text){
      if(!Text) Text = '';
      var ControlElement = document.getElementById('ListAllPortals_Control');
      if(ControlElement) ControlElement.innerHTML = Text;
}

//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=FONCTION : récupération paramètres d'édition}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_getFormParams = function(Form){
     var Params = new Array();
     var Tags = new Array("textarea", "select", "input");
     for(var a=0,l=Tags.length;a<l;a++){
          var Elements = Form.getElementsByTagName(Tags[a]);
          for(var b=0,m=Elements.length;b<m;b++){
               var Element = Elements[b];
               var ElName = Element.name;
               var ElValue = Element.value;
               var ElType = Element.type;
               if(Tags[a].toLowerCase()=='input' && (ElType == "checkbox" || ElType == "radio") && Element.checked){
                    Params[ElName] = ElValue;
               }else if(Tags[a].toLowerCase()=='input' && (ElType == "text" || ElType == "hidden") ){
                    Params[ElName] = ElValue;
               }else if(Tags[a].toLowerCase()!='input'){
                    Params[ElName] = ElValue;
               }
          }
     }
     return Params;
}


window.ListAllPortals_createURLFromParams = function(Params){
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    return ParamsInURL.join('&');
}

//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Ajout du lien de mise à jour}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_AddLinks = function(){
      var ButtonLink = document.getElementById('ListAllPortals_Link');
      if(!ButtonLink) return;
      var Link = '<a id="ListAllPortals_A" href="javascript:ListAllPortals_Run();" title="Lancer la mise à jour">' + ButtonLink.innerHTML + '</a>';
      ButtonLink.innerHTML = Link;
      var Separator = document.createElement('br');
      var ControlSpan = document.createElement('span');
      ControlSpan.id = 'ListAllPortals_Control';
      ButtonLink.parentNode.insertBefore(Separator, ButtonLink);
      ButtonLink.parentNode.insertBefore(ControlSpan, Separator);
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Recherche des pages de l'espace de noms Portail: }}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_Array = new Array();
window.ListAllPortals_Array_NoAccent = new Array();

for(var z=0;z<ListAllPortals_ExceptionArray.length;z++){
      ListAllPortals_Array.push(ListAllPortals_ExceptionArray[z]);
      ListAllPortals_Array_NoAccent.push(ListAllPortals_NoAccent(ListAllPortals_ExceptionArray[z]));
}

window.ListAllPortals_Run = function(){
      ListAllPortals_Alert("Listage de tous les portails");
      ListAllPortals_GetPage(ListAllPortals_APIURL_AllPortals, ListAllPortals_AllPortals);
}

window.ListAllPortals_AllPortals = function(Req){
      var ObjetXML = Req.responseXML; 
      var AllPortals = ObjetXML.getElementsByTagName('p');
      for(a=0;a<AllPortals.length;a++){
            var TitrePage =AllPortals[a].getAttribute('title');
            if((TitrePage.indexOf('/')==-1)&&(TitrePage!="Portail:Accueil")){
                  ListAllPortals_Array.push(TitrePage);
                  ListAllPortals_Array_NoAccent.push(ListAllPortals_NoAccent(TitrePage));
            }
      } 
      var AutreRequeteNecessaire = ObjetXML.getElementsByTagName('query-continue')[0];
      if(AutreRequeteNecessaire){
            var ContinueParam = AutreRequeteNecessaire.firstChild.attributes[0];
            var AutreRequeteContinue = ContinueParam.value;
            ListAllPortals_Alert("Listage de tous les portails : "+AutreRequeteContinue);
            ListAllPortals_GetPage(ListAllPortals_APIURL_AllPortals+'&'+ContinueParam.name+'='+encodeURIComponent(AutreRequeteContinue), ListAllPortals_AllPortals);
      }else{
            ListAllPortals_Alert("Listage des ébauches de portail");
            ListAllPortals_GetPage(ListAllPortals_APIURL_StubPortals, ListAllPortals_StubPortals);
      }
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Recherche portails ébauchés}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_StubArray = new Array();
window.ListAllPortals_StubArray_NoAccent = new Array();

window.ListAllPortals_StubPortals = function(Req){
      var ObjetXML = Req.responseXML; 
      var Lines = ObjetXML.getElementsByTagName('cm');
      for(var a=0,l=Lines.length;a<l;a++){
            var NS = parseInt(Lines[a].getAttribute('ns'));
            var TitrePage = Lines[a].getAttribute('title');
            if((NS==100) && (TitrePage.indexOf('/')==-1)&&(TitrePage!="Portail:Accueil")){
                  ListAllPortals_StubArray.push(TitrePage);
                  ListAllPortals_StubArray_NoAccent.push(ListAllPortals_NoAccent(TitrePage));
            }
      }
      var MustContinue = ObjetXML.getElementsByTagName('query-continue')[0];
      if(MustContinue){
            var ContinueParam = MustContinue.firstChild.attributes[0];
            var ValueToContinue = ContinueParam.value;
            ListAllPortals_Alert("Listage des ébauches de portail : "+ValueToContinue);
            ListAllPortals_GetPage(ListAllPortals_APIURL_StubPortals+'&'+ContinueParam.name+'='+encodeURIComponent(ValueToContinue), ListAllPortals_StubPortals);
      }else{
            ListAllPortals_Alert("Listage des portails de qualité");
            ListAllPortals_GetPage(ListAllPortals_APIURL_PdQPortals, ListAllPortals_PdQPortals);
      }
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Recherche portails de qualité}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_PdQArray = new Array();
 
window.ListAllPortals_PdQPortals = function(Req){
      var ObjetXML = Req.responseXML; 
      var Lines = ObjetXML.getElementsByTagName('cm');
      for(var a=0,l=Lines.length;a<l;a++){
            var NS = parseInt(Lines[a].getAttribute('ns'));
            var TitrePage = Lines[a].getAttribute('title');
            if(NS==100){
                  ListAllPortals_PdQArray.push(TitrePage);
            }
      }
      var MustContinue = ObjetXML.getElementsByTagName('query-continue')[0];
      if(MustContinue){
            var ContinueParam = MustContinue.firstChild.attributes[0];
            var ValueToContinue = ContinueParam.value;
            ListAllPortals_Alert("Listage des portails de qualité : "+ValueToContinue);
            ListAllPortals_GetPage(ListAllPortals_APIURL_PdQPortals+'&'+ContinueParam.name+'='+encodeURIComponent(ValueToContinue), ListAllPortals_PdQPortals);
      }else{
            ListAllPortals_Alert("Listage des bons portails");
            ListAllPortals_GetPage(ListAllPortals_APIURL_BPPortals, ListAllPortals_BPPortals);
      }
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Recherche bons portails}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_BPArray = new Array();
 
window.ListAllPortals_BPPortals = function(Req){
      var ObjetXML = Req.responseXML; 
      var Lines = ObjetXML.getElementsByTagName('cm');
      for(var a=0,l=Lines.length;a<l;a++){
            var NS = parseInt(Lines[a].getAttribute('ns'));
            var TitrePage = Lines[a].getAttribute('title');
            if(NS==100){
                  ListAllPortals_BPArray.push(TitrePage);
            }
      }
      var MustContinue = ObjetXML.getElementsByTagName('query-continue')[0];
      if(MustContinue){
            var ContinueParam = MustContinue.firstChild.attributes[0];
            var ValueToContinue = ContinueParam.value;
            ListAllPortals_Alert("Listage des bons portails : "+ValueToContinue);
            ListAllPortals_GetPage(ListAllPortals_APIURL_BPPortals+'&'+ContinueParam.name+'='+encodeURIComponent(ValueToContinue), ListAllPortals_BPPortals);
      }else{
            ListAllPortals_Alert("Tri des pages");
            ListAllPortals_Sort();
      }
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Tri alphabétique des pages}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_SortedArray = new Array();
window.ListAllPortals_SortedArrayCount = -1;
window.ListAllPortals_SortedStubArray = new Array();
window.ListAllPortals_SortedStubArrayCount = -1;

window.ListAllPortals_Sort = function(){
      ListAllPortals_Alert("Tri des portails");
      ListAllPortals_Array_NoAccent.sort();
      for(var a=0;a<ListAllPortals_Array_NoAccent.length;a++){
            for(var b=0;b<ListAllPortals_Array.length;b++){
                  if(ListAllPortals_NoAccent(ListAllPortals_Array[b]) == ListAllPortals_Array_NoAccent[a]){
                        ListAllPortals_SortedArrayCount++
                        ListAllPortals_SortedArray[ListAllPortals_SortedArrayCount] = ListAllPortals_Array[b];
                  }else{
                        continue;
                  }
            }
      }
      ListAllPortals_StubArray_NoAccent.sort();
      for(var a=0;a<ListAllPortals_StubArray_NoAccent.length;a++){
            for(var b=0;b<ListAllPortals_StubArray.length;b++){
                  if(ListAllPortals_NoAccent(ListAllPortals_StubArray[b]) == ListAllPortals_StubArray_NoAccent[a]){
                        ListAllPortals_SortedStubArrayCount++
                        ListAllPortals_SortedStubArray[ListAllPortals_SortedStubArrayCount] = ListAllPortals_StubArray[b];
                  }else{
                        continue;
                  }
            }
      }
      ListAllPortals_Alert("Création des nouvelles listes");
      ListAllPortals_CreateTemplates();
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Création des listes}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_PortalsListTemplate = "Test List";
window.ListAllPortals_StubPortalsListTemplate = "Test Stub List";
window.ListAllPortals_RandomPortalListTemplate = "Test Random List";
window.ListAllPortals_RandomStubPortalListTemplate = "Test Random Stub List";

window.ListAllPortals_CreateTemplates = function(){
      ListAllPortals_PortalsListTemplate = '{{colonnes|nombre=4|1=\n' 
                                         + "# [[Portail:Accueil|'''Portail des portails''']]\n";
      ListAllPortals_RandomPortalListTemplate = '{{#switch:{{{1|{{rand|1|'+ListAllPortals_SortedArray.length+'}}}}}\n';
      for(var a=0;a<ListAllPortals_SortedArray.length;a++){
            var Portal = ListAllPortals_SortedArray[a];
            var PortalName = ListAllPortals_SortedArray[a].split('Portail:')[1].replace(/ \(.*/g, "");
            var Stub = ( ListAllPortals_StubArray.indexOf(Portal)!=-1 ? "[[File:Nuvola_apps_kedit.png|10px|ébauche]] " : "");
            var Star = ( ListAllPortals_PdQArray.indexOf(Portal)!=-1 ? "[[File:Fairytale bookmark gold.png|10px|portail de qualité]] " : ( ListAllPortals_BPArray.indexOf(Portal)!=-1 ? "[[File:Fairytale bookmark silver light.png|10px|bon portail]] " : ""));
            ListAllPortals_PortalsListTemplate += '# '+Stub+Star+'[[' + Portal + '|' + PortalName + ']]\n';
            ListAllPortals_RandomPortalListTemplate += '|'+ (a+1) + '= [[' + Portal + '|' + PortalName + ']]\n';
      }
      ListAllPortals_PortalsListTemplate += "}}";
      ListAllPortals_RandomPortalListTemplate += '|NbMax = ' + ListAllPortals_SortedArray.length + '\n'
                                               + '|#default=[[Portail:Accueil|\'\'\'Portail des portails\'\'\']]\n'
                                               + '}}';
      ListAllPortals_StubPortalsListTemplate = '{{colonnes|nombre=4|1=\n';
      ListAllPortals_RandomStubPortalListTemplate = '{{#switch:{{{1|{{rand|1|'+ListAllPortals_SortedStubArray.length+'}}}}}\n';
      for(var a=0;a<ListAllPortals_SortedStubArray.length;a++){
            var Portal = ListAllPortals_SortedStubArray[a];
            var PortalName = ListAllPortals_SortedStubArray[a].split('Portail:')[1].replace(/ \(.*/g, "");
            ListAllPortals_StubPortalsListTemplate += '# [[' + Portal + '|' + PortalName + ']]\n';
            ListAllPortals_RandomStubPortalListTemplate += '|'+ (a+1) + '= [[' + Portal + '|' + PortalName + ']]\n';

      }
      ListAllPortals_StubPortalsListTemplate += "}}";
      ListAllPortals_RandomStubPortalListTemplate += '|NbMax = ' + ListAllPortals_SortedStubArray.length + '\n'
                                                   + '}}';
      ListAllPortals_Alert("Éditions");
      ListAllPortals_GetPage(ListAllPortals_ListURL, ListAllPortals_EditPageList);
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Mise à jour de [[Wikipédia:Liste des portails#Liste des portails]]}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_EditPageList = function(Req){
      while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}  
      document.body.innerHTML = Req.responseText;
      var ContenuPage = document.getElementById("wpTextbox1").value;
      var AncienResumeModif = document.editform.wpSummary.value;
      var Reg = new RegExp("\\{\\{colonnes\\|nombre=4\\|[^\\}]+\\}\\}", "ig");
      var Matches = ContenuPage.match(Reg);
      if(Matches != null && Matches.length == 1){
            var TexteFinal = ContenuPage.replace(Matches[0], ListAllPortals_PortalsListTemplate);
      }else{
            if(Matches == null){ 
                  alert("Pas trouvé le texte à remplacer " + Reg);
            }else{
                  alert("Trouvé plusieurs occurrences du texte à remplacer " + Reg);
            }
            document.getElementById ("wpTextbox1").value = "<!-------------------------------------------------------\n"
                                                   + ListAllPortals_PortalsListTemplate
                                                   + "-------------------------------------------------------->\n"
                                                   + ContenuPage ;
            return;
      }
      document.getElementById ("wpTextbox1").value = TexteFinal ;
      document.editform.wpSummary.value = AncienResumeModif + ListAllPortals_Resume ;
      document.editform.wpMinoredit.checked = "checked";
      document.editform.wpWatchthis.checked = "checked";
      ListAllPortals_SavePage(function(){ ListAllPortals_GetPage(ListAllPortals_StubListURL, ListAllPortals_EditPageStubList) });
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Mise à jour de [[Wikipédia:Liste des portails#Portails à améliorer]]}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_EditPageStubList = function(Req){
      while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}  
      document.body.innerHTML = Req.responseText;
      var ContenuPage = document.getElementById("wpTextbox1").value;
      var AncienResumeModif = document.editform.wpSummary.value;
      var Reg = new RegExp("\\{\\{colonnes\\|nombre=4\\|[^\\}]+\\}\\}", "ig");
      var Matches = ContenuPage.match(Reg);
      if(Matches != null && Matches.length == 1){
            var TexteFinal = ContenuPage.replace(Matches[0], ListAllPortals_StubPortalsListTemplate);
      }else{
            if(Matches == null){ 
                  alert("Pas trouvé le texte à remplacer " + Reg);
            }else{
                  alert("Trouvé plusieurs occurrences du texte à remplacer " + Reg);
            }
            document.getElementById ("wpTextbox1").value = "<!-------------------------------------------------------\n"
                                                         + ListAllPortals_StubPortalsListTemplate
                                                         + "-------------------------------------------------------->\n"
                                                         + ContenuPage ;
            return;
      }
      document.getElementById ("wpTextbox1").value = TexteFinal ;
      document.editform.wpSummary.value = AncienResumeModif + ListAllPortals_Resume ;
      document.editform.wpMinoredit.checked = "checked";
      document.editform.wpWatchthis.checked = "checked";
      ListAllPortals_SavePage(function(){ ListAllPortals_GetPage(ListAllPortals_RandomListURL, ListAllPortals_EditRandomPageList) });
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Mise à jour de {{m|Portail au hasard}}}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_EditRandomPageList = function(Req){
      while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}  
      document.body.innerHTML = Req.responseText;
      var ContenuPage = document.getElementById("wpTextbox1").value;
      var AncienResumeModif = document.editform.wpSummary.value;
      var Reg = new RegExp("\\<includeonly\\>[^\\>]+\\<\\/includeonly\\>", "ig");
      var Matches = ContenuPage.match(Reg);
      if(Matches != null && Matches.length == 1){
            var TexteFinal = ContenuPage.replace(Matches[0], "<includeonly>"+ListAllPortals_RandomPortalListTemplate+"</includeonly>");
      }else{
            if(Matches == null){ 
                  alert("Pas trouvé le texte à remplacer " + Reg);
            }else{
                  alert("Trouvé plusieurs occurrences du texte à remplacer " + Reg);
            }
            document.getElementById ("wpTextbox1").value = "<!-------------------------------------------------------\n"
                                                         + ListAllPortals_RandomPortalListTemplate
                                                         + "-------------------------------------------------------->\n"
                                                         + ContenuPage ;
            return;
      }
      document.getElementById ("wpTextbox1").value = TexteFinal ;
      document.editform.wpSummary.value = AncienResumeModif + ListAllPortals_Resume ;
      document.editform.wpMinoredit.checked = "checked";
      document.editform.wpWatchthis.checked = "checked";
      ListAllPortals_SavePage(function(){ ListAllPortals_GetPage(ListAllPortals_RandomStubListURL, ListAllPortals_EditRandomStubPageList) });
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Mise à jour de {{m|Portail ébauché au hasard}}}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_EditRandomStubPageList = function(Req){
      while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}  
      document.body.innerHTML = Req.responseText;
      var ContenuPage = document.getElementById("wpTextbox1").value;
      var AncienResumeModif = document.editform.wpSummary.value;
      var Reg = new RegExp("\\<includeonly\\>[^\\>]+\\<\\/includeonly\\>", "ig");
      var Matches = ContenuPage.match(Reg);
      if(Matches != null && Matches.length == 1){
            var TexteFinal = ContenuPage.replace(Matches[0], "<includeonly>"+ListAllPortals_RandomStubPortalListTemplate+"</includeonly>");
      }else{
            if(Matches == null){ 
                  alert("Pas trouvé le texte à remplacer " + Reg);
            }else{
                  alert("Trouvé plusieurs occurrences du texte à remplacer " + Reg);
            }
            document.getElementById ("wpTextbox1").value = "<!-------------------------------------------------------\n"
                                                         + ListAllPortals_RandomStubPortalListTemplate
                                                         + "-------------------------------------------------------->\n"
                                                         + ContenuPage ;
            return;
      }
      document.getElementById ("wpTextbox1").value = TexteFinal ;
      document.editform.wpSummary.value = AncienResumeModif + ListAllPortals_Resume ;
      document.editform.wpMinoredit.checked = "checked";
      document.editform.wpWatchthis.checked = "checked";
      ListAllPortals_SavePage(function(){ ListAllPortals_GetPage(ListAllPortals_NumberOfPortalsURL, ListAllPortals_EditNumberOfPortals) });
}


//</nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Mise à jour de {{m|Nombre de portails}}}}<source lang=javascript>//<pre><nowiki>

window.ListAllPortals_EditNumberOfPortals = function(Req){
      while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}  
      document.body.innerHTML = Req.responseText;
      var ContenuPage = document.getElementById("wpTextbox1").value;
      var AncienResumeModif = document.editform.wpSummary.value;
      var Reg = new RegExp(".*\\<noinclude\\>", "ig");
      var Matches = ContenuPage.match(Reg);
      if(Matches != null && Matches.length == 1){
            var TexteFinal = ContenuPage.replace(Matches[0], (ListAllPortals_SortedArray.length+1) + "<noinclude>");
      }else{
            if(Matches == null){ 
                  alert("Pas trouvé le texte à remplacer " + Reg);
            }else{
                  alert("Trouvé plusieurs occurrences du texte à remplacer " + Reg);
            }
            document.getElementById ("wpTextbox1").value = "<!-------------------------------------------------------\n"
                                                         + (ListAllPortals_SortedArray.length+1) + "<noinclude>"
                                                         + "-------------------------------------------------------->\n"
                                                         + ContenuPage ;
            return;
      }
      document.getElementById ("wpTextbox1").value = TexteFinal ;
      document.editform.wpSummary.value = AncienResumeModif + ListAllPortals_Resume + " : " +  (ListAllPortals_SortedArray.length+1);
      document.editform.wpMinoredit.checked = "checked";
      document.editform.wpWatchthis.checked = "checked";
      ListAllPortals_SavePage();
}

// </nowiki></pre></source>{{Boîte déroulante fin}}{{Boîte déroulante début|titre=Lancement}}<source lang=javascript>//<pre><nowiki>

if(mw.config.get('wgNamespaceNumber')==2 || mw.config.get('wgNamespaceNumber')== 8) $(ListAllPortals_AddLinks);


//</nowiki></pre></source>{{Boîte déroulante fin}}|}}