Utilisateur:Dr Brains/MoveDeluxe.js
Apparence
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) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./*
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
{{Catégorisation JS|MoveDeluxe}}
*/
//<source lang=javascript>//<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></source>