jonnykates
8/1/2017 - 8:21 AM

Ignore any files being served from codeclips-staging or in the platform styles (JS will still execute)

Ignore any files being served from codeclips-staging or in the platform styles (JS will still execute)

$(document).ready(function() {
  var client = "CLIENTNAME";
  var localPort = "8000";
  var script = document.createElement('script');
  var stylesheet = document.createElement('link');
  stylesheet.setAttribute('rel', 'stylesheet');
  stylesheet.type = "text/css";

  if(window.location.href.indexOf("rit.org.uk") > -1) {
    console.log("We're on the server");
    script.src = "//assets.rit.org.uk/" + client + "/scripts/main.js";
    stylesheet.href = "//assets.rit.org.uk/" + client + "/styles/main.css";
  } else {
    console.log("We're local");
    script.src = "http://localhost:" + localPort + "/main.js";
    stylesheet.href = "http://localhost:" + localPort + "/main.css";
    $('link[rel=stylesheet][href*="assets.rit.org.uk"]').remove();
    $('link[rel=stylesheet]#platformStylesheet').remove();
  }

  document.head.appendChild(stylesheet);
  document.body.appendChild(script);
});
<script>
  $('link[rel=stylesheet][href*="assets.rit.org.uk"]').remove();
  $('script[src*="assets.rit.org.uk"]').remove();
  $('link[rel=stylesheet]#platformStylesheet').remove();
</script>