/* Javascript functions to help make the print page more PDF friendly */ /* Generates a table of contents for the print site page. Only called when print-site-plugin option 'add_table_of_contents' is set to true */ function generate_toc() { var ToC = "" var newLine, el, title, link; const toc_elements = document.querySelectorAll( "#print-site-page h1.nav-section-title, #print-site-page h1.nav-section-title-end," + "#print-site-page h2.nav-section-title, #print-site-page h2.nav-section-title-end," + "#print-site-page h3.nav-section-title, #print-site-page h3.nav-section-title-end," + "#print-site-page h4.nav-section-title, #print-site-page h4.nav-section-title-end," + "#print-site-page h5.nav-section-title, #print-site-page h5.nav-section-title-end," + "#print-site-page h6.nav-section-title, #print-site-page h6.nav-section-title-end," + "section.print-page h1,section.print-page h2,section.print-page h3," + "section.print-page h4,section.print-page h5,section.print-page h6") var current_heading_depth = 0; var current_section_depth = 0; // Extract table of contents depth // basically plugin setting, passed via a data attribute var toc_depth = document.getElementById("print-page-toc").getAttribute("data-toc-depth") for (var i = 0; i < toc_elements.length; i++) { // Get the info from the element el = toc_elements[i] link = "#" + el.id; tag = el.tagName tag_level = tag.substring(1) // Get the text of a heading // We use .firstChild.nodeValue instead of .innerText // because of elements like: //