| 118 | |
| 119 | // Update loading state |
| 120 | function updateLoadingState(isLoading) { |
| 121 | if (sendButton) { |
| 122 | sendButton.disabled = isLoading |
| 123 | sendButton.textContent = isLoading ? 'Sending...' : 'Send' |
| 124 | } |
| 125 | |
| 126 | if (messageInput) { |
| 127 | messageInput.disabled = isLoading |
| 128 | } |
| 129 | |
| 130 | // Show typing indicator |
| 131 | if (isLoading && messagesContainer) { |
| 132 | const typingIndicator = document.createElement('div') |
| 133 | typingIndicator.className = 'message assistant typing' |
| 134 | typingIndicator.id = 'typing-indicator' |
| 135 | typingIndicator.innerHTML = '<div class="message-content">...</div>' |
| 136 | messagesContainer.appendChild(typingIndicator) |
| 137 | messagesContainer.scrollTop = messagesContainer.scrollHeight |
| 138 | } else { |
| 139 | const indicator = document.getElementById('typing-indicator') |
| 140 | if (indicator) { |
| 141 | indicator.remove() |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // Show error |
| 147 | function showError(error) { |