Wikipedia:WikiProject User scripts/Scripts/Add edit section 0

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Raylu (talk | contribs) at 22:58, 14 August 2005 (Made it only show when not already editing. Added description comment.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

//


//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.

function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
  if (!document.getElementById) return;
  x = document.getElementById('ca-edit');
  if(!x) return;
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  if (x.className == 'selected') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected';
    } else {
      x.className = 'selected istalk';
    }
  } else if (x.className == 'selected istalk') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected istalk';
    } else {
      y.className = 'istalk';
    }
  } else {
    y.className = x.className;
    x.className = 'istalk';
  }
  z = document.createElement('A');
  if (x.children) {
    z.href = x.children[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.href = x.childNodes[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
  }
}

if (document.title.indexOf("Editing ") == -1) {
  if (window.addEventListener) window.addEventListener("load", addEditSection0, false);
  else if (window.attachEvent) window.attachEvent("onload", addEditSection0);
}

//