User:Animum/addlimenu.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
importStylesheet('User:Animum/addlimenu.css');
 
function addlilink(tabs, href, name, id, title, key){
    var na = document.createElement('a');
    na.href = href;
    na.appendChild(document.createTextNode(name));
    na.style.cssText = 'cursor:pointer';
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(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
    akeytt();
    return li;
}
 
function addlimenu(tabs, name, id, href, position) {
    var na, mn;
    var li;
 
    if (!id)  id = name;
 
    na = document.createElement("a");
    na.appendChild(document.createTextNode(name));
    na.onclick = href;
    na.style.cssText = 'cursor:pointer';
    mn = document.createElement("ul");
    li = document.createElement("li");
    li.appendChild(na);
    li.appendChild(mn);
    if (id) li.id = id;
    li.className = 'tabmenu';
 
    if (position) {
        tabs.insertBefore(li, position);
    } else {
        tabs.appendChild(li);
    }
 
    return mn;  // useful because it gives us the <ul> to add <li>s to
}