For faster navigation, this Iframe is preloading the Wikiwand page for Utilisateur:Dr Brains/ArticlesRecents.js.

Utilisateur:Dr Brains/ArticlesRecents.js

/*<noinclude>((Catégorisation JS|ArticlesRecents))


* Documentation : voir [[Modèle:Articles récents/Documentation]]

	
* Licence : Domaine public
	
</noinclude>

== Code JavaScript ==

((Boîte déroulante/début|titre=Articles récents))<!--
*/
// --><source lang=javascript>
//<pre><nowiki>

var ArticlesRecents_TailleListe = 10;

var ArticlesRecents_ModeleDefautDebut = '((Articles récents\n'
                  + '|pageportail=$1\n'
                  + '|catégorie=$2\n'
                  + '|nbMax=$3\n'
                  + '|defilant=oui\n'
                  + '|hauteur=250\n'
                  + '|listeRecents=\n'
                  + '$4\n'
                  + '))\n'

var ArticlesRecents_DebutListeRecents = '<!-- Ce tableau est créé automatiquement par un robot. Articles Récents DEBUT -->\n';

var ArticlesRecents_FinListeRecents = '<!-- Ce tableau est créé automatiquement par un robot. Articles Récents FIN -->\n'

var ArticlesRecents_ResumeModif = 'Mise à jour du modèle [[Modèle:Articles récents|((Articles récents))]]';


if( (mw.config.get('wgAction')!="edit")&&(mw.config.get('wgAction')!="submit") ){
     $(ArticlesRecents_init);
}

// recherche des modèles ((Articles récents)) de la page et ajout des liens de mise à jour

var ArticlesRecents_TemplateCount = 0;
function ArticlesRecents_init(){
     var Cadres = document.getElementsByTagName('div');
     for(s=0;s<Cadres.length;s++){
            if( $(Cadres[s]).hasClass('categoryRecentChanges') ){
                  ArticlesRecents_TemplateCount++
                  Cadres[s].id = 'categoryRecentChanges_'+ArticlesRecents_TemplateCount;
                  var ParamCategorie = Cadres[s].firstChild.innerHTML;
                  var ParamPage = Cadres[s].firstChild.title;
                  var NewButton = '<a href="javascript:ArticlesRecents_Update(\'categoryRecentChanges_'
                  +ArticlesRecents_TemplateCount+ '\',\''+ParamPage.replace(/'/g,"\\'")+'\');" title="Cliquer pour  mettre à jour l\'analyse de la catégorie ' + ParamCategorie + ' sur la page '+ParamPage+'" ><img height="50" width="50" src="//upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Crystal_Clear_action_exit.svg/50px-Crystal_Clear_action_exit.svg.png" alt="Démarrer la mise à jour"/></a>' ;
                  Cadres[s].innerHTML = NewButton + Cadres[s].innerHTML;
            }
     }
}

function ArticlesRecents_Update(id, Page){
     if(!id) return;
     if(!Page) Page = mw.config.get('wgPageName');
     var Cadre = document.getElementById(id);
     if(!Cadre){
          alert('Il y a un problème avec le modèle ((Articles récents))');
          window.location.reload();
     }
     var Bouton = Cadre.getElementsByTagName('span')[0];
     var ParamCategorie = Bouton.innerHTML;
     var ParamPage = Bouton.title;
     var TailleListe = Bouton.className;
     if((!TailleListe)||(TailleListe=='')) TailleListe = ArticlesRecents_TailleListe;
// /*
               var Suretcertain = confirm('Paramètres :'
                                        + '\n* Page à mettre à jour : -( ' + ParamPage + ' )- '
                                        + '\n* Catégorie : -( ' + ParamCategorie + ' )- '
                                        + '\n* Maximum : -( ' + TailleListe + ' )- '
                                        + '\n\n Lancer la mise à jour ?' );
               if(!Suretcertain) window.location.reload();
// */
     var NewCategory = [];
     
     var api = new mw.Api();
     api.get({
          action  : 'query',
          list    : 'categorymembers',
          cmdir   : 'descending',
          cmsort  : 'timestamp',
          cmlimit : TailleListe,
          cmtitle : ParamCategorie
     }).then( function ( data ) {
          var categorymembers = data.query.categorymembers;
          if ( categorymembers ) {
               for(var a=0,l=categorymembers.length;a<l;a++){
                    var TitrePage = categorymembers[a].title;
                    var NS = parseInt(categorymembers[a].ns);
                    if(NS === 0) NewCategory.push(TitrePage);
               }
               ArticlesRecents_Edit(id, ParamPage, ParamCategorie, TailleListe, NewCategory);
          }
     } );
}

function ArticlesRecents_Edit(id, ParamPage, ParamCategorie, TailleListe, NewRecents){
     var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(ParamPage) + '&action=edit';
     $.ajax({url : URL, complete : function(Req){
               while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}
               ajaxResponse = Req.responseText;
               document.body.innerHTML = ajaxResponse;
               var ContenuPage = document.getElementById("wpTextbox1").value;
               var AncienResumeModif = document.editform.wpSummary.value;

               var NouvelleListeRecents = ArticlesRecents_DebutListeRecents;
               for(var r=0;r<NewRecents.length;r++){
                    NouvelleListeRecents += '# [[' + NewRecents[r] + ']]\n';
               }
               NouvelleListeRecents += ArticlesRecents_FinListeRecents;
               if(
                  (ContenuPage.indexOf(ArticlesRecents_DebutListeRecents)!=-1) &&
                  (ContenuPage.indexOf(ArticlesRecents_FinListeRecents)!=-1) ){
                    var debutTexte = ContenuPage.substring(0, ContenuPage.indexOf(ArticlesRecents_DebutListeRecents));
                    AncienModele = ContenuPage.substring(0, ContenuPage.indexOf(ArticlesRecents_FinListeRecents)) + ArticlesRecents_FinListeRecents;
                    AncienModele = AncienModele.replace(debutTexte, "");
                    finTexte = ContenuPage.split(debutTexte).join('').split(AncienModele).join('');
                    var TexteFinal = debutTexte + NouvelleListeRecents + finTexte;
/*
                    alert('Début Texte : \n\n' + debutTexte);
                    alert('NouvelleListeRecents : \n\n' + NouvelleListeRecents);
                    alert('Fin Texte : \n\n' + finTexte);
*/
               }else{
                    var TexteFinal = ArticlesRecents_ModeleDefautDebut;
                    TexteFinal = TexteFinal.split('$1').join(ParamPage);
                    TexteFinal = TexteFinal.split('$2').join(ParamCategorie);
                    TexteFinal = TexteFinal.split('$3').join(TailleListe);
                    TexteFinal = TexteFinal.split('$4').join(NouvelleListeRecents);
               }
               document.getElementById ("wpTextbox1").value = TexteFinal;
               document.editform.wpSummary.value = AncienResumeModif + ArticlesRecents_ResumeModif ;
               var SurEtCertain = confirm('Publier la modification ?');
               if(SurEtCertain) document.editform.submit();;
          }
     });
}

//</nowiki></pre></source>((Boîte déroulante/fin))
{{bottomLinkPreText}} {{bottomLinkText}}
Utilisateur:Dr Brains/ArticlesRecents.js
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?