diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index 0fa31e5..cfc591d 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -687,8 +687,16 @@ class KidsAIExplorer { // For pure "don't know" responses with Socratic guidance, continue to next question immediately this.continueToNextQuestion(); } else { - // For substantial answers, show choice buttons - this.addContinueChoiceButtons(); + // Check if AI response contains a question that needs answering + const hasQuestion = data.response && data.response.includes('?'); + + if (hasQuestion) { + // AI asked a follow-up question, provide input area + this.addUserInputArea(); + } else { + // No question in response, show choice buttons + this.addContinueChoiceButtons(); + } } }, 1500); } else { @@ -1100,6 +1108,13 @@ class KidsAIExplorer { // Add input area for user to respond addUserInputArea() { + // Remove any existing input areas to avoid duplicates + const existingInputs = this.conversationContainer.querySelectorAll('.user-input-container'); + existingInputs.forEach(input => input.remove()); + + // Generate unique ID for this input + const inputId = `chat-input-${Date.now()}`; + const inputContainer = document.createElement('div'); inputContainer.className = 'user-input-container'; inputContainer.innerHTML = ` @@ -1107,9 +1122,9 @@ class KidsAIExplorer {

💭 ${this.getTranslation('share-thoughts') || (this.currentLanguage === 'de' ? 'Teile deine Gedanken mit:' : 'Share your thoughts:')}

- -
@@ -1123,18 +1138,18 @@ class KidsAIExplorer { this.scrollToBottomSmoothly(); // Focus on textarea - const textarea = inputContainer.querySelector('#chat-input'); + const textarea = inputContainer.querySelector(`#${inputId}`); if (textarea) { textarea.focus(); } }, 200); } - // Submit chat answer - submitChatAnswer() { - const textarea = document.getElementById('chat-input'); + // Submit chat answer from dynamic input with specific ID + submitChatAnswerFromInput(inputId) { + const textarea = document.getElementById(inputId); if (!textarea) { - console.error('❌ Chat input not found'); + console.error('❌ Chat input not found with ID:', inputId); return; }