1function initializeCodeToolbar() { 2 document.querySelectorAll("pre").forEach(pre => { 3 const codeElement = pre.querySelector("code"); 4 const lineCount = pre.querySelector(".line-numbers-rows")?.querySelectorAll("span").length; 5 if (codeElement && lineCount > 10) { 6 pre.insertAdjacentHTML("afterbegin", '<div class="code-expand-btn"><i class="fas fa-angle-double-down"></i></div>'); 7 } 8 }); 9 10 document.querySelectorAll(".code-expand-btn").forEach(btn => { 11 btn.addEventListener('click', () => { 12 const parentElement = btn.parentNode; 13 const isExpanded = btn.classList.toggle("expand-done"); 14 15 Array.from(parentElement.children).forEach(element => { 16 if (element.tagName === 'CODE') { 17 element.classList.toggle('expand-bcode', isExpanded); 18 } 19 }); 20 }); 21 }); 22 23 24 document.querySelectorAll(".toolbar").forEach((toolbar) => { 25 const iElement = document.createElement("i"); 26 iElement.className = "fas fa-angle-down expand"; 27 toolbar.appendChild(iElement); 28 }); 29 const codeToolbars = document.querySelectorAll(".code-toolbar"); 30 const expandIcons = document.querySelectorAll(".expand");
31 codeToolbars.forEach((toolbar, i) => { 32 toolbar.id = `pre${i}`; 33 }); 34 expandIcons.forEach((icon, i) => { 35 icon.id = `pbtn${i}`; 36 }); 37 expandIcons.forEach((icon) => { 38 icon.removeEventListener("click", handleExpandClick); 39 }); 40 expandIcons.forEach((icon) => { 41 icon.addEventListener("click", handleExpandClick); 42 }); 43} 44 45function handleExpandClick(event) { 46 const icon = event.currentTarget; 47 const btid = icon.id; 48 document.getElementById(btid).classList.toggle("bclose"); 49 50 const codeToolbar = icon.closest(".code-toolbar"); 51 const preId = codeToolbar.id; 52 const preElement = document.querySelector(`#${preId} pre`); 53 if (preElement) { 54 preElement.style.display = 55 preElement.style.display === "none" ? "" : "none"; 56 } 57} 58 59function tocCheck() { 60 const tocElement = document.querySelector(".toc"); 61 if (tocElement && tocElement.innerHTML.length === 14) { 62 const cardToc = document.getElementById("card-toc"); 63 const mobileTocButton = document.getElementById("mobile-toc-button"); 64 if (cardToc) cardToc.remove(); 65 if (mobileTocButton) mobileTocButton.remove(); 66 } 67}
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.