Użytkownik:Splarka/monobook.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(nowa strona)
 
M
Linia 32: Linia 32:
selsel.appendChild(groupop[gpn]);
selsel.appendChild(groupop[gpn]);


var reasonparent = document.getElementById('mw-bi-reason').parentNode;
var reasonparent = document.getElementById('blockip').wpBlockReason.parentNode;
reasonparent.appendChild(document.createElement('br'));
reasonparent.appendChild(document.createElement('br'));
reasonparent.appendChild(selsel);
reasonparent.appendChild(selsel);
Linia 39: Linia 39:


function blockreasonchange() {
function blockreasonchange() {
if(document.getElementById('blockreasonsel').selectedIndex == 0) return
var selsel = document.getElementById('blockreasonsel');
document.getElementById('mw-bi-reason').value = document.getElementById('blockreasonsel').options[document.getElementById('blockreasonsel').selectedIndex].value;
var reasonbox = document.getElementById('blockip').wpBlockReason;
if(selsel.selectedIndex == 0) return
reasonbox.value = selsel.options[selsel.selectedIndex].value;
}
}
//****************************************************************************************************************
//****************************************************************************************************************

Wersja z 11:25, 25 kwi 2007

//****************************************************************************************************************
function blockreasons() {
  if(!document.getElementById('ipbreason-dropdown-js')) return;
  var reasondiv = document.getElementById('ipbreason-dropdown-js');
  var reasons = document.getElementById('ipbreason-dropdown-js').firstChild.nodeValue.split('\n');

  var selsel = document.createElement('select');
  selsel.setAttribute('onchange','blockreasonchange();');
  selsel.setAttribute('id','blockreasonsel');
  var firstop = document.createElement('option');  
  firstop.appendChild(document.createTextNode('Predefined block reasons'));
  selsel.appendChild(firstop);

  var groupop = new Array(); var gpn = 0;
  var op = new Array(); var opn = 0;
  for(var i in reasons) {
    if(reasons[i].substring(0,1)=='*') {
    if(reasons[i].substring(0,2)=='**') {
      op[opn] = document.createElement('option');
      op[opn].setAttribute('value',reasons[i].substring(2));
      op[opn].appendChild(document.createTextNode(reasons[i].substring(2)));
      groupop[gpn].appendChild(op[opn]);
      opn++;
    } else {
      if(groupop[gpn]) selsel.appendChild(groupop[gpn])
      gpn++;
      groupop[gpn] = document.createElement('optgroup');
      groupop[gpn].setAttribute('label',reasons[i].substring(1));
    }
    }
  }
  selsel.appendChild(groupop[gpn]);

  var reasonparent = document.getElementById('blockip').wpBlockReason.parentNode;
  reasonparent.appendChild(document.createElement('br'));
  reasonparent.appendChild(selsel);
}
if(wgPageName=='Specjalna:Blockip') addOnloadHook(blockreasons);

function blockreasonchange() {
  var selsel = document.getElementById('blockreasonsel');
  var reasonbox = document.getElementById('blockip').wpBlockReason;
  if(selsel.selectedIndex == 0) return
  reasonbox.value = selsel.options[selsel.selectedIndex].value;
}
//****************************************************************************************************************