| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Agil Support</title> |
| <style> |
| * { |
| margin: 0; |
| padding: 0; |
| box-sizing: border-box; |
| } |
| body { |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
| background: #f5f5f5; |
| } |
| .chat-container { |
| max-width: 400px; |
| margin: 20px auto; |
| background: white; |
| border-radius: 12px; |
| box-shadow: 0 4px 20px rgba(0,0,0,0.1); |
| overflow: hidden; |
| } |
| .chat-header { |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| color: white; |
| padding: 20px; |
| text-align: center; |
| } |
| .chat-header h3 { |
| font-size: 18px; |
| margin-bottom: 5px; |
| } |
| .chat-header p { |
| font-size: 12px; |
| opacity: 0.9; |
| } |
| .chat-messages { |
| height: 400px; |
| overflow-y: auto; |
| padding: 20px; |
| display: flex; |
| flex-direction: column; |
| gap: 12px; |
| } |
| .message { |
| max-width: 80%; |
| padding: 12px 16px; |
| border-radius: 18px; |
| font-size: 14px; |
| line-height: 1.4; |
| } |
| .user-message { |
| background: #667eea; |
| color: white; |
| align-self: flex-end; |
| border-bottom-right-radius: 4px; |
| } |
| .bot-message { |
| background: #f0f0f0; |
| color: #333; |
| align-self: flex-start; |
| border-bottom-left-radius: 4px; |
| } |
| .typing-indicator { |
| display: none; |
| align-self: flex-start; |
| padding: 12px 16px; |
| background: #f0f0f0; |
| border-radius: 18px; |
| border-bottom-left-radius: 4px; |
| } |
| .typing-dots { |
| display: inline-block; |
| } |
| .typing-dots span { |
| display: inline-block; |
| width: 4px; |
| height: 4px; |
| border-radius: 50%; |
| background: #999; |
| margin: 0 1px; |
| animation: typing 1.4s infinite; |
| } |
| .typing-dots span:nth-child(2) { |
| animation-delay: 0.2s; |
| } |
| .typing-dots span:nth-child(3) { |
| animation-delay: 0.4s; |
| } |
| @keyframes typing { |
| 0%, 60%, 100% { transform: translateY(0); } |
| 30% { transform: translateY(-10px); } |
| } |
| .chat-input { |
| display: flex; |
| padding: 20px; |
| border-top: 1px solid #eee; |
| gap: 10px; |
| } |
| .chat-input input { |
| flex: 1; |
| padding: 12px 16px; |
| border: 1px solid #ddd; |
| border-radius: 24px; |
| outline: none; |
| font-size: 14px; |
| } |
| .chat-input input:focus { |
| border-color: #667eea; |
| } |
| .send-btn { |
| padding: 12px 20px; |
| background: #667eea; |
| color: white; |
| border: none; |
| border-radius: 24px; |
| cursor: pointer; |
| font-size: 14px; |
| transition: background 0.3s; |
| } |
| .send-btn:hover { |
| background: #5a6fd8; |
| } |
| .send-btn:disabled { |
| background: #ccc; |
| cursor: not-allowed; |
| } |
| .quick-questions { |
| padding: 20px; |
| border-top: 1px solid #eee; |
| } |
| .quick-questions h4 { |
| font-size: 14px; |
| margin-bottom: 10px; |
| color: #666; |
| } |
| .question-btn { |
| display: block; |
| width: 100%; |
| padding: 8px 12px; |
| margin-bottom: 6px; |
| background: #f8f9ff; |
| border: 1px solid #e0e5ff; |
| border-radius: 8px; |
| color: #667eea; |
| font-size: 12px; |
| cursor: pointer; |
| text-align: left; |
| transition: all 0.3s; |
| } |
| .question-btn:hover { |
| background: #667eea; |
| color: white; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="chat-container"> |
| <div class="chat-header"> |
| <h3>Agil Support</h3> |
| <p>Ask me anything about the platform</p> |
| </div> |
| <div class="chat-messages" id="messages"> |
| <div class="message bot-message"> |
| Hi! I'm here to help with OncoConnect questions. Ask me about accounts, image uploads, trials, or challenges! |
| </div> |
| </div> |
| <div class="typing-indicator" id="typing"> |
| <div class="typing-dots"> |
| <span></span> |
| <span></span> |
| <span></span> |
| </div> |
| </div> |
| <div class="chat-input"> |
| <input type="text" id="messageInput" placeholder="Type your question..." maxlength="200"> |
| <button id="sendBtn" class="send-btn">Send</button> |
| </div> |
| <div class="quick-questions"> |
| <h4>Quick Questions:</h4> |
| <button class="question-btn" onclick="askQuestion('How do I create an account?')">How do I create an account?</button> |
| <button class="question-btn" onclick="askQuestion('What file types can I upload?')">What file types can I upload?</button> |
| <button class="question-btn" onclick="askQuestion('How do I join a challenge?')">How do I join a challenge?</button> |
| <button class="question-btn" onclick="askQuestion('Is this tool FDA cleared?')">Is this tool FDA cleared?</button> |
| </div> |
| </div> |
| |
| <script> |
| const messagesContainer = document.getElementById('messages'); |
| const messageInput = document.getElementById('messageInput'); |
| const sendBtn = document.getElementById('sendBtn'); |
| const typing = document.getElementById('typing'); |
| |
| async function sendMessage(message) { |
| if (!message.trim()) return; |
| |
| |
| addMessage(message, 'user'); |
| messageInput.value = ''; |
| sendBtn.disabled = true; |
| |
| typing.style.display = 'block'; |
| messagesContainer.scrollTop = messagesContainer.scrollHeight; |
| |
| try { |
| const response = await fetch('http://localhost:5000/chat', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify({ message: message }) |
| }); |
| |
| if (!response.ok) { |
| throw new Error('Network response was not ok'); |
| } |
| |
| const data = await response.json(); |
| |
| typing.style.display = 'none'; |
| |
| addMessage(data.response, 'bot'); |
| } catch (error) { |
| typing.style.display = 'none'; |
| addMessage('Sorry, I encountered an error. Please try again.', 'bot'); |
| console.error('Error:', error); |
| } |
| |
| sendBtn.disabled = false; |
| } |
| |
| function addMessage(text, sender) { |
| const messageDiv = document.createElement('div'); |
| messageDiv.className = `message ${sender}-message`; |
| messageDiv.textContent = text; |
| messagesContainer.appendChild(messageDiv); |
| messagesContainer.scrollTop = messagesContainer.scrollHeight; |
| } |
| |
| function askQuestion(question) { |
| messageInput.value = question; |
| sendMessage(question); |
| } |
| |
| sendBtn.addEventListener('click', () => { |
| sendMessage(messageInput.value); |
| }); |
| |
| messageInput.addEventListener('keypress', (e) => { |
| if (e.key === 'Enter') { |
| sendMessage(messageInput.value); |
| } |
| }); |
| |
| messageInput.addEventListener('input', () => { |
| sendBtn.disabled = !messageInput.value.trim(); |
| }); |
| </script> |
| </body> |
| </html> |
|
|