MediaWiki:Gadget-ProtectCreation.js

Un article de Wikipèdia, l'enciclopèdia liura.

Nòta : Aprèp aver publicat la pagina, vos cal forçar son recargament complet tot ignorant lo contengut actual de l'amagatal de vòstre navigador per veire los cambiaments : Mozilla / Firefox / Konqueror / Safari : mantenètz la tòca Majuscula (Shift) en clicant lo boton Actualizar (Reload,) o quichatz Maj-Ctrl-R (Maj-Cmd-R sus Apple Mac) ; Internet Explorer / Opera : mantenètz la tòca Ctrl en clicant lo boton Actualizar o quichatz Ctrl-F5.

/*
  * '''Proteccion a la creacion'''
  * 
  * Permet als administrators de protegir automaticament la recreacion d'una pagina
  * en l'ajustant a [[Wikipèdia:Paginas protegidas a la creacion|WP:PPC]] al moment de la confirmacion de supression
  * 
  * Autor : [[fr:Utilisateur:Seb35|Seb35]]
  * Data de darrièra revision : 6 de septembre de 2007
  */

function protectCreation() {
  if (!document.getElementById('deleteconfirm')) return;
  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(' Protegir aquesta pagina de la recreacion'));
  td.appendChild(label);
  
  document.getElementById('wpConfirmB').setAttribute('tabindex', '4');
  document.getElementById('wpConfirmB').setAttribute('onclick', 'protectCreationExec();');
}
if(mw.config.get('wgAction') == 'delete') $(protectCreation);
if(document.URL.indexOf('protectcreation=') != -1) $(protectCreationWindow);

function protectCreationExec() {
  if(!document.getElementById('wpProtectCreation').checked) return;
  var d = new Array('Genièr','Febrièr','Març','Abril','Mai','Junh','Julhet','Agost','Setembre','Octobre','Novembre','Decembre');
  var hui = new Date();
  var adresse = new String('//oc.wikipedia.org/w/index.php?title=Wikipèdia:Pages_protegidas_a_la_creacion/'+d[hui.getMonth()]+'_'+hui.getFullYear()+'&action=edit&protectcreation='+mw.config.get('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(mw.config.get('wgPageName').substr(0,40) != 'Wikipèdia:Paginas_protegidas_a_la_creacion/') 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 += '* {{Títol protegit|' + page + '}}';
  document.editform.wpSave.click();
}