Fix for nesting of TOC

This commit is contained in:
John Mulhausen 2016-10-10 20:15:50 -07:00
parent cc2092d2fa
commit 6b2de29fa7
1 changed files with 11 additions and 11 deletions

View File

@ -57,7 +57,6 @@ jQuery(document).ready(function(){
var output = "";
$("h2, h3, h4").each(function() {
var li= "<li><a href='" + window.location + "#" + $(this).attr('id') + "'>" + $(this).text().replace("¶","") + "</a></li>";
lastHeader = currentHeader;
if( $(this).is("h2") ){
// h2
currentHeader = 2;
@ -68,18 +67,19 @@ jQuery(document).ready(function(){
// h4
currentHeader = 4;
}
if (currentHeader > lastHeader)
{
if (currentHeader > lastHeader) {
// nest further
output += "<ul>" + li;
} else if (lastHeader < currentHeader)
{
// close nesting
output += "</ul>" + li
} else {
// continue, no change in nesting
output += li;
output += "<ul>"
}
if (currentHeader < lastHeader && lastHeader > 0) {
// close nesting
for (i=0; i < (lastHeader - currentHeader); i++)
{
output += "</ul>"
}
}
output += li;
lastHeader = currentHeader;
/*
if( $(this).is("h2") ){
prevH2List = $("<ul></ul>");