User:Joshurtree/utils.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

function addLink(url, name, id, element)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.setAttribute('id' id);
  na.appendChild(document.createTextNode(name));

  var li = document.createElement('li');
  li.appendChild(na);

  element.appendChild(li);
}


function addTagLink(url, name, id)
{
//  var tabs = document.getElementById('p-captions').getElementsByTagName('ul')[0];
//  addLink(url, name, id, tabs);
}

function addToolboxLink(url, name, id)
{
  var toolbox = document.getElementById('p-tb').getElementsByTagName('ul')[0];
  addLink(url, name, id, toolbox);
}

function addNavigationLink(url, name, id)
{
  var navigationBox = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
  addLink(url, name, id, navigation);
}

function hideElement(id)
{
  document.getElementById(id).style.display = 'none';
}

function showElement(id)
{
  document.getElementById(id).style.display = '';
}