`); printWindow.document.close(); printWindow.focus(); setTimeout(() => { printWindow.print(); printWindow.close(); }, 250); } }); }); // Add print button to each document documents.forEach(doc => { const header = doc.querySelector('.document-header'); const printBtn = document.createElement('button'); printBtn.className = 'print-btn'; printBtn.innerHTML = ' Print Document'; printBtn.style.cssText = ` background: #2a5caa; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; margin-top: 15px; transition: background 0.3s ease; `; printBtn.addEventListener('mouseenter', () => { printBtn.style.background = '#1a2b4c'; }); printBtn.addEventListener('mouseleave', () => { printBtn.style.background = '#2a5caa'; }); header.appendChild(printBtn); }); // Back to top button const backToTop = document.createElement('button'); backToTop.innerHTML = ''; backToTop.className = 'back-to-top'; backToTop.style.cssText = ` position: fixed; bottom: 30px; right: 30px; width: 50px; height: 50px; background: #2a5caa; color: white; border: none; border-radius: 50%; cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 1.2rem; box-shadow: 0 4px 15px rgba(42, 92, 170, 0.3); transition: all 0.3s ease; z-index: 1000; `; document.body.appendChild(backToTop); backToTop.addEventListener('mouseenter', () => { backToTop.style.background = '#1a2b4c'; backToTop.style.transform = 'translateY(-3px)'; }); backToTop.addEventListener('mouseleave', () => { backToTop.style.background = '#2a5caa'; backToTop.style.transform = 'translateY(0)'; }); backToTop.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); window.addEventListener('scroll', () => { if (window.pageYOffset > 300) { backToTop.style.display = 'flex'; } else { backToTop.style.display = 'none'; } }); // Add table of contents functionality documents.forEach(doc => { const sections = doc.querySelectorAll('.section h3'); if (sections.length > 0) { const toc = document.createElement('div'); toc.className = 'table-of-contents'; toc.innerHTML = `

Table of Contents

`; toc.style.cssText = ` background: #f8f9fa; border-radius: 10px; padding: 20px; margin: 30px 0; border-left: 4px solid #2a5caa; `; const tocContent = toc.querySelector('.toc-content'); sections.forEach((section, index) => { const sectionId = `section-${doc.id}-${index}`; section.id = sectionId; const tocItem = document.createElement('a'); tocItem.href = `#${sectionId}`; tocItem.textContent = section.textContent; tocItem.className = 'toc-item'; tocItem.style.cssText = ` display: block; padding: 8px 0; color: #2a5caa; text-decoration: none; border-bottom: 1px solid #e9ecef; transition: color 0.3s ease; `; tocItem.addEventListener('mouseenter', () => { tocItem.style.color = '#ff6b35'; }); tocItem.addEventListener('mouseleave', () => { tocItem.style.color = '#2a5caa'; }); tocItem.addEventListener('click', (e) => { e.preventDefault(); const yOffset = -100; const y = section.getBoundingClientRect().top + window.pageYOffset + yOffset; window.scrollTo({ top: y, behavior: 'smooth' }); }); tocContent.appendChild(tocItem); }); doc.querySelector('.document-content').prepend(toc); } }); });