User:PeterL/exasperation.js

/* Adds a list of quick statements to the edit tools at the bottom of the edit screen (Where it says "Sign your username: &#126;~", but at the bottom). Click where it says "Exasperated remarks" to get a list. Add more to User:PeterL/ex. Code from MediaWiki:Gadget-smileylist.js. PeterL, 09:25, 29 May 2012 (UTC) var exasperationList; function showExasperationList { vis = (exasperationList.style.display == "block"); if (!vis) {   var toolbar = document.getElementById('editpage-specialchars'); toolbar.appendChild(exasperationList); exasperationList.style.display = "block"; } else { exasperationList.style.display = "none"; } } function exasperations2 { var toolbar = document.getElementById('editpage-specialchars'); if (!toolbar) { return false; } var textbox = document.getElementById('wpTextbox1'); var exasperationspan = document.createElement("span"); exasperationspan.innerHTML = "Exasperated remarks" exasperationspan.id = "edittools_exasperations" exasperationspan.title = "Exasperated remarks"; exasperationspan.style.cursor = "pointer"; exasperationspan.onclick = function { showExasperationList; return false; }; toolbar.appendChild(exasperationspan); exasperationList = document.createElement("div"); exasperationList.id = "exasperationList"; exasperationList.style.position = "static"; /*populate exasperation box*/ var req = false; if (window.XMLHttpRequest) { req = new XMLHttpRequest; } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req) { req.open("GET", wgServer + wgScript + "?title=User:" + wgUserName + "/ex", true); //req.overrideMimeType("text/xml"); req.onreadystatechange = function {     if (req.readyState==4 && req.status == 200) { var xmlhack = document.createElement("div"); xmlhack.innerHTML = req.responseText; var divs = xmlhack.getElementsByTagName("div"); //var divs = req.responseXML.documentElement.getElementsByTagName("div"); var bci; var i;       for (i=0; i0) {         addExasperation2(exasperationList,ps.item(0)); }     }    }    req.send(null); } exasperationList.style.display = "none"; return true; } function addExasperation2(parent, item) { item.onclick = function { insertTags(item.innerHTML,,); return false; }; item.style.margin="4px"; item.style.cursor = "pointer"; parent.appendChild(item); } hookEvent("load", exasperations2);