User:Mike Dillon/Scripts/addlilink.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// Requires: [[User:Mike Dillon/Scripts/easydom.js]] // <pre><nowiki> // // Add a new LI element to a list (usually a list of tabs) // function addlilink(parent, url, name, id, title, key, after) { var e; with (easyDOM) { if (url == null && name != null) { if (name.nodeType != null) { e = name; } else { e = document.createTextNode(name); } } else { e = a({ "href": url }, name); } var listItem = li(e); if(id) { listItem.id = id; } // If the "after" argument was provided but was not a node, // find the node by id if (after && !after.nodeType) { after = document.getElementById(after); } // If there is a node to be placed before, use it, otherwise append to the end if (after) { parent.insertBefore(listItem, after); } else { parent.appendChild(listItem); } } // Set up access keys and title, if any if(url && id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } // re-render the title and accesskeys from existing code in wikibits.js if (ta[id] && window.doneOnloadHook) { akeytt(id); } } return e; } // </nowiki></pre>