Użytkownik:Datrio/monobook.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
M |
|||
Linia 37: | Linia 37: | ||
console.log("4"); |
console.log("4"); |
||
} |
} |
||
console.log(wgPageName); |
|||
if(wgPageName=='Specjalna:Blockip') addOnloadHook(blockreasons); |
if(wgPageName=='Specjalna:Blockip') addOnloadHook(blockreasons); |
||
Wersja z 11:51, 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');
console.log("1");
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);
console.log("2");
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));
}
}
}console.log("3");
selsel.appendChild(groupop[gpn]);
var reasonparent = document.getElementById('blockip').wpBlockReason.parentNode;
reasonparent.appendChild(document.createElement('br'));
reasonparent.appendChild(selsel);
console.log("4");
}
console.log(wgPageName);
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;
}
//****************************************************************************************************************