Team:Freiburg/Templates/html/inlinejs.html

From 2014.igem.org

(Difference between revisions)
 
(7 intermediate revisions not shown)
Line 2: Line 2:
<script>
<script>
(function(){
(function(){
-
   var DEBUG = true;
+
   function hasClass( elem, klass ) {
-
  // grab navigation links
+
     return (" " + elem.className + " " ).indexOf( " "+klass+" " ) > -1;
-
  var navLinks = document.getElementsByTagName('nav');
+
-
  if (DEBUG) {
+
-
     console.log('All found nav elements');
+
-
    console.dir(navLinks);
+
-
  }
+
-
  if (navLinks.length > 0) navLinks = navLinks[0];
+
-
  if (DEBUG) {
+
-
    console.log('First nav element');
+
-
    console.dir(navLinks);
+
-
  }
+
-
  navLinks = navLinks.getElementsByTagName('a');
+
-
  if (DEBUG) {
+
-
    console.log('Anchor Elements in the first nav element');
+
-
    console.dir(navLinks);
+
   }
   }
-
   // check all links' href attributes for equality with url
+
   // remove unnecessary css
-
  var currentPath = location.pathname;
+
   if (hasClass(document.body, 'mediawiki')){
-
   if (DEBUG) console.log("Current Path: " + currentPath);
+
    var unwantedStylesheets = document.head.querySelectorAll('head link[rel="stylesheet"], head style[type="text/css"]');
-
  for (var i=0;i<navLinks.length;i++) {
+
    for (var i=0;i<unwantedStylesheets.length; i++){
-
    var href = navLinks[i].getAttribute('href')
+
      unwantedStylesheets[i].parentNode.removeChild(unwantedStylesheets[i]);
-
    if (DEBUG) console.log(href);
+
-
    if (href.indexOf(currentPath) !== -1){
+
-
      // set active state
+
-
      if (DEBUG) console.log('Setting active state for: ' + href);
+
-
      var parent = navLinks[i].parentNode;
+
-
      while (parent.tagName != 'NAV') {
+
-
        // set active class for all ancestral list items
+
-
        if (parent.tagName == 'LI') {
+
-
          parent.setAttribute('class', 'active');
+
-
        }
+
-
        parent = parent.parentNode;
+
-
      }
+
     }
     }
   }
   }
 +
function loadStylesheet(href) {
 +
      var link = document.createElement("link");
 +
      link.href = href;
 +
      link.type = "text/css";
 +
      link.rel = "stylesheet";
 +
      document.getElementsByTagName("head")[0].appendChild(link);
 +
    };
 +
    loadStylesheet('/Team:Freiburg/css/bootstrap.3.2.0.min.css?action=raw\u0026ctype=text/css');
 +
    loadStylesheet('/Team:Freiburg/css/magnific-popup.css?action=raw\u0026ctype=text/css');
 +
    loadStylesheet('/Team:Freiburg/css/jquery.qtip.min.css?action=raw\u0026ctype=text/css');
 +
    loadStylesheet('/Team:Freiburg/css/styles_v2.css?action=raw\u0026ctype=text/css');
 +
    loadStylesheet('/Team:Freiburg/css/styles_additional.css?action=raw\u0026ctype=text/css');
})();
})();
</script>
</script>
</html>
</html>

Latest revision as of 12:05, 13 October 2014