Utilisateur:Alchemica/monobook.js

Un article de Wikipédia, l'encyclopédie libre.

Note : Après avoir publié la page, vous devrez forcer son rechargement pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, Internet Explorer / Opera : Ctrl-F5, Safari : Cmd-R.

/*
  * '''Protection à la création'''
  * 
  * Permet aux administrateurs de protéger automatiquement la recréation d'une page
  * en l'ajoutant à [[Wikipédia:Pages protégées à la création|WP:PPC]] lors de la confirmation de suppression
  * 
  * Auteur : [[Utilisateur:Seb35|Seb35]]
  * Date de dernière révision : 6 septembre 2007
  */
 
// Code :<source lang="javascript" line="true">
function protectCreation() {
  var td = document.getElementById('wpWatch').parentNode;
  td.appendChild(document.createElement('br'));
  var label = document.createElement('label');
  var input = document.createElement('input');
  input.setAttribute('name', 'wpProtectCreation');
  input.setAttribute('type', 'checkbox');
  input.setAttribute('id', 'wpProtectCreation');
  input.setAttribute('tabindex', '3');
  label.appendChild(input);
  label.appendChild(document.createTextNode(' Protéger cette page de la recréation'));
  td.appendChild(label);
 
  document.getElementById('wpConfirmB').setAttribute('tabindex', '4');
  document.getElementById('wpConfirmB').setAttribute('onclick', 'protectCreationExec();');
}
if(wgAction == 'delete' && document.getElementById('deleteconfirm')) addOnloadHook(protectCreation);
if(document.URL.indexOf('protectcreation=') != -1) addOnloadHook(protectCreationWindow);
 
function protectCreationExec() {
  if(!document.getElementById('wpProtectCreation').checked) return;
  var d = new Array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre');
  var hui = new Date();
  var adresse = new String('http://fr.wikipedia.org/w/index.php?title=Wikipédia:Pages_protégées_à_la_création/'+d[hui.getMonth()]+'_'+hui.getFullYear()+'&action=edit&protectcreation='+wgPageName);
  var fenetre = window.open(encodeURI(adresse), 'fProtectCreation', 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=800,height=200');
  fenetre.focus();
}
 
function protectCreationWindow() {
  if(wgPageName.substr(0,40) != 'Wikipédia:Pages_protégées_à_la_création/') return;
  window.scrollTo(0,document.documentElement.clientHeight);
  if(document.URL.indexOf('protectcreation=') == -1) return;
  var page = decodeURI(document.URL.substr(document.URL.indexOf('protectcreation=')+16).replace(/_/g, ' '));
  document.editform.wpSummary.value = '+' + page;
  if(page.indexOf(':')!=-1) page = page.substr(page.indexOf(':')+1) + '|ns=' + page.substr(0, page.indexOf(':'));
  document.editform.wpTextbox1.value += '* {{Titre protégé|' + page + '}}';
  document.editform.wpSave.click();
}
//Fin du code</source>[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]]