main.js 891 B

123456789101112131415161718
  1. (function(w){
  2. // conditionally load hightlight.js /w sunburst css from cdn
  3. var codes = document.getElementsByTagName('code');
  4. if (codes.length > 0) {
  5. console.log("We have code!");
  6. var css = document.createElement("link");
  7. css.setAttribute("rel", "stylesheet");
  8. css.setAttribute("type", "text/css");
  9. css.setAttribute("href", "https://d2xxklvztqk0jd.cloudfront.net/css/sunburst.js");
  10. document.getElementsByTagName("head")[0].appendChild(css);
  11. var js = document.createElement('script');
  12. js.setAttribute("type", "text/javascript");
  13. js.setAttribute("async", true);
  14. js.onload = function() { hljs.initHighlight(); };
  15. js.setAttribute("src", "https://d2xxklvztqk0jd.cloudfront.net/js/highlight.js");
  16. document.getElementsByTagName('script')[0].parentNode.insertBefore(js, t);
  17. }
  18. })(window);