MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ // ================================================== // Begin default dropdown block reasons - Splarka // ================================================== 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=0;i<reasons.length;i++) { 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=='Special: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; } // ================================================== // End default dropdown block reasons // ==================================================