Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const form = document.querySelector('.input-form');
+ const textarea = form.querySelector('textarea');
+ const messages = document.querySelector('.messages');
+
+ // Auto-resize textarea
+ textarea.addEventListener('input', () => {
+ textarea.style.height = 'auto';
+ textarea.style.height = textarea.scrollHeight + 'px';
+ });
+
+ // Handle form submission
+ form.addEventListener('submit', (e) => {
+ e.preventDefault();
+ const message = textarea.value.trim();
+
+ if (!message) return;
+
+ // Add user message
+ addMessage('user', message);
+
+ // Clear input
+ textarea.value = '';
+ textarea.style.height = 'auto';
+
+ // Simulate Claude response
+ simulateResponse(message);
+ });
+
+ function addMessage(type, content) {
+ const messageDiv = document.createElement('div');
+ messageDiv.classList.add('message', type);
+ messageDiv.innerHTML = `
+ `;
+ messages.appendChild(messageDiv);
+ messages.scrollTop = messages.scrollHeight;
+ }
+
+ function simulateResponse(userMessage) {
+ // Add loading state
+ const loadingDiv = document.createElement('div');
+ loadingDiv.classList.add('message', 'assistant', 'loading');
+ loadingDiv.textContent = 'Claude is thinking...';
+ messages.appendChild(loadingDiv);
+
+ // Simulate typing delay
+ setTimeout(() => {
+ messages.removeChild(loadingDiv);
+ addMessage('assistant', `I understand you said: "${userMessage}". However, I'm just a frontend demo and can't actually process requests. To chat with the real Claude, please visit the official Anthropic website.`);
+ }, 1500);
+ }
+
+ // Handle new chat button
+ document.querySelector('.new-chat').addEventListener('click', () => {
+ messages.innerHTML = '';
+ const welcomeMessage = document.createElement('div');
+ welcomeMessage.classList.add('welcome-message');
+ welcomeMessage.innerHTML = `
+
Welcome to Claude Chat
+
How can I help you today?
+ `;
+ messages.appendChild(welcomeMessage);
+ });
+ });