1document.addEventListener("DOMContentLoaded", () => { 2 const toggleSpecs = [ 3 { trigger: "a.abstract", target: ".abstract.hidden" }, 4 { trigger: "a.award", target: ".award.hidden" }, 5 { trigger: "a.bibtex", target: ".bibtex.hidden" }, 6 ]; 7 8 const resolveToggleScope = (link) => { 9 const linksContainer = link.closest(".links"); 10 if (linksContainer && linksContainer.parentElement) { 11 return linksContainer.parentElement; 12 } 13 14 return link.closest("li, .card-body, article, .post, .row") || link.parentElement; 15 }; 16 17 const closePanels = (scope, exceptPanel) => { 18 scope.querySelectorAll(".abstract.hidden.open, .award.hidden.open, .bibtex.hidden.open").forEach((panel) => { 19 if (panel !== exceptPanel) { 20 panel.classList.remove("open"); 21 } 22 }); 23 }; 24 25 toggleSpecs.forEach((spec) => { 26 document.querySelectorAll(spec.trigger).forEach((link) => { 27 link.addEventListener("click", (event) => { 28 event.preventDefault(); 29 const scope = resolveToggleScope(link); 30 if (!scope) { 31 return; 32 } 33 34 const panel = scope.querySelector(spec.target); 35 if (panel) { 36 closePanels(scope, panel); 37 panel.classList.toggle("open"); 38 } 39 }); 40 }); 41 }); 42 43 document.querySelectorAll("a.waves-effect, a.waves-light").forEach((anchor) => { 44 anchor.classList.remove("waves-effect", "waves-light"); 45 }); 46 47 const tocSidebar = document.querySelector("#toc-sidebar"); 48 const contentRoot = document.querySelector('[role="main"]') || document.querySelector("main") || document.body; 49 const buildSidebarToc = (tocRoot) => { 50 const headings = Array.from(contentRoot.querySelectorAll("h2, h3")).filter((heading) => { 51 return !heading.hasAttribute("data-toc-skip"); 52 }); 53 54 if (!headings.length) { 55 return; 56 } 57 58 const list = document.createElement("ul"); 59 list.className = "toc-list"; 60
61 headings.forEach((heading) => { 62 if (!heading.id) { 63 heading.id = heading.textContent 64 .trim() 65 .toLowerCase() 66 .replace(/[^a-z0-9]+/g, "-") 67 .replace(/^-+|-+$/g, ""); 68 } 69 70 const item = document.createElement("li"); 71 item.className = "toc-list-item"; 72 const link = document.createElement("a"); 73 link.className = "toc-link"; 74 link.href = `#${heading.id}`; 75 link.textContent = heading.dataset.tocText || heading.textContent.trim(); 76 if (heading.tagName.toLowerCase() === "h3") { 77 item.classList.add("is-collapsible"); 78 } 79 80 item.appendChild(link); 81 list.appendChild(item); 82 }); 83 84 tocRoot.replaceChildren(list); 85 }; 86 87 if (tocSidebar) { 88 const resolveTocCollapseDepth = () => { 89 const explicitDepth = Number.parseInt(tocSidebar.dataset.tocCollapseDepth || "", 10); 90 if (!Number.isNaN(explicitDepth) && explicitDepth >= 0) { 91 return explicitDepth; 92 } 93 94 const collapseMode = (tocSidebar.dataset.tocCollapse || "expanded").toLowerCase(); 95 if (["auto", "scroll", "true", "collapsed"].includes(collapseMode)) { 96 // Keep top-level entries visible and expand nested branches while scrolling. 97 return 3; 98 } 99 100 return 6; 101 }; 102 103 document.querySelectorAll(".publications h2").forEach((heading) => { 104 heading.setAttribute("data-toc-skip", ""); 105 }); 106 107 const headings = Array.from(contentRoot.querySelectorAll("h2, h3")).filter((heading) => !heading.hasAttribute("data-toc-skip"));
108 headings.forEach((heading) => { 109 if (!heading.id) { 110 heading.id = heading.textContent 111 .trim() 112 .toLowerCase() 113 .replace(/[^a-z0-9]+/g, "-") 114 .replace(/^-+|-+$/g, ""); 115 } 116 }); 117 118 const applyCustomTocLabels = () => { 119 tocSidebar.querySelectorAll(".toc-link").forEach((link) => { 120 const anchor = link.getAttribute("href") || ""; 121 const headingId = decodeURIComponent(anchor.replace(/^#/, "")); 122 if (!headingId) { 123 return; 124 } 125 const heading = document.getElementById(headingId); 126 const customText = heading?.dataset?.tocText; 127 if (customText) { 128 link.textContent = customText; 129 } 130 }); 131 }; 132 133 if (window.tocbot && typeof window.tocbot.init === "function" && headings.length > 0) { 134 if (typeof window.tocbot.destroy === "function") { 135 window.tocbot.destroy(); 136 } 137 138 window.tocbot.init({ 139 tocSelector: "#toc-sidebar", 140 contentSelector: '[role="main"]', 141 headingSelector: "h2, h3", 142 ignoreSelector: "[data-toc-skip]", 143 hasInnerContainers: true, 144 collapseDepth: resolveTocCollapseDepth(), 145 orderedList: false, 146 activeLinkClass: "is-active-link", 147 scrollSmooth: true, 148 scrollSmoothOffset: -80, 149 headingsOffset: 80, 150 }); 151 applyCustomTocLabels(); 152 } else { 153 buildSidebarToc(tocSidebar); 154 } 155 } 156 157 const prefersTheme = () => { 158 if (typeof window.determineComputedTheme === "function") { 159 return window.determineComputedTheme(); 160 } 161 return document.documentElement.dataset.theme || "light"; 162 }; 163 164 const jupyterTheme = prefersTheme(); 165 document.querySelectorAll(".jupyter-notebook-iframe-container iframe").forEach((iframe) => { 166 const applyNotebookStyling = () => { 167 const iframeDocument = iframe.contentDocument; 168 if (!iframeDocument) { 169 return; 170 } 171 172 if (!iframeDocument.querySelector('link[data-al-folio-jupyter="true"]')) { 173 const cssLink = iframeDocument.createElement("link"); 174 cssLink.href = "../css/jupyter.css"; 175 cssLink.rel = "stylesheet"; 176 cssLink.type = "text/css"; 177 cssLink.setAttribute("data-al-folio-jupyter", "true"); 178 iframeDocument.head.appendChild(cssLink); 179 } 180 181 if (jupyterTheme === "dark") { 182 iframeDocument.body?.setAttribute("data-jp-theme-light", "false"); 183 iframeDocument.body?.setAttribute("data-jp-theme-name", "JupyterLab Dark"); 184 } 185 }; 186 187 if (iframe.contentDocument?.readyState === "complete") { 188 applyNotebookStyling(); 189 } 190 iframe.addEventListener("load", applyNotebookStyling); 191 }); 192 193 if (window.AlFolioUi && typeof window.AlFolioUi.initPopovers === "function") { 194 window.AlFolioUi.initPopovers(document); 195 } 196});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.