Jump to content

User:Ashlux/test.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ashlux (talk | contribs) at 13:17, 23 May 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
//////////////////////////////////////////
/**** Add tab as menu ****/
/**** The CSS for this to work is on the talk page. ****/

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

// 

/**** Add generic tab ****/

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function changePersonalLinks()
{
    if(!document.getElementById) return;
    // remove the "my" bits
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions';
}

function addClock()
{
    var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    addlilink(toplinks, '#', '', 'utcdate');
    showTime();
}

function showTime()
{
    var timerID;
    var now = new Date();
    var timeValue = now.toUTCString().replace(/GMT/, "UTC");
    document.getElementById('utcdate').firstChild.innerHTML = timeValue;
    timerID = setTimeout('showTime()', 100);
}

function asdf() {

  changePersonalLinks();
  addClock();  

  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];

        addlimenu(tabs, 'afd actions', 'afda');
        var afda = document.getElementById('afda').getElementsByTagName('ul')[0];
        addlilink(afda, 'javascript:closeafd("keep", "")', 'keep', '');
        addlilink(afda, 'javascript:closeafd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'merge', '');
        addlilink(afda, 'javascript:closeafd("redirect", " to [[" + prompt("Redirect to?") + "]]")', 'redir', '');
        addlilink(afda, 'javascript:closeafd("transwiki", " to " + prompt("Transwiki to?"))', 'trans', '');
        addlilink(afda, 'javascript:closeafd("transwiki", " to Wiktionary")', 'wikt', '');
        addlilink(afda, 'javascript:closeafd("speedy delete", "")', 'speedy', '');
        addlilink(afda, 'javascript:closeafd("delete", "")', 'del', '');
        addlilink(afda, 'javascript:closeafd(prompt("Result?"), "")', 'other', '');
        addlilink(tabs, 'javascript:replace()', 'replace', '');

//  addlilink(tabs, 'http://www.ashlux.com/', 'Ashlux.com', 'ashlux.com');

//  addlimenu(tabs, 'bcrat', 'bfunc');
//  var bfunc = document.getElementById('bfunc').getElementsByTagName('ul')[0];


//  addlilink(bfunc, 'asdf', 'make sysop', 'sysop');
}

addOnloadHook(asdf);