User:Year2000Prob/Y2P.MediaWiki.js

Y2P.AddPortletItem = function(Item) { if (arguments.length == 0) return; var li = document.createElement("li"); var a = document.createElement("a"); if (typeof Item.url == "function") { a.onclick = Item.url; a.href = "javascript:void(0)"; } else a.href = Item.url; a.appendChild(document.createTextNode(Item.text)); if (!Item.overwrite) { if (Item.id) li.id = Item.id; li.appendChild(a)}; if (Item.overwrite) { document.getElementById(Item.overwrite).innerHTML = ""; if (Item.id) document.getElementById(Item.overwrite).id = Item.id; document.getElementById(Item.id).appendChild(a); } else if (Item.before) document.getElementById(Item.before).parentNode.insertBefore(li, document.getElementById(Item.before)); else if (Item.addTo) document.getElementById(Item.addTo).getElementsByTagName("ul")[0].appendChild(li); else if (Item.addToRaw) Item.addToRaw.appendChild(li); else throw new Error("Please specify somewhere to PUT your item(s)!"); return arguments.callee};

Y2P.Portlet = function { this.init = function(Id, Name) { var portlet = document.createElement("div"); portlet.className = "portlet"; portlet.id = Id; var header = document.createElement("h5"); header.appendChild(document.createTextNode(Name)); portlet.appendChild(header); var pBody = document.createElement("div"); pBody.className = pBody; portlet.appendChild(pBody); var list = document.createElement("ul"); pBody.appendChild(list); document.getElementById("column-one").appendChild(portlet); portlet.addItem = function(Item) { if (arguments.length == 0) return; Y2P.AddPortletItem({       text: Item.text,        url: Item.url,        id: Item.id || null,        addTo: this.id      }); return arguments.callee}; return portlet}; return this.init.apply(this, arguments)};

Y2P.ChangeActions = function(labels) { for (var id in labels) if (document.getElementById("ca-"+id) && labels[id].length > 0) // check that the label isn't an empty string document.getElementById("ca-"+id).childNodes[0].innerHTML = labels[id]; if (wgAjaxWatch) for (var i=0,j="watch,watching,unwatch,unwatching".split(",");i<j.length;i++) wgAjaxWatch[j[i]+"Msg"] = labels[j[i]]};