User:Ashlux/test.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Ashlux/test. |
//////////////////////////////////////////
// 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);