Discussion utilisateur:Dr Brains/MoveDeluxe.js

/* Javascript qui s'active lors du renommage d'une page.

Fournit des résumés de modification prédéfinis (personnalisables, voir plus bas)


Documentation : Projet:JavaScript/Notices/MoveDeluxe

Licence : Domaine Public


  • /

//

//<pre><nowiki>


if(typeof(MoveDeluxe_Reason)=='undefined'){ ////// PARTIE PERSONNALISABLE ///////////////

     window.MoveDeluxe_Reason = [
       { text : "Typo",      reason : "Conventions typographiques" },
       { text : "Ortho",     reason : "Orthographe"                },
       { text : "Namespace", reason : "Mauvais espace de noms"     },
       { text : "Précision", reason : "Titre imprécis"             }
     ];

} //////////////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE /////


window.MoveDeluxe = function(){
     var MoveForm = document.getElementById('movepage');
     if(!MoveForm) return;
     var TextArea = document.getElementById('wpReason');
     if(TextArea) MoveDeluxe_GetReasons();
}

window.MoveDeluxe_GetReasons = function(){
     if(typeof(MoveDeluxe__GetSiteCustom)==="function") try{ MoveDeluxe__GetSiteCustom(); }catch(e){ }
     if(typeof(MoveDeluxe__GetUserCustom)==="function") try{ MoveDeluxe__GetUserCustom(); }catch(e){ }
     if(MoveDeluxe_Reason.length < 1 ) return;
     var Reasons = [];
     for(var a=0,l=MoveDeluxe_Reason.length;a<l;a++){
          if(typeof(MoveDeluxe_Reason[a]) == "string")
               Reasons[a] = { text : MoveDeluxe_Reason[a], reason : MoveDeluxe_Reason[a] };
          else
               Reasons[a] = MoveDeluxe_Reason[a];
     }
     var TextArea = document.getElementById('wpReason');
     var NewSelect = document.createElement('select');
     NewSelect.id = 'ReasonSelect';
     TextArea.parentNode.insertBefore(NewSelect, TextArea);
     NewSelect.onchange = function(){
          var Selected = this.getElementsByTagName('option');
          for(var a=0;a<Selected.length;a++){
               if(Selected[a].selected){
                    var TextSelected = Selected[a].value;
                    document.getElementById('wpReason').value = TextSelected;
                    document.getElementById('wpReason').focus();
               }
          }
     }
     NewSelect.innerHTML += '<option value=""></option>';
     for(var a=0;a<Reasons.length;a++){
           NewSelect.innerHTML += '<option value="'+Reasons[a].reason+'" '
                                 +'>'+Reasons[a].text+'</option>';

     }
}

///////////////////////////////////////////////////// Lancements

if(mw.config.get('wgCanonicalSpecialPageName')=="Movepage"){ 
      $(MoveDeluxe);
}
//</nowiki></pre>
Retour à la page de l’utilisateur « Dr Brains/MoveDeluxe.js ».