Template:Team:Groningen/Header/AncestorLinks.js

From 2009.igem.org

(Difference between revisions)
(Trying to modify top heading.)
Line 1: Line 1:
-
var pnc = wgPageName.split('/');
+
var firstHeadingNode = document.getElementById('firstHeading');
-
var tc = wgTitle.split('/');
+
if (firstHeadingNode) {
-
for(var i=0; i<pnc.length; i++) {
+
  var pageTitle = firstHeadingNode.innerHTML;
-
  var c = tc[i];
+
  var prefix = pageTitle.substring(0,pageTitle.indexOf('Team:Groningen'));
-
  var p = pnc.slice(0,i+1).join('/');
+
  firstHeadingNode.innerHTML = prefix;
-
  if (i>0) document.write(' > ');
+
  var pnc = wgPageName.split('/');
-
  if (i+1<pnc.length) {
+
  var tc = wgTitle.split('/');
-
    document.write(c.link(wgArticlePath.replace('$1',p)));
+
  for(var i=0; i<pnc.length; i++) {
-
  } else {
+
    var c = tc[i];
-
    document.write(c);
+
    var p = pnc.slice(0,i+1).join('/');
 +
    if (i>0) firstHeadingNode.appendChild(document.createTextNode(' > '));
 +
    if (i+1<pnc.length) {
 +
      var link = document.createElement('a');
 +
      link.href = wgArticlePath.replace('$1',p);
 +
      link.innerHTML = c;
 +
      firstHeadingNode.appendChild(link);
 +
    } else {
 +
      firstHeadingNode.appendChild(document.createTextNode(c));
 +
    }
   }
   }
}
}

Revision as of 15:00, 31 August 2009

var firstHeadingNode = document.getElementById('firstHeading'); if (firstHeadingNode) {

 var pageTitle = firstHeadingNode.innerHTML;
 var prefix = pageTitle.substring(0,pageTitle.indexOf('Team:Groningen'));
 firstHeadingNode.innerHTML = prefix;
 var pnc = wgPageName.split('/');
 var tc = wgTitle.split('/');
 for(var i=0; i<pnc.length; i++) {
   var c = tc[i];
   var p = pnc.slice(0,i+1).join('/');
   if (i>0) firstHeadingNode.appendChild(document.createTextNode(' > '));
   if (i+1<pnc.length) {
     var link = document.createElement('a');
     link.href = wgArticlePath.replace('$1',p);
     link.innerHTML = c;
     firstHeadingNode.appendChild(link);
   } else {
     firstHeadingNode.appendChild(document.createTextNode(c));
   }
 }

}