Wikipedia:WikiProject User scripts/Scripts/Add LI link

From Wikipedia, the free encyclopedia

// Note: There is now a mostly equivalent function, addPortletLink(), included as a part of MediaWiki in wikibits.js. Please consider using it instead. The only major difference is that the first argument to addPortletLink() should be the id attribute of an element containing the list, not the DOM node of the list itself.


function addlilink(node, href, text, id, tooltip, accesskey) {
        // the code below is mostly copied from addPortletLink()

        var link = document.createElement( "a" );
        link.appendChild( document.createTextNode( text ) );
        link.href = href;

        var item = document.createElement( "li" );
        item.appendChild( link );
        if ( id ) item.id = id;

        if ( accesskey ) {
                link.setAttribute( "accesskey", accesskey );
                tooltip += " ["+accesskey+"]";
        }
        if ( tooltip ) {
                link.setAttribute( "title", tooltip );
        }
        updateTooltipAccessKeys( new Array( link ) );

        node.appendChild( item );

        return item;
}

//