// ==== File: docs/assets/floating_ask_ai_button.js ==== document.addEventListener('DOMContentLoaded', () => { const askAiPagePath = '/core/ask-ai/'; // IMPORTANT: Adjust this path if needed! const currentPath = window.location.pathname; // Determine the base URL for constructing the link correctly, // especially if deployed in a sub-directory. // This assumes a simple structure; adjust if needed. const baseUrl = window.location.origin + (currentPath.startsWith('/core/') ? '../..' : ''); // Check if the current page IS the Ask AI page // Use includes() for flexibility (handles trailing slash or .html) if (currentPath.includes(askAiPagePath.replace(/\/$/, ''))) { // Remove trailing slash for includes check console.log("Floating Ask AI Button: Not adding button on the Ask AI page itself."); return; // Don't add the button on the target page } // --- Create the button --- const fabLink = document.createElement('a'); fabLink.className = 'floating-ask-ai-button'; fabLink.href = askAiPagePath; // Construct the correct URL fabLink.title = 'Ask Crawl4AI Assistant'; fabLink.setAttribute('aria-label', 'Ask Crawl4AI Assistant'); // Add content (using SVG icon for better visuals) fabLink.innerHTML = ` Ask AI `; // Append to body document.body.appendChild(fabLink); console.log("Floating Ask AI Button added."); });