UNPKG

@spectrumsense/spectrum-chat-dev

Version:

Embeddable AI Widget - Add trusted, evidence-based answers directly to your website. Simple installation, enterprise-grade security.

225 lines (195 loc) โ€ข 6.48 kB
<!-- This would extend template-base.html in a real framework --> <!-- {% extends "template-base.html" %} --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Home Page - Template Example</title> <!-- Global Chat Configuration - Only add this once in your main template! --> <script> window.SpectrumChatConfig = { apiUrl: 'http://localhost:8000/api/v1/conversations', tenantId: 'brightspectrum-tenant-123', title: 'Bright Spectrum AI Assistant', introText: 'I am Bright Spectrum AI Assistant. I can answer questions about our programs, costs, and services.', primaryColor: 'hsl(145 73% 35%)', userColor: 'hsl(195 82% 45%)', aiColor: 'hsl(145 73% 35%)', position: 'bottom-right', width: '320px', height: '350px', showIntro: true, enableCitations: false, debug: true }; </script> <!-- Global Chat Script - Only include this once in your main template! --> <script src="../../dist/spectrum-chat.js"></script> <style> body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.6; color: #1f2937; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; margin: 0; padding: 0; } .container { max-width: 1200px; margin: 0 auto; padding: 2rem; } .hero { text-align: center; color: white; margin-bottom: 3rem; } .hero h1 { font-size: 3rem; font-weight: 700; margin-bottom: 1rem; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .hero p { font-size: 1.25rem; opacity: 0.9; max-width: 600px; margin: 0 auto; } .demo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 2rem; margin-bottom: 3rem; } .demo-card { background: white; border-radius: 1rem; padding: 2rem; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .demo-card:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15); } .demo-card h3 { color: #1f2937; margin-bottom: 1rem; font-size: 1.5rem; font-weight: 600; } .demo-card p { color: #6b7280; margin-bottom: 1.5rem; } .button { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; font-weight: 500; text-decoration: none; display: inline-block; margin: 0.25rem; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3); } .button:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(59, 130, 246, 0.4); } .button-container { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; } .navigation { background: white; border-radius: 1rem; padding: 2rem; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); margin-bottom: 2rem; } .navigation h3 { color: #1f2937; margin-bottom: 1rem; text-align: center; } .nav-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; } .nav-link { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; padding: 0.75rem 1.5rem; border-radius: 0.5rem; text-decoration: none; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3); } .nav-link:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(16, 185, 129, 0.4); } </style> </head> <body> <div class="container"> <div class="hero"> <h1>๐Ÿš€ Template-Based Global Chat</h1> <p>This demonstrates how customers would implement the chat widget in their main template.</p> </div> <div class="demo-grid"> <div class="demo-card"> <h3>โœจ Template Implementation</h3> <p>This page extends the main template that includes the chat script. The chat widget appears automatically on all pages.</p> <div class="button-container"> <button class="button" onclick="window.SpectrumChatGlobal.open()">Open Chat</button> <button class="button" onclick="alert('Conversation ID: ' + (window.SpectrumChatGlobal.getConversationId() || 'No conversation started yet'))">Get Conversation ID</button> </div> </div> <div class="demo-card"> <h3>๐Ÿ”„ Cross-Page Persistence</h3> <p>Navigate to other pages to test that the conversation persists across page navigation.</p> <div class="button-container"> <button class="button" onclick="window.SpectrumChatGlobal.close()">Close Chat</button> <button class="button" onclick="window.SpectrumChatGlobal.clearSession(); alert('Session cleared!')">Clear Session</button> </div> </div> </div> <div class="navigation"> <h3>๐Ÿงช Test Cross-Page Navigation</h3> <p style="text-align: center; color: #6b7280; margin-bottom: 1.5rem;"> Open the chat, send a message, then navigate to different pages to test persistence. <strong>All pages extend the same template!</strong> </p> <div class="nav-links"> <a href="template-home.html" class="nav-link">๐Ÿ  Home Page</a> <a href="template-page1.html" class="nav-link">๐Ÿ“„ Page 1</a> <a href="template-page2.html" class="nav-link">๐Ÿ“„ Page 2</a> <a href="template-page3.html" class="nav-link">๐Ÿ“„ Page 3</a> </div> </div> </div> <script> console.log('Template Home Page loaded'); console.log('SpectrumChatGlobal available:', !!window.SpectrumChatGlobal); // Log when page loads setTimeout(() => { const convId = window.SpectrumChatGlobal.getConversationId(); console.log('Current conversation ID on home page:', convId); }, 1000); </script> </body> </html>