User:Korath/sb

From Wikipedia, the free encyclopedia

Contents

[edit] Common

[edit] Hide and Show

The following should appear if you want explicit "Hide" and "Show" links:

function hidevfd()
{
  var divs = document.getElementsByTagName("div");
  for (var x = 0; x < divs.length; ++x)
    if (divs[x].className.indexOf("vfd") != -1)
      divs[x].style.display = "none";
}

function showvfd()
{
  var divs = document.getElementsByTagName("div");
  for (var x = 0; x < divs.length; ++x)
    if (divs[x].className.indexOf("vfd") != -1)
      divs[x].style.display = "";
}

[edit] Toggle

The following should appear if you want a "Toggle" link:

function togglevfd()
{
  var divs = document.getElementsByTagName("div");
  var hidden = -1;
  for (var x = 0; x < divs.length; ++x)
    if (divs[x].className.indexOf("vfd") != -1)
      {
        if (hidden == -1)
          {
            if (divs[x].style.display == "none")
              hidden = 1;
            else
              hidden = 0;
          }

        if (hidden == 0)
          divs[x].style.display = "none";
        else
          divs[x].style.display = "";
      }
}

[edit] Classic skin

User:YourUsername/standard.js

[edit] Top

The following adds links to the top of the page in the Classic skin:

function addbarelink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);
  return na;
}

function vfdlinks()
{
  var table = document.getElementById('topbar').getElementsByTagName('table')[0];
  var tds = table.getElementsByTagName('td');
  var td = tds[1];

  // Add link to hide closed vfds, and label it "Hide"
  td.appendChild(addbarelink('javascript:hidevfd()', 'Hide'));

  // Add text " | "
  td.appendChild(document.createTextNode(' | '));

  // Add link to show closed vfds, and label it "Show"
  td.appendChild(addbarelink('javascript:showvfd()', 'Show'));

  // Add text " | "
  td.appendChild(document.createTextNode(' | '));

  // Add link to toggle closed vfds, and label it "Toggle"
  td.appendChild(addbarelink('javascript:togglevfd()', 'Toggle'));
}

[edit] Quickbar

The following adds links to the quickbar in the Classic skin:

function addbarelink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);
  return na;
}

function addsep()
{
  var hr = document.createElement('hr');
  hr.className = 'sep';
  return hr;
}

function vfdlinks()
{
  var qb = document.getElementById('quickbar');

  // add separator
  qb.appendChild(addsep());

  // Add link to hide closed vfds, and label it "Hide Vfds"
  qb.appendChild(addbarelink('javascript:hidevfd()', 'Hide Vfds'));

  // Next line
  qb.appendChild(document.createElement('br'));

  // Add link to show closed vfds, and label it "Show Vfds"
  qb.appendChild(addbarelink('javascript:showvfd()', 'Show Vfds'));

  // Next line
  qb.appendChild(document.createElement('br'));

  // Add link to toggle closed vfds, and lable it "Toggle Vfds"
  qb.appendChild(addbarelink('javascript:togglevfd()', 'Toggle Vfds'));
}

[edit] Monobook skin

User:YourUsername/monobook.js

[edit] Top

The following adds tabs at the top in the Monobook skin:

function addlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

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

function vfdlinks()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Add link to hide closed vfds, and label it "Hide Vfds"
  tabs.appendChild(addlilink('javascript:hidevfd()', 'Hide Vfds'));

  // Add link to hide closed vfds, and label it "Show Vfds"
  tabs.appendChild(addlilink('javascript:showvfd()', 'Show Vfds'));

  // Add link to hide closed vfds, and label it "Toggle Vfds"
  tabs.appendChild(addlilink('javascript:togglevfd()', 'Toggle Vfds'));
}

[edit] Toolbox

The following adds links to the toolbox in the sidebar in the Monobook skin:

function addlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

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

function vfdlinks()
{
  var tb = document.getElementById('p-tb');
  var ul = tb.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Add link to hide closed vfds, and label it "Hide Vfds"
  ul.appendChild(addlilink('javascript:hidevfd()', 'Hide Vfds'));

  // Add link to show closed vfds, and label it "Show Vfds"
  ul.appendChild(addlilink('javascript:showvfd()', 'Show Vfds'));

  // Add link to toggle closed vfds, and label it "Toggle Vfds"
  ul.appendChild(addlilink('javascript:togglevfd()', 'Toggle Vfds'));
}

[edit] Common

The following should appear at the bottom in all versions:

function do_onload()
{
  // Only add for pages with "Wikipedia:Votes for deletion" somewhere in the title
  if (document.title.indexOf("Wikipedia:Votes for deletion") != -1)
    vfdlinks();
}

if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);