// Rustelo Documentation Custom JavaScript // Add copy buttons to code blocks document.addEventListener("DOMContentLoaded", function () { // Add copy buttons to code blocks const codeBlocks = document.querySelectorAll("pre > code"); codeBlocks.forEach(function (codeBlock) { const pre = codeBlock.parentElement; const button = document.createElement("button"); button.className = "copy-button"; button.textContent = "Copy"; button.style.cssText = ` position: absolute; top: 8px; right: 8px; background: #4a5568; color: white; border: none; padding: 4px 8px; border-radius: 4px; font-size: 12px; cursor: pointer; opacity: 0; transition: opacity 0.2s; `; pre.style.position = "relative"; pre.appendChild(button); pre.addEventListener("mouseenter", function () { button.style.opacity = "1"; }); pre.addEventListener("mouseleave", function () { button.style.opacity = "0"; }); button.addEventListener("click", function () { const text = codeBlock.textContent; navigator.clipboard.writeText(text).then(function () { button.textContent = "Copied!"; button.style.background = "#48bb78"; setTimeout(function () { button.textContent = "Copy"; button.style.background = "#4a5568"; }, 2000); }); }); }); // Add feature badges const content = document.querySelector(".content"); if (content) { let html = content.innerHTML; // Replace feature indicators html = html.replace( /\[FEATURE:([^\]]+)\]/g, '$1', ); html = html.replace( /\[OPTIONAL:([^\]]+)\]/g, '$1', ); html = html.replace( /\[DISABLED:([^\]]+)\]/g, '$1', ); // Add callout boxes html = html.replace( /\[NOTE\]([\s\S]*?)\[\/NOTE\]/g, '
Built with ❤️ using mdBook
Rustelo Documentation • Last updated: ${new Date().toLocaleDateString()}
`; content.appendChild(footer); } });