diff --git a/html/kidsai/PUBLIC-DOMAIN-SUCCESS.md b/html/kidsai/PUBLIC-DOMAIN-SUCCESS.md index 6c22cbe..e69de29 100644 --- a/html/kidsai/PUBLIC-DOMAIN-SUCCESS.md +++ b/html/kidsai/PUBLIC-DOMAIN-SUCCESS.md @@ -1,77 +0,0 @@ -# 🌐 Public Domain Setup Complete! - -## ✅ **Your KidsAI Explorer is now live on the public domain!** - -### 🚀 **Access URLs** - -- **Main Application**: https://portal.egonetix.de/kidsai/ -- **Testing Interface**: https://portal.egonetix.de/kidsai/test-ai.html -- **API Health Check**: https://portal.egonetix.de/api/health - -### 🔧 **What Was Fixed** - -1. **Nginx Proxy Configuration**: Updated port from 3000 → 3002 -2. **API Routing**: All `/api/*` requests now properly routed to backend -3. **Static File Serving**: Added dedicated location block for KidsAI files -4. **Timeout Settings**: Increased timeouts for AI processing -5. **Service Setup**: Created systemd service for reliable production deployment - -### 📊 **Technical Details** - -#### Nginx Configuration -```nginx -# API Proxy (port 3002) -location /api/ { - proxy_pass http://127.0.0.1:3002; - # Enhanced headers and timeouts for AI processing -} - -# Static Files -location /kidsai/ { - alias /var/www/html/kidsai/; - try_files $uri $uri/ /kidsai/index.html; -} -``` - -#### Production Service -```bash -# Service status -systemctl status kidsai-explorer - -# Service logs -journalctl -f -u kidsai-explorer - -# Restart service -systemctl restart kidsai-explorer -``` - -### ✅ **Verification Tests** - -All endpoints tested and working: - -- ✅ **Health Check**: `GET /api/health` -- ✅ **AI Questions**: `POST /api/ask` -- ✅ **Answer Reveal**: `POST /api/reveal-answer` -- ✅ **Static Files**: CSS, JS, images all loading -- ✅ **HTTPS**: Secure connection working - -### 🎯 **Production Ready Features** - -- **Auto-restart**: Service restarts on failure -- **Security**: Proper user isolation and permissions -- **Logging**: Centralized logging via systemd -- **Performance**: Optimized caching for static assets -- **SSL**: Secure HTTPS communication -- **High Availability**: Multiple fallback layers for AI - -### 🌟 **Your KidsAI Explorer is now live!** - -**Visit**: https://portal.egonetix.de/kidsai/ - -The application will work exactly the same as localhost, but now: -- ✅ Accessible from anywhere on the internet -- ✅ Secure HTTPS connection -- ✅ Production-grade reliability -- ✅ Auto-scaling and monitoring ready - -**Share it with kids worldwide! 🚀🌍** diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index c667486..fece8fb 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -11,55 +11,7 @@ class KidsAIExplorer { this.questionInput = document.getElementById('question-input'); this.askButton = document.getElementById('ask-button'); this.thinkingSection = document.getElementById('thinking-section'); - this.thinkingSteps = document // Topic-specific contextual responses - - // BICYCLE BRAKE RESPO // Generic responses based on answer quality (as last resort) - if (answer.length > 25) { - return "🌟 I appreciate your detailed explanation! You're really working through this systematically."; - } else if (answer.length > 15) { - return "👍 Good thinking! I can see you're considering different aspects of this."; - } else if (answer.length > 8) { - return "💭 Interesting! Can you help me understand your reasoning a bit more?"; - } else if (answer.length > 3) { - return "🤔 I see what you're thinking. Can you elaborate on that?"; - } else { - return "💡 Feel free to share any thoughts - every idea helps us learn!"; - } if (questionLower.includes('bicycle') && questionLower.includes('brake')) { - if (answerLower.includes('slow') || answerLower.includes('stop')) { - return "🚴♂️ Exactly right! You understand that brakes slow you down and stop you. That's the basic function we need to understand!"; - } else if (answerLower.includes('wheel') || answerLower.includes('rim')) { - return "🎯 Great technical thinking! You understand how the brake mechanism works on the wheel!"; - } else { - return "🤔 Tell me more about what happens when you use bicycle brakes."; - } - } - - // CAR BRAKE RESPONSES - This is the key fix! - if (questionLower.includes('car') && (questionLower.includes('brake') || questionLower.includes('slow down') || questionLower.includes('stop'))) { - if ((answerLower.includes('brake') && answerLower.includes('?')) || answer.trim().toLowerCase() === 'the brake') { - return "🎯 EXACTLY! 🚗 Yes, it's the brake system! Perfect answer - the brake pedal controls the brakes that slow down or stop the car!"; - } else if (answerLower.includes('brake') && answerLower.includes('pedal')) { - return "🏆 Perfect! The brake pedal and brake system work together to control the car's speed. You nailed it!"; - } else if (answerLower.includes('brake')) { - return "🎯 YES! The brakes! You got it exactly right! The brake system is what slows down and stops the car!"; - } else if (answerLower.includes('wheel') || answerLower.includes('tire')) { - return "👍 You're thinking about where the braking happens - at the wheels! The brake system applies pressure there."; - } else if (answerLower.includes('pedal')) { - return "🦶 Good! You're thinking about pedals. Which specific pedal controls stopping?"; - } else { - return "🤔 What component do you think actually does the slowing down in a car?"; - } - } - - if (questionLower.includes('bicycle') || questionLower.includes('pedal') || questionLower.includes('chain')) { - if (answerLower.includes('pedal') || answerLower.includes('chain') || answerLower.includes('wheel')) { - return "🚴♂️ Excellent! You understand the connection between pedals, chain, and wheels. That mechanical connection concept is key!"; - } else if (answerLower.includes('gear') || answerLower.includes('speed')) { - return "👍 Yes! You're thinking about how we control speed and power - that's exactly right!"; - } else if (answerLower.includes('slow') || answerLower.includes('stop')) { - return "🚴♂️ Right! You understand the basic control functions of bicycles!"; - } - }entById('thinking-steps'); + this.thinkingSteps = document.getElementById('thinking-steps'); this.loadingOverlay = document.getElementById('loading'); this.suggestionCards = document.querySelectorAll('.suggestion-card'); this.langButtons = document.querySelectorAll('.lang-btn'); diff --git a/html/kidsai/script.js b/html/kidsai/script.js index 5af2ed3..98f7496 100644 --- a/html/kidsai/script.js +++ b/html/kidsai/script.js @@ -1,4 +1,6 @@ // KidsAI Explorer - Interactive Learning Assistant +console.log('🚀 KidsAI script.js is loading...'); + class KidsAIExplorer { constructor() { this.currentLanguage = localStorage.getItem('kidsai-language') || 'en'; @@ -8,10 +10,17 @@ class KidsAIExplorer { this.askButton = document.getElementById('ask-button'); this.thinkingSection = document.getElementById('thinking-section'); this.thinkingSteps = document.getElementById('thinking-steps'); + this.actionButtons = document.getElementById('action-buttons'); this.loadingOverlay = document.getElementById('loading'); this.suggestionCards = document.querySelectorAll('.suggestion-card'); this.langButtons = document.querySelectorAll('.lang-btn'); + // Debug: Log what elements we found + console.log('🔍 DOM Elements found:'); + console.log('questionInput:', this.questionInput); + console.log('askButton:', this.askButton); + console.log('suggestionCards count:', this.suggestionCards.length); + // Ensure loading is hidden initially if (this.loadingOverlay) { this.loadingOverlay.classList.add('hidden'); @@ -81,11 +90,14 @@ class KidsAIExplorer { // Clear thinking section if visible if (!this.thinkingSection.classList.contains('hidden')) { this.thinkingSection.classList.add('hidden'); + this.actionButtons.classList.add('hidden'); this.thinkingSteps.innerHTML = ''; } } initializeEventListeners() { + console.log('Initializing event listeners'); + // Language switching this.langButtons.forEach(btn => { btn.addEventListener('click', () => { @@ -94,24 +106,46 @@ class KidsAIExplorer { }); // Main question submission - this.askButton.addEventListener('click', () => this.handleQuestion()); - this.questionInput.addEventListener('keypress', (e) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault(); - this.handleQuestion(); - } - }); + if (this.askButton) { + console.log('Adding click listener to ask button'); + this.askButton.addEventListener('click', () => this.handleQuestion()); + } + + if (this.questionInput) { + console.log('Adding keypress listener to question input'); + this.questionInput.addEventListener('keypress', (e) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + this.handleQuestion(); + } + }); + } // Suggestion cards + console.log('Adding listeners to suggestion cards:', this.suggestionCards.length); this.suggestionCards.forEach(card => { card.addEventListener('click', () => { + console.log('Suggestion card clicked'); const questionKey = `data-question-${this.currentLanguage}`; const question = card.getAttribute(questionKey); + console.log('Setting question:', question); this.questionInput.value = question; this.handleQuestion(); }); }); + // Action buttons + document.getElementById('research-btn').addEventListener('click', () => { + this.showActionGuidance('research'); + }); + + document.getElementById('experiment-btn').addEventListener('click', () => { + this.showActionGuidance('experiment'); + }); + + document.getElementById('discuss-btn').addEventListener('click', () => { + this.showActionGuidance('discuss'); + }); } initializeAnimations() { @@ -123,7 +157,10 @@ class KidsAIExplorer { } async handleQuestion() { + console.log('handleQuestion called'); const question = this.questionInput.value.trim(); + console.log('Question:', question); + if (!question) { this.showMessage('Please ask me something first! 🤔', 'warning'); return; @@ -172,122 +209,33 @@ class KidsAIExplorer { displayAIGuidance(guidance, isFallback) { // Clear any previous content this.thinkingSteps.innerHTML = ''; + this.currentStep = 0; + this.userAnswers = []; - // Show encouragement - const encouragementDiv = document.createElement('div'); - encouragementDiv.className = 'encouragement-message'; - encouragementDiv.innerHTML = ` -
${guidance.encouragement}
+ ${isFallback ? '💻 Offline mode' : '✨ AI-powered'}${step.text}
+${this.currentLanguage === 'de' + ? 'Du hast wirklich gut nachgedacht! Jetzt bist du bereit, die richtige Antwort zu entdecken.' + : 'You\'ve done some great thinking! Now you\'re ready to discover the actual answer.'}
+${this.currentLanguage === 'de' - ? 'Nachdem du über die Fragen nachgedacht hast, möchtest du die richtige Antwort erfahren?' - : 'After thinking through the questions, would you like to discover the actual answer?'}
- -${data.explanation}
+${this.currentLanguage === 'de' - ? '🎉 Großartig! Wie nah warst du mit deinen Überlegungen?' - : '🎉 Awesome! How close were your thoughts to the answer?'}
+ ? '🌟 Großartig! Du hast durch deine eigenen Gedanken gelernt!' + : '🌟 Great! You learned by thinking it through yourself!'}${this.currentLanguage === 'de' + ? 'Ich kann die Antwort gerade nicht laden. Aber du hast schon toll nachgedacht! Frag gerne einen Erwachsenen oder schaue in einem Buch nach.' + : 'I can\'t load the answer right now. But you\'ve done great thinking! Feel free to ask an adult or look it up in a book.'}
+${this.currentLanguage === 'de' ? 'Denk daran:' : 'Remember:'} ${t.actionReminder}
+${this.currentLanguage === 'de' - ? 'Nachdem du die Schritte durchdacht hast, was ist dein Ergebnis?' - : 'After thinking through the steps, what is your result?'}
-${this.currentLanguage === 'de' - ? 'Hast du alle Schritte durchgedacht und eine Antwort gefunden? Klicke hier, wenn du bereit bist!' - : 'Have you thought through all the steps and found an answer? Click when you\'re ready!'}
- -${this.currentLanguage === 'de' - ? 'Bitte gib deine Antwort ein!' - : 'Please enter your answer!'}
-${this.currentLanguage === 'de' - ? 'Das ist nicht ganz richtig. Keine Sorge, das passiert!' - : 'That\'s not quite right. Don\'t worry, it happens!'}
- ${hint ? `${hint}` : ''} -${hints.encouragement}
-${message}
-${feedback.response}
- ✨ AI Teacher - ${isAIQuestion ? ` -${this.currentLanguage === 'de' - ? 'Tolle Unterhaltung! Du hast großartig mitgedacht.' - : 'Great conversation! You thought along wonderfully.'}
-${guidance.encouragement}
+ ${isFallback ? '💻 Offline mode' : '✨ AI-powered'} +${step.text}
+${this.currentLanguage === 'de' + ? 'Du hast wirklich gut nachgedacht! Jetzt bist du bereit, die richtige Antwort zu entdecken.' + : 'You\'ve done some great thinking! Now you\'re ready to discover the actual answer.'}
+${data.explanation}
+${this.currentLanguage === 'de' + ? '🌟 Großartig! Du hast durch deine eigenen Gedanken gelernt!' + : '🌟 Great! You learned by thinking it through yourself!'}
+${this.currentLanguage === 'de' + ? 'Ich kann die Antwort gerade nicht laden. Aber du hast schon toll nachgedacht! Frag gerne einen Erwachsenen oder schaue in einem Buch nach.' + : 'I can\'t load the answer right now. But you\'ve done great thinking! Feel free to ask an adult or look it up in a book.'}
+${this.currentLanguage === 'de' ? 'Lass uns das Schritt für Schritt erforschen und dir helfen, ein fantastischer Problemlöser zu werden!' : 'Let\'s explore this step by step and help you become a fantastic problem solver!'}
+ `; + this.thinkingSteps.appendChild(encouragementDiv); + + // Add thinking steps with animation delay + guidance.framework.steps.forEach((step, index) => { + setTimeout(() => { + const stepDiv = document.createElement('div'); + stepDiv.className = 'thinking-step'; + stepDiv.innerHTML = ` +${step.content}
+ `; + this.thinkingSteps.appendChild(stepDiv); + + // Show action buttons after all steps are displayed + if (index === guidance.framework.steps.length - 1) { + setTimeout(() => { + this.actionButtons.classList.remove('hidden'); + this.actionButtons.style.animation = 'fadeInUp 0.6s ease-out'; + + // Store suggestions for action buttons + this.currentSuggestions = guidance.actionSuggestions; + }, 300); + } + }, index * 500); + }); + + // Show thinking section + this.thinkingSection.classList.remove('hidden'); + this.thinkingSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + + showActionGuidance(actionType) { + const t = translations[this.currentLanguage]; + const actionTitles = t.actionTitles; + + const suggestions = this.currentSuggestions[actionType]; + + let content = `${this.currentLanguage === 'de' ? 'Denk daran:' : 'Remember:'} ${t.actionReminder}
+${guidance.encouragement}
+ ${isFallback ? '💻 Offline mode' : '✨ AI-powered'} +${step.text}
+${this.currentLanguage === 'de' + ? 'Du hast wirklich gut nachgedacht! Jetzt bist du bereit, die richtige Antwort zu entdecken.' + : 'You\'ve done some great thinking! Now you\'re ready to discover the actual answer.'}
+${data.explanation}
+${this.currentLanguage === 'de' + ? '🌟 Großartig! Du hast durch deine eigenen Gedanken gelernt!' + : '🌟 Great! You learned by thinking it through yourself!'}
+${this.currentLanguage === 'de' + ? 'Ich kann die Antwort gerade nicht laden. Aber du hast schon toll nachgedacht! Frag gerne einen Erwachsenen oder schaue in einem Buch nach.' + : 'I can\'t load the answer right now. But you\'ve done great thinking! Feel free to ask an adult or look it up in a book.'}
+${this.currentLanguage === 'de' + ? '🎉 Großartig! Wie nah warst du mit deinen Überlegungen?' + : '🎉 Awesome! How close were your thoughts to the answer?'}
+${this.currentLanguage === 'de' ? 'Lass uns das Schritt für Schritt erforschen und dir helfen, ein fantastischer Problemlöser zu werden!' : 'Let\'s explore this step by step and help you become a fantastic problem solver!'}
+ `; + this.thinkingSteps.appendChild(encouragementDiv); + + // Add thinking steps with animation delay + guidance.framework.steps.forEach((step, index) => { + setTimeout(() => { + const stepDiv = document.createElement('div'); + stepDiv.className = 'thinking-step'; + stepDiv.innerHTML = ` +${step.content}
+ `; + this.thinkingSteps.appendChild(stepDiv); + + // Show action buttons after all steps are displayed + if (index === guidance.framework.steps.length - 1) { + setTimeout(() => { + this.actionButtons.classList.remove('hidden'); + this.actionButtons.style.animation = 'fadeInUp 0.6s ease-out'; + + // Store suggestions for action buttons + this.currentSuggestions = guidance.actionSuggestions; + }, 300); + } + }, index * 500); + }); + + // Show thinking section + this.thinkingSection.classList.remove('hidden'); + this.thinkingSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + + showActionGuidance(actionType) { + const t = translations[this.currentLanguage]; + const actionTitles = t.actionTitles; + + const suggestions = this.currentSuggestions[actionType]; + + let content = `${this.currentLanguage === 'de' ? 'Denk daran:' : 'Remember:'} ${t.actionReminder}
+