📘 Solve Your Study Problems Instantly with Our Free AI Question Solver Tool

📘 Solve Your Study Problems Instantly with Our Free AI Question Solver Tool

Are you tired of struggling with homework or exam preparation? Whether it's Urdu, English, Math, Physics, Chemistry, or Biology, students often face confusion and a lack of guidance — especially when help isn’t available at the right time.

We’ve created the perfect solution for you: a free, intelligent AI tool that solves your academic problems instantly, with clear, easy-to-understand answers. 💡

📘 Solve Your Study Problems Instantly with Our Free AI Question Solver Tool



🎯 What is the AI Question Solver Tool?

Our AI Question Solver is an all-in-one educational assistant powered by Google Gemini (free version). It allows students to:

✅ Ask any question in Urdu or English
✅ Get quick, accurate answers with explanations
✅ Understand concepts, formulas, and grammar rules
✅ Prepare for exams effectively without stress
✅ Study smarter anytime, anywhere — for free!


📚 Subjects Supported

Our AI tool currently supports these key subjects:

  • 📝 Urdu – Grammar, essays, comprehension, and more

  • ✍️ English – Grammar, vocabulary, tenses, paragraph writing

  • Math – Equations, algebra, geometry, word problems

  • 🔬 Physics – Concepts, formulas, numerical solutions

  • 🧪 Chemistry – Reactions, structures, MCQs, theory

  • 🧬 Biology – Diagrams, systems, definitions, questions

Whether you're in Grade 6 or FSC, our AI adapts to your level!


⚡ Key Features

  • 🧠 Powered by Google Gemini AI (Free API)

  • 🌐 No signup required

  • 📱 Fully responsive – Use on mobile or desktop

  • 🔄 24/7 access – Study anytime

  • 🆓 Completely free to use


💻 How to Use It?

  1. Visit our website.

  2. Type your question in Urdu or English.

  3. Press the “Ask AI” button.

  4. Get a clear, complete answer instantly!

It’s that simple.


🎓 Who Should Use This Tool?

  • 📚 School & college students preparing for exams

  • 👨‍👩‍👧‍👦 Parents helping their kids with homework

  • 📖 Anyone who wants to learn or revise concepts quickly

This tool is designed to empower learners in Pakistan and across the world by making education more accessible.


📣 Final Words

Learning should never be a burden. With our AI Question Solver, you're just one click away from getting help in any subject. No more waiting for tutors or getting stuck — let AI guide you to success.


🔗 Try It Now!

👉 Click here to use the tool: [Insert Your Tool Link]

💬 Got questions? Contact us or share your feedback.
📢 Don’t forget to share this amazing tool with your classmates and friends!


🔎 Suggested Keywords (for SEO):

Free AI Question Solver in Pakistan, Homework help AI tool, Urdu Math Science AI, Gemini AI for students, AI study help tool, Exam preparation with AI, Free study tools for Pakistan, AI tutor in Urdu

