{% comment %}
- If previewing locally, site.root is set in _config_dev.yml.
- If site.root is not set, assume we're viewing on the web.
+ Javascript used in lesson and workshop pages.
{% endcomment %}
-{% if site.root %}
- {% assign root = site.root %}
-{% else %}
- {% assign root = site.github.url %}
-{% endif %}
-<script src="{{ root }}/assets/js/jquery.min.js"></script>
-<script src="{{ root }}/assets/js/bootstrap.min.js"></script>
-<script src="{{ root }}/assets/js/lesson.js"></script>
+<script src="{{ page.root }}/assets/js/jquery.min.js"></script>
+<script src="{{ page.root }}/assets/js/bootstrap.min.js"></script>
+<script src="{{ page.root }}/assets/js/lesson.js"></script>
+<script>
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+ ga('create', 'UA-37305346-2', 'auto');
+ ga('send', 'pageview');
+</script>
+<script>
+ // This snippet fixes a bug caused by Github's pages-gem using kramdown v1.11.1.
+ // In order for anchor links to point to the correct place in the glossary, they must have an id
+ // This snippet ensures every definition term has an id
+ // See https://github.com/swcarpentry/styles/pull/129
+ $('dt').each(function () {
+ if (!this.id) {
+ var id = $(this).text();
+ // If there's a ( in the name (e.g., "comma-separated values (CSV)") - just take everything up to the first (
+ var index = id.indexOf('(');
+ if (index > 0) {
+ id = id.substring(0, index);
+ }
+ // Strip leading and trailing whitespace, convert spaces to dashes and convert everything to lowercase
+ id = id.trim().replace(/ /g, '-').toLowerCase();
+ this.id = id;
+ }
+ });
+</script>