MediaWiki talk:Common.js

/** Deletion reasons ***************************************************** * Adds drop down box to delete page for choosing pre-made deletion reasons called * from Template:Dltreasons */ var xhrReasons;

addOnloadHook(fillDeleteReasons, false);

function fillDeleteReasons {  var label = document.getElementById("wpReason");

if(label == null) {      return; }

label = document.getElementById("contentSub");

if(label == null) {      return; }

if (window.location.href.indexOf("action=delete") == -1) {      return; }

if(typeof(disableDeletionReasons) != 'undefined' && disableDeletionReasons) {       return; }

var comboString = " "; comboString += " "; label.innerHTML += comboString;

var request = getRequest; xhrReasons = request; request.open("GET", "http://wiki.ffxiclopedia.org/index.php?title=Template:Dltreasons&action=raw&ctype=text/plain"); request.onreadystatechange = onRSCReasons; request.send(null); }

function onStdReasonChange {  var combo = document.getElementById("stdReasons"); var value = combo.options[combo.selectedIndex].value;

if(value != "") document.getElementById("wpReason").value = value; }

function getRequest {  var agt = navigator.userAgent.toLowerCase;

if (agt.indexOf('msie')!=-1 && agt.indexOf('msie 7')==-1 && document.all && agt.indexOf('opera')==-1 && agt.indexOf('mac')==-1) return new ActiveXObject("Msxml2.XMLHTTP");

var request = new XMLHttpRequest; return request; }

function onRSCReasons {   fillCombo(xhrReasons, 'stdReasons'); }

function fillCombo(request, comboid) {      if(request.readyState == 4) {          var combo = document.getElementById(comboid); var lines = request.responseText.split("\n");

for(var i = 0; i < lines.length; i++) {              var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : ""; //combo.innerHTML += "" + lines[i] + " "; var option = document.createElement('option'); option.setAttribute('value', value); option.appendChild(document.createTextNode(lines[i])); combo.appendChild(option); }      }   }