2020-01-24 12:47:52 -07:00
|
|
|
$(function() {
|
|
|
|
function hasPrefix(str, prefix) {
|
|
|
|
if (!prefix) return true;
|
|
|
|
if (!str) return false;
|
|
|
|
return str.indexOf(prefix) === 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// highlight current page in left nav
|
|
|
|
var $currentPageLink = $('main nav a[href="'+window.location.pathname+'"]');
|
|
|
|
if (hasPrefix(window.location.pathname, "/docs/json/")) {
|
|
|
|
// as a special case, highlight the JSON structure link anywhere within it
|
|
|
|
$currentPageLink = $('main nav a[href="/docs/json/"]');
|
|
|
|
}
|
2020-03-21 21:03:29 -06:00
|
|
|
if (hasPrefix(window.location.pathname, "/docs/modules/")) {
|
|
|
|
// as another special case, highlight the modules link anywhere within it
|
|
|
|
$currentPageLink = $('main nav a[href="/docs/modules/"]');
|
|
|
|
}
|
2020-01-24 12:47:52 -07:00
|
|
|
$currentPageLink.addClass('current');
|
2020-02-26 16:30:54 -05:00
|
|
|
|
|
|
|
// add anchor links, inspired by https://github.com/bryanbraun/anchorjs
|
2020-03-30 15:38:40 -06:00
|
|
|
$('article > h1[id], article > h2[id], article > h3[id], article > h4[id], article > h5[id], article > h6[id]').each(function() {
|
|
|
|
var $anchor = $('<a href="#'+this.id+'" class="anchor-link" title="Direct link">🔗</a>');
|
|
|
|
$(this).append($anchor);
|
2020-02-26 16:30:54 -05:00
|
|
|
});
|
2020-03-30 15:38:40 -06:00
|
|
|
|
|
|
|
// the server-side markdown renderer annoyingly renders
|
|
|
|
// colored code blocks differently from plain ones, in that
|
|
|
|
// colorized ones do not have the additional <code> inside
|
|
|
|
// the <pre>; this line finds those and adds a .chroma class
|
|
|
|
// to the outer pre element, and our CSS file has a style to
|
|
|
|
// ensure the inner code block does not produce extra padding
|
|
|
|
$('article > pre:not(.chroma) > code:not(.cmd)').parent().addClass('chroma');
|
2020-01-24 12:47:52 -07:00
|
|
|
});
|