Team:HSAAHNU Anhui/inject.js

From 2014hs.igem.org

(Difference between revisions)
m (content type fixed)
(add nprogress)
Line 24: Line 24:
removelinkStylesheetNodes();
removelinkStylesheetNodes();
-
var injections = [
+
var stylesheetList = [
   '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
   '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
-
   '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/css" rel="stylesheet">'
+
   '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/css" rel="stylesheet">',
 +
  '<link href="http://ricostacruz.com/nprogress/nprogress.css" rel="stylesheet">'
];
];
-
document.head.innerHTML += injections.join('\n');
+
document.head.innerHTML += stylesheetList.join('\n');
 +
 
 +
var javascriptList = [
 +
  'http://ricostacruz.com/nprogress/nprogress.js'
 +
];
 +
 
 +
javascriptList.forEach(function (script) {
 +
  $.getScript(script);
 +
});

Revision as of 15:37, 29 May 2014

function removeStyleNodes () {

 var styleNodes = document.head.getElementsByTagName('style');
 while (styleNodes.length != 0) {
   document.head.removeChild(styleNodes[0]);
 }

}

function removelinkStylesheetNodes () {

 var linkNodes = document.head.getElementsByTagName('link');
 var nonStylesheetLinksCounter = 0;
 var iter = 0;
 while (linkNodes.length != nonStylesheetLinksCounter) {
   var node = linkNodes[iter];
   if (node['rel'] == 'stylesheet')
     document.head.removeChild(node);
   else {
     nonStylesheetLinksCounter ++;
     iter ++;
   }
 }

}

removeStyleNodes(); removelinkStylesheetNodes();

var stylesheetList = [

 '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
 '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/css" rel="stylesheet">',
 '<link href="http://ricostacruz.com/nprogress/nprogress.css" rel="stylesheet">'

];

document.head.innerHTML += stylesheetList.join('\n');

var javascriptList = [

 'http://ricostacruz.com/nprogress/nprogress.js'

];

javascriptList.forEach(function (script) {

 $.getScript(script);

});