Jump to navigation Jump to search
mNo edit summary
Line 12: Line 12:
Adds an edit link that lets you section edit the very top section.
Adds an edit link that lets you section edit the very top section.
<pre>
<pre>
/******************************************
importScript('User:Ryan Schmidt/Scripts/TopSection.js');
** Add Section Edit link for top section **
******************************************/
if (wgAction == 'view' && wgNamespaceNumber >=0)
addOnloadHook(function(){
  var h2s = document.getElementsByTagName('H2');
  var h2 = h2s[0];
  if (!h2) return;
  if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
  if (!h2) return;
  var span = h2.firstChild;
  if (!span || span.className != 'editsection') return;
  var zero = span.cloneNode(true);
  if (document.getElementById('featured_icon')) zero.style.marginRight = '30px'
  var parent = document.getElementsByTagName('H1')[0];
  parent.insertBefore(zero, parent.firstChild);
  var a = zero.getElementsByTagName('A')[0];
  a.title = a.title.replace(/:.*$/,': 0');
  a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
})
</pre>
</pre>