Final Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>StudyBot Pro - Multi-Language AI Assistant</title>
    
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
    
    <!-- Marked.js and Highlight.js for Code Formatting -->
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/lib/common.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.9.0/styles/atom-one-dark.css">

    <style>
        /* Saare CSS styles pehle jaise hi hain, koi tabdeeli nahi */
        :root { --background-primary: #f7f9fc; --background-secondary: #ffffff; --text-primary: #1e293b; --text-secondary: #64748b; --accent-primary: #3b82f6; --accent-hover: #2563eb; --border-color: #e2e8f0; --shadow-color: rgba(0, 0, 0, 0.05); --sidebar-bg: #eef2f9; --sidebar-hover: #dfe6f2; }
        .dark-mode { --background-primary: #0b1120; --background-secondary: #1a233a; --text-primary: #f1f5f9; --text-secondary: #94a3b8; --accent-primary: #3b82f6; --accent-hover: #60a5fa; --border-color: #334155; --shadow-color: rgba(0, 0, 0, 0.15); --sidebar-bg: #131b2f; --sidebar-hover: #1e294a; }
        * { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
        body { font-family: 'Poppins', sans-serif; background: var(--background-primary); color: var(--text-primary); transition: background 0.3s ease, color 0.3s ease; }
        .app-layout { display: flex; height: 100vh; }
        .sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 16px; transition: background 0.3s ease, border-color 0.3s ease; }
        .sidebar-header { padding: 8px; margin-bottom: 20px; }
        .sidebar-header h1 { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
        .new-chat-btn { width: 100%; padding: 12px; background: var(--accent-primary); color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: background-color 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 20px; }
        .chat-history { flex-grow: 1; overflow-y: auto; }
        .history-title { font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; padding: 0 8px; }
        .history-item { padding: 10px 12px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: var(--text-secondary); font-size: 0.9rem; transition: background-color 0.2s ease, color 0.2s ease; }
        .history-item.active { background: var(--accent-primary); color: white; font-weight: 500; }
        .sidebar-footer { padding-top: 16px; border-top: 1px solid var(--border-color); }
        .theme-switcher, .language-switcher { display: flex; align-items: center; justify-content: space-between; padding: 8px; border-radius: 6px; background: var(--background-primary); margin-top: 10px; }
        .theme-switcher span, .language-switcher span { font-size: 0.9rem; font-weight: 500; }
        #languageSelector { background: var(--sidebar-bg); border: 1px solid var(--border-color); border-radius: 4px; padding: 4px; color: var(--text-primary); }
        .toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
        .toggle-switch input { opacity: 0; width: 0; height: 0; }
        .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
        .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
        input:checked + .slider { background-color: var(--accent-primary); }
        input:checked + .slider:before { transform: translateX(20px); }
        .main-content { flex-grow: 1; display: flex; flex-direction: column; background: var(--background-primary); }
        .chat-container { flex-grow: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; }
        .welcome-screen { text-align: center; margin: auto; color: var(--text-secondary); }
        .welcome-screen h1 { font-size: 2.5rem; color: var(--text-primary); margin-bottom: 10px; }
        .message { max-width: 90%; margin-bottom: 20px; display: flex; align-items: flex-start; gap: 12px; }
        .message .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--border-color); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
        .message-content { background: var(--background-secondary); padding: 16px; border-radius: 12px; line-height: 1.7; width: 100%; word-wrap: break-word; }
        .message.user { align-self: flex-end; flex-direction: row-reverse; }
        .message.user .avatar { background: var(--accent-primary); color: white; }
        .spinner { width: 20px; height: 20px; border: 2px solid var(--border-color); border-top: 2px solid var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }
        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        .input-area-container { padding: 24px; border-top: 1px solid var(--border-color); background: var(--background-primary); }
        .input-area { max-width: 800px; margin: 0 auto; position: relative; background: var(--background-secondary); border: 1px solid var(--border-color); border-radius: 12px; display: flex; align-items: center; padding: 8px; }
        #questionText { flex-grow: 1; border: none; outline: none; background: transparent; font-size: 1rem; padding: 12px; color: var(--text-primary); resize: none; font-family: 'Poppins', sans-serif; height: 48px; }
        .input-buttons { display: flex; align-items: center; gap: 8px; }
        .input-btn { width: 40px; height: 40px; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; border-radius: 8px; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s, color 0.2s; }
        #sendButton:disabled { background-color: var(--border-color); cursor: not-allowed; color: var(--text-secondary); }
        #imageFile { display: none; }
    </style>
</head>
<body>
    <div class="app-layout">
        <nav class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <h1>📚 StudyBot Pro</h1>
            </div>
            <button class="new-chat-btn" id="newChatBtn">
                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
                <span class="lang" data-key="newChat">New Chat</span>
            </button>
            <div class="chat-history">
                <h3 class="history-title lang" data-key="history">History</h3>
                <div id="historyList"></div>
            </div>
            <div class="sidebar-footer">
                <div class="language-switcher">
                    <span class="lang" data-key="language">Language</span>
                    <select id="languageSelector"></select>
                </div>
                <div class="theme-switcher">
                    <span class="lang" data-key="darkMode">Dark Mode</span>
                    <label class="toggle-switch">
                        <input type="checkbox" id="themeToggle">
                        <span class="slider"></span>
                    </label>
                </div>
            </div>
        </nav>
        <main class="main-content">
            <div class="chat-container" id="chatContainer">
                <div class="welcome-screen" id="welcomeScreen">
                    <h1 class="lang" data-key="welcome">Welcome to StudyBot Pro</h1>
                    <p class="lang" data-key="welcomeSub">Your enhanced AI learning assistant. <br> Ask a question, upload an image, or start a new chat from the sidebar.</p>
                </div>
            </div>
            <div class="input-area-container">
                <div class="input-area">
                    <textarea id="questionText" data-key="placeholder" placeholder="Ask your question here..." rows="1"></textarea>
                    <div class="input-buttons">
                        <button class="input-btn" id="attachImageBtn" title="Attach Image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg></button>
                        <input type="file" id="imageFile" accept="image/*">
                        <button class="input-btn" id="sendButton" title="Send Message" disabled><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg></button>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // --- LANGUAGE SUPPORT ---
        const translations = {
            'en': { name: 'English', newChat: 'New Chat', history: 'History', language: 'Language', darkMode: 'Dark Mode', welcome: 'Welcome to StudyBot Pro', welcomeSub: 'Your enhanced AI learning assistant. <br> Ask a question, upload an image, or start a new chat from the sidebar.', placeholder: 'Ask your question here...', user: 'You', ai: 'AI' },
            'ur': { name: 'اردو', newChat: 'نئی چیٹ', history: 'گزشتہ بات چیت', language: 'زبان', darkMode: 'ڈارک موڈ', welcome: 'اسٹڈی بوٹ پرو میں خوش آمدید', welcomeSub: 'آپ کا بہترین AI سیکھنے کا معاون۔<br> سائڈبار سے کوئی سوال پوچھیں، تصویر اپ لوڈ کریں، یا نئی چیٹ شروع کریں۔', placeholder: 'اپنا سوال یہاں پوچھیں...', user: 'آپ', ai: 'AI' },
            'hi': { name: 'हिन्दी', newChat: 'नई चैट', history: 'इतिहास', language: 'भाषा', darkMode: 'डार्क मोड', welcome: 'स्टडीबॉट प्रो में आपका स्वागत है', welcomeSub: 'आपका उन्नत AI लर्निंग असिस्टेंट।<br> कोई प्रश्न पूछें, कोई छवि अपलोड करें, या साइडबार से एक नई चैट शुरू करें।', placeholder: 'अपना प्रश्न यहाँ पूछें...', user: 'आप', ai: 'AI' },
            'es': { name: 'Español', newChat: 'Nuevo Chat', history: 'Historial', language: 'Idioma', darkMode: 'Modo Oscuro', welcome: 'Bienvenido a StudyBot Pro', welcomeSub: 'Tu asistente de aprendizaje de IA mejorado.<br> Haz una pregunta, sube una imagen o inicia un nuevo chat desde la barra lateral.', placeholder: 'Haz tu pregunta aquí...', user: 'Tú', ai: 'IA' },
            'fr': { name: 'Français', newChat: 'Nouveau Chat', history: 'Historique', language: 'Langue', darkMode: 'Mode Sombre', welcome: 'Bienvenue sur StudyBot Pro', welcomeSub: 'Votre assistant d\'apprentissage IA amélioré.<br> Posez une question, téléchargez une image ou démarrez une nouvelle discussion depuis la barre latérale.', placeholder: 'Posez votre question ici...', user: 'Vous', ai: 'IA' },
            'ar': { name: 'العربية', newChat: 'دردشة جديدة', history: 'السجل', language: 'لغة', darkMode: 'الوضع الداكن', welcome: 'مرحباً بك في StudyBot Pro', welcomeSub: 'مساعدك التعليمي المعزز بالذكاء الاصطناعي.<br> اطرح سؤالاً، أو حمّل صورة، أو ابدأ دردشة جديدة من الشريط الجانبي.', placeholder: 'اطرح سؤالك هنا...', user: 'أنت', ai: 'AI' }
            // Aap yahan mazeed 200+ zubaanein add kar sakte hain
        };

        class StudyBotPro {
            constructor() {
                this.apiKey = 'paste your apikey here';
                this.currentLanguage = 'en';
                this.currentLanguageName = 'English';
                // Baaqi properties pehle jaisi hain
                this.history = [];
                this.currentChatId = null;
                this.selectedImage = null;
                this.isProcessing = false;

                this.initializeElements();
                this.populateLanguageSelector();
                this.bindEvents();
                this.loadState();
                
                marked.setOptions({ breaks: true, gfm: true });
            }

            initializeElements() {
                // Saare elements pehle jaise hi hain
                this.questionText = document.getElementById('questionText');
                this.sendButton = document.getElementById('sendButton');
                this.chatContainer = document.getElementById('chatContainer');
                this.welcomeScreen = document.getElementById('welcomeScreen');
                this.newChatBtn = document.getElementById('newChatBtn');
                this.historyList = document.getElementById('historyList');
                this.themeToggle = document.getElementById('themeToggle');
                this.attachImageBtn = document.getElementById('attachImageBtn');
                this.imageFile = document.getElementById('imageFile');
                this.languageSelector = document.getElementById('languageSelector');
            }

            bindEvents() {
                // Pehle jaise events
                this.sendButton.addEventListener('click', () => this.sendMessage());
                this.questionText.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); this.sendMessage(); } });
                this.questionText.addEventListener('input', () => this.updateSendButtonState());
                this.newChatBtn.addEventListener('click', () => this.startNewChat());
                this.themeToggle.addEventListener('change', () => this.toggleTheme());
                this.attachImageBtn.addEventListener('click', () => this.imageFile.click());
                this.imageFile.addEventListener('change', (e) => this.handleImageSelect(e));
                // NAYA EVENT: Language change ke liye
                this.languageSelector.addEventListener('change', (e) => this.setLanguage(e.target.value));
            }

            // --- NAYE FUNCTIONS: Language Management ---
            populateLanguageSelector() {
                for (const langCode in translations) {
                    const option = document.createElement('option');
                    option.value = langCode;
                    option.textContent = translations[langCode].name;
                    this.languageSelector.appendChild(option);
                }
            }

            setLanguage(langCode) {
                this.currentLanguage = langCode;
                this.currentLanguageName = translations[langCode].name;
                this.languageSelector.value = langCode;

                document.querySelectorAll('.lang').forEach(el => {
                    const key = el.dataset.key;
                    if (translations[langCode][key]) {
                        el.innerHTML = translations[langCode][key];
                    }
                });
                
                // Placeholder ke liye khaas
                const placeholderKey = this.questionText.dataset.key;
                this.questionText.placeholder = translations[langCode][placeholderKey];

                // State save karein
                localStorage.setItem('studybot_language', langCode);
            }

            loadState() {
                // Theme load karein
                const isDarkMode = localStorage.getItem('studybot_dark_mode') === 'true';
                this.themeToggle.checked = isDarkMode;
                if(isDarkMode) document.body.classList.add('dark-mode');

                // Language load karein
                const savedLang = localStorage.getItem('studybot_language') || 'en';
                this.setLanguage(savedLang);

                // History load karein
                this.history = JSON.parse(localStorage.getItem('studybot_history')) || [];
                if (this.history.length > 0) {
                    this.renderHistoryList();
                    const lastChatId = localStorage.getItem('studybot_current_chat') || this.history[0].id;
                    this.loadChat(lastChatId);
                } else {
                    this.startNewChat();
                }
            }
            
            // --- API CALL MEIN TABDEELI ---
            async callGeminiAPI(question, image) {
                const model = image ? 'gemini-1.5-flash' : 'gemini-1.5-flash';
                const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${this.apiKey}`;
                
                const contents = { parts: [] };
                
                // **AI KO HIDAYAT DENE WALA PROMPT**
                let promptText = `You are a helpful study assistant. Please provide all responses in ${this.currentLanguageName}. Question: ${question}`;
                
                if(!question && image) {
                    promptText = `You are a helpful study assistant. Please describe this image in detail, and provide your entire response in ${this.currentLanguageName}.`;
                }
                contents.parts.push({ text: promptText });

                if (image) {
                    contents.parts.push({ inline_data: { mime_type: image.mimeType, data: image.base64 } });
                }
                
                const response = await fetch(url, {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ contents: [contents] })
                });

                if (!response.ok) {
                    const errorData = await response.json();
                    throw new Error(errorData.error?.message || `Request failed with status ${response.status}`);
                }
                
                const data = await response.json();
                this.hideLoadingIndicator();

                if (!data.candidates || !data.candidates[0] || !data.candidates[0].content) {
                    throw new Error('No valid response content received from AI.');
                }
                
                const fullResponse = data.candidates[0].content.parts[0].text;
                
                const aiMessageContainer = this.appendMessage('ai', '');
                aiMessageContainer.querySelector('.message-content div').innerHTML = marked.parse(fullResponse);
                
                const currentChat = this.history.find(c => c.id === this.currentChatId);
                currentChat.messages.push({ role: 'model', parts: [{ text: fullResponse }] });
            }

            // Baaqi saare functions (sendMessage, appendMessage, etc.) pehle jaise hi hain
            // Un mein koi barri tabdeeli nahi hai.
            // Neeche woh functions diye gaye hain for reference.

            toggleTheme() { if (this.themeToggle.checked) { document.body.classList.add('dark-mode'); localStorage.setItem('studybot_dark_mode', 'true'); } else { document.body.classList.remove('dark-mode'); localStorage.setItem('studybot_dark_mode', 'false'); } }
            saveHistory() { localStorage.setItem('studybot_history', JSON.stringify(this.history)); localStorage.setItem('studybot_current_chat', this.currentChatId); }
            renderHistoryList() { this.historyList.innerHTML = ''; this.history.forEach(chat => { const item = document.createElement('div'); item.className = 'history-item'; item.textContent = chat.title; item.dataset.id = chat.id; if (chat.id === this.currentChatId) item.classList.add('active'); item.addEventListener('click', () => this.loadChat(chat.id)); this.historyList.prepend(item); }); }
            startNewChat() { this.currentChatId = `chat_${Date.now()}`; this.history.push({ id: this.currentChatId, title: 'New Conversation', messages: [] }); this.chatContainer.innerHTML = ''; this.welcomeScreen.style.display = 'block'; this.renderHistoryList(); this.saveHistory(); this.questionText.value = ''; this.updateSendButtonState(); }
            loadChat(id) { if(this.isProcessing) return; this.currentChatId = id; this.chatContainer.innerHTML = ''; this.welcomeScreen.style.display = 'none'; const chat = this.history.find(c => c.id === id); if (chat && chat.messages) { chat.messages.forEach(msg => { this.appendMessage(msg.role, msg.parts[0].text, msg.image); }); } if(!chat || chat.messages.length === 0){ this.welcomeScreen.style.display = 'block'; } this.renderHistoryList(); localStorage.setItem('studybot_current_chat', this.currentChatId); }
            handleImageSelect(e) { const file = e.target.files[0]; if (!file) return; if (file.size > 4 * 1024 * 1024) { alert('Image size should be less than 4MB'); return; } const reader = new FileReader(); reader.onload = (event) => { this.selectedImage = { base64: event.target.result.split(',')[1], mimeType: file.type, name: file.name }; this.updateSendButtonState(); }; reader.readAsDataURL(file); }
            updateSendButtonState() { this.sendButton.disabled = this.isProcessing || (!this.questionText.value.trim() && !this.selectedImage); }
            async sendMessage() { const question = this.questionText.value.trim(); if ((!question && !this.selectedImage) || this.isProcessing) return; this.isProcessing = true; this.updateSendButtonState(); this.welcomeScreen.style.display = 'none'; const userMessage = { role: 'user', parts: [{ text: question }], image: this.selectedImage ? `data:${this.selectedImage.mimeType};base64,${this.selectedImage.base64}` : null }; this.appendMessage(userMessage.role, userMessage.parts[0].text, userMessage.image); const currentChat = this.history.find(c => c.id === this.currentChatId); currentChat.messages.push(userMessage); if (currentChat.messages.length === 1 && question) { currentChat.title = question.substring(0, 30) + (question.length > 30 ? '...' : ''); this.renderHistoryList(); } this.questionText.value = ''; const imageForApi = this.selectedImage; this.selectedImage = null; this.showLoadingIndicator(); try { await this.callGeminiAPI(question, imageForApi); } catch (error) { const errorMessageContent = `❌ **An error occurred.**\n\n**Details:** ${error.message}`; this.appendMessage('ai', errorMessageContent); this.hideLoadingIndicator(); } finally { this.isProcessing = false; this.updateSendButtonState(); this.saveHistory(); } }
            appendMessage(role, content, imageUrl = null) { const messageDiv = document.createElement('div'); messageDiv.className = `message ${role}`; const lang = this.currentLanguage; const avatarText = translations[lang][role] || (role === 'user' ? 'You' : 'AI'); messageDiv.innerHTML = `<div class="avatar">${avatarText}</div><div class="message-content">${imageUrl ? `<img src="${imageUrl}" style="max-width: 200px; border-radius: 8px; margin-bottom: 10px;">` : ''}<div>${marked.parse(content || ' ')}</div></div>`; this.chatContainer.appendChild(messageDiv); this.chatContainer.scrollTop = this.chatContainer.scrollHeight; messageDiv.querySelectorAll('pre code').forEach((block) => { hljs.highlightElement(block); }); return messageDiv; }
            showLoadingIndicator() { if(document.getElementById('loading')) return; const loadingDiv = document.createElement('div'); loadingDiv.id = 'loading'; loadingDiv.className = 'message ai'; loadingDiv.innerHTML = `<div class="avatar">AI</div><div class="message-content"><div class="spinner"></div></div>`; this.chatContainer.appendChild(loadingDiv); this.chatContainer.scrollTop = this.chatContainer.scrollHeight; }
            hideLoadingIndicator() { const loadingDiv = document.getElementById('loading'); if (loadingDiv) loadingDiv.remove(); }
        }

        document.addEventListener('DOMContentLoaded', () => {
            new StudyBotPro();
        });
    </script>
</body>
</html>

Post a Comment

0 Comments