Jump to content

User:Extremecircuitz/toolbarTweaks.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Extremecircuitz (talk | contribs) at 22:47, 21 October 2007 (Created page with '// function to get toolbar by id for variables function toolbar(toolbarId, isSearchbox) { if (isSearchBox == 'true') { document.getElementById(toolbarId); }...'). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
// function to get toolbar by id for variables
function toolbar(toolbarId, isSearchbox) {
  if (isSearchBox == 'true') {
    document.getElementById(toolbarId);
  } else {
    document.getElementById(toolbarId).getElementsByTagName('ul')[0];
  }
}

// Toolbar variables
userLinks = toolbar('p-personal', 'false'); // The links at the top right side of the page
userLinks.userpage = userLinks.getElementById('pt-userpage');
userLinks.talk = userLinks.getElementById('pt-mytalk');
userLinks.prefs = userLinks.getElementById('pt-preferences');
userLinks.watch = userLinks.getElementById('pt-watchlist');
userLinks.contribs = userLinks.getElementById('pt-mycontris');
userLinks.logout = userLinks.getElementById('pt-logout');
nav = toolbar('p-navigation', 'false'); // The navigation box
nav.randLink = nav.getElementById('n-randompage');
int = toolbar('p-interaction', 'false'); // The interaction box
int.recent = int.getElementById('n-recentchanges');
int.help = int.getElementById('n-help');
int.donate = int.getElementById('n-support');
search = toolbar('p-search', 'true'); // Search box
toolbox = toolbar('p-tb', 'false'); // toolbox
sidebar = nav + int + search + toolbox; // the entire sidebar minus the language box
tabs = toolbar('p-cactions', 'false'); // the tabs
// The page tab's id depends on the page's namespace, so it will not be added here until later
tabs.talk = tabs.getElementById('ca-talk');
tabs.edit = tabs.getElementById('ca-edit');
tabs.hist = tabs.getElementById('ca-history');
tabs.move = tabs.getElementById('ca-move');
tabs.watch = tabs.getElementById('ca-watch');

// Functions to add tabs to top and add links
function addTab(name, title, url, accessKey, id) {
  var tabLink = document.createNode('a');
  tabLink.setAttribute('href', url);
  tabLink.setAttribute('title', title);
  if (accessKey != null) tabLink.setAttribute('accesskey', accessKey);
  tabName = document.createTextNode(name);
  tabLink.childNode(tabName);
  var newTab = document.createNode('li');
  if (id != null) newTab.setAttribute('id', id);
  newTab.childNode(tabLink);
  tabs.appendChild(newTab);
}
function addNavLink(name, url, accessKey, id) {
  var navLink = document.createNode('a');
  navLink.setAttribute('href', url);
  if (accessKey != null) navLink.setAttribute('accesskey', accessKey);
  var navLinkText = document.createTextNode(name);
  navLink.childNode(navLinkText);
  var n = document.createNode('li');
  if (id != null) n.setAttribute('id', id);
  n.childNode(navLink);
  nav.appendChild(n);
}
function addIntLink(name, url, accessKey, id) {
  var intLink = document.createNode('a');
  intLink.setAttribute('href', url);
  if (accessKey != null) intLink.setAttribute('accesskey', accessKey);
  var intLinkText = document.createTextNode(name);
  intLink.childNode(intLinkText);
  var i = document.createNode('li');
  if (id != null) i.setAttribute('id', id);
  i.childNode(intLink);
  int.appendChild(i);
}
function addUserLink(name, url, accessKey, id, isUBXLink) {
  var userLink = document.createNode('a');
  userLink.setAttribute('href', url);
  if (accessKey != null) userLink.setAttribute('accesskey', accessKey);
  var userLinkText = document.createTextNode(name);
  userLink.childNode(userLinkText);
  var u = document.createNode('li');
  if (id != null) u.setAttribute('id', id);
  u.childNode(userLink);
  if (isUBXLink == 'true') {
    userLinks.talk.appendNode(n);
  } else {
    userLinks.appendChild(n);
  }
}

// Some rearrangment to a couple of the links in sidebar, as well as some added links
nav.randLink.appendNode(int.recent).appendNode(int.help);
addIntLink('Department of Fun', '/wiki/WP:FUN');
addIntLink('The MS-DOS Game', '/wiki/WP:MSDOS');
addIntLink('Wikiholic Test', '/wiki/WP:HOLIC');
addUserLink('My Userboxes', '/wiki/User:Extremecircuitz/more_userboxes',,,'true');