User:TheParanoidOne/monobook.js

/* Tabs at bottom of page as well */ function morelinks { var tabs = document.getElementById('p-cactions').childNodes[3].cloneNode(true); tabs.id = 'mytabs'; tabs.setAttribute("class", "") var listitems = tabs.getElementsByTagName('LI'); for (i=0;i<listitems.length;i++) { if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id; } document.getElementById('column-content').appendChild(tabs); } if (window.addEventListener) window.addEventListener("load",morelinks,false); else if (window.attachEvent) window.attachEvent("onload",morelinks);

function fillEditSummaries {

var label = document.getElementById("wpSummaryLabel");

if (label == null) { return; };

var summaryCombo = document.createElement('select'); summaryCombo.setAttribute('id','stdSummaries'); summaryCombo.setAttribute('onchange','onStdSummaryChange'); label.appendChild(summaryCombo);

var request;

try { request = new XMLHttpRequest; } catch(e) { request = new ActiveXObject("Msxml2.XMLHTTP"); }

request.open("GET", "/w/index.php?title=User:TheParanoidOne/EditSummaries&action=raw&ctype=text/plain");

request.onreadystatechange = function { if(request.readyState == 4) { var combo = document.getElementById("stdSummaries"); var lines = request.responseText.split("\n"); var i;     var element; var delimiter; var value;

for(i = 0; i < lines.length; i++) { delimiter = lines[i].indexOf("|"); element = document.createElement('option');

if (lines[i].indexOf('* ') == -1) { // Separator element.setAttribute('value',''); element.innerHTML = lines[i]; } else if (delimiter < 0) { // Item with no piping element.setAttribute('value', lines[i].substring(2)); element.innerHTML = lines[i] } else { // Item with piping element.setAttribute('value', lines[i].substring(delimiter+1)); element.innerHTML = lines[i].substring(0, delimiter); }       combo.appendChild(element); }   }  }

request.send(null); }

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

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

function fillDeleteReasons{ if (document.getElementById("deleteconfirm") == null) { // Don't do anything if this is not a deletion page return; }

var reasonTextBox = document.getElementById('wpReason'); if (reasonTextBox == null) return;

var reasonsCombo = document.createElement('select'); reasonsCombo.setAttribute('id','delReasons'); reasonsCombo.setAttribute('onchange','onDynamicComboChange(this.id, "wpReason")'); reasonTextBox.parentNode.insertBefore(reasonsCombo, reasonTextBox);

// TODO: Extract this lot into a separate function

var request; try { request = new XMLHttpRequest; } catch(e) { request = new ActiveXObject("Msxml2.XMLHTTP"); }

request.open("GET", "/w/index.php?title=User:TheParanoidOne/DeleteReasons&action=raw&ctype=text/plain");

request.onreadystatechange = function { if(request.readyState == 4) { var lines = request.responseText.split("\n"); var element, delimiter;

for(var i = 0; i < lines.length; i++) { delimiter = lines[i].indexOf("|"); element = document.createElement('option');

if (delimiter < 0){ // Item with no piping element.setAttribute('value', lines[i]); element.textContent = lines[i] } else { //Item with piping element.setAttribute('value', lines[i].substring(delimiter+1)); element.textContent = lines[i].substring(0, delimiter); }       reasonsCombo.appendChild(element); }   }  }

request.send(null); }

function onDynamicComboChange(source, target) { var combo = document.getElementById(source); var value = combo.options[combo.selectedIndex].value;

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

function loadFunc { fillEditSummaries; fillDeleteReasons; }

window.onload = loadFunc;

// installation of the wikEd editing page extension

// install User:Cacycle/diff text diff code document.write(' ');

// install User:Pilaf/Live_Preview page preview tool document.write(' ');

// install RegExTypoFix common typo fixer document.write(' ');

// install User:Cacycle/wikEd international translation here

// install User:Cacycle/wikEd editing page extension document.write(' ');