Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions docs/_spec/public/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
function currentChapter() {
var path = document.location.pathname;
var idx = path.lastIndexOf("/") + 1;
var chap = path.substring(idx, idx + 2);
return parseInt(chap, 10);
return parseInt(document.location.pathname.split('/').pop().substr(0, 2), 10);
}

function heading(i, heading, $heading) {
var currentLevel = parseInt(heading.tagName.substring(1));
var result = "";
const currentLevel = parseInt(heading.tagName.substring(1));

if (currentLevel === this.headerLevel) {
this.headerCounts[this.headerLevel] += 1;
return "" + this.headerCounts[this.headerLevel] + " " + $heading.text();
this.headerCounts[this.headerLevel]++;
} else if (currentLevel < this.headerLevel) {
while(currentLevel < this.headerLevel) {
while (currentLevel < this.headerLevel) {
this.headerCounts[this.headerLevel] = 1;
this.headerLevel -= 1;
this.headerLevel--;
}
this.headerCounts[this.headerLevel] += 1;
return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
this.headerCounts[this.headerLevel]++;
} else {
while(currentLevel > this.headerLevel) {
this.headerLevel += 1;
while (currentLevel > this.headerLevel) {
this.headerLevel++;
this.headerCounts[this.headerLevel] = 1;
}
return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
}
return `${this.headerCounts[this.headerLevel]} ${$heading.text()}`;
}

// ignore when using wkhtmltopdf, or it won't work...
if(window.jekyllEnv !== 'spec-pdf') {
if (window.jekyllEnv !== 'spec-pdf') {
$('#toc').toc(
{
'selectors': 'h1,h2,h3',
Expand Down Expand Up @@ -64,8 +59,6 @@ document.addEventListener("DOMContentLoaded", function() {
});

$("#chapters a").each(function (index) {
if (document.location.pathname.endsWith($(this).attr("href")))
$(this).addClass("chapter-active");
else
$(this).removeClass("chapter-active");
const href = $(this).attr("href");
$(this).toggleClass("chapter-active", document.location.pathname.endsWith(href));
});