Skip to content

Instantly share code, notes, and snippets.

@tessas-capella
Created March 1, 2013 16:31
Show Gist options
  • Save tessas-capella/5065837 to your computer and use it in GitHub Desktop.
Save tessas-capella/5065837 to your computer and use it in GitHub Desktop.
sniffs file's location and writes style sheet links and js script tags depending on what environment the file is being served from. Searches for that server's common wrapper files. - localhost, cis subdomain, ffti courseroom.
<script>
//check where page is coming from
var hostname = window.location.hostname;
if(hostname == 'localhost'){
var sharedResources = "//localhost/00-medtronic/";
}else if(hostname == 'customsolutions.capella-id.com'){
var sharedResources = "//customsolutions.capella-id.com/medtronic/";
}else{
var sharedResources = "//medtronic.capella.edu/file.php/1/media/";
}//if/else check for where the page is loading
//css sample
document.write('<link rel="stylesheet" href="'+sharedResources+'/common/wrapper/css/css.css" />');
//js sample
document.write("<scr" + "ipt src='"+sharedResources+"/common/wrapper/js/modernizr-1.7.min.js' type='text/javascript' charset='utf-8'><\/scr" + "ipt>");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment