Team:Freiburg/Templates/html/js.html

From 2014.igem.org

(Difference between revisions)
Line 187: Line 187:
       if (DEBUG) console.log("indexofPath: " + indexOfPath);
       if (DEBUG) console.log("indexofPath: " + indexOfPath);
       if (indexOfPath === -1) continue;
       if (indexOfPath === -1) continue;
 +
      if (indexOfPath > 2) continue;
       var indexOfSharp = href.indexOf('#');
       var indexOfSharp = href.indexOf('#');
-
       if (indexOfSharp === -1) {
+
      // check if the url part of the href ends with our location
-
         navLinks[i].setAttribute('href', '#');
+
      var hreflength = href.length;
-
        navLinks[i].setAttribute('class', 'active');
+
       if (indexOfSharp === -1) hreflength = indexOfSharp;
-
      } else {
+
      if (indexOfPath >= href.length - currentPath.length - 1){
-
        navLinks[i].setAttribute('href', href.slice(indexOfSharp));
+
         if (indexOfSharp === -1) {
 +
          navLinks[i].setAttribute('href', '#');
 +
          navLinks[i].setAttribute('class', 'active');
 +
        } else {
 +
          navLinks[i].setAttribute('href', href.slice(indexOfSharp));
 +
        }
       }
       }
     }
     }

Revision as of 22:09, 17 October 2014