Spaces:
Running

vedicmath / index.html
onlyoneritz's picture
Update index.html
957ef42 verified
Raw History Blame Contribute Delete
40.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vedic Math Magic - Learn Fast Calculation Tricks</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.trick-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.progress-step.active {
background-color: #4f46e5;
color: white;
}
.progress-step.completed {
background-color: #10b981;
color: white;
}
.math-animation {
transition: all 0.3s ease;
}
.confetti {
position: absolute;
width: 10px;
height: 10px;
background-color: #f00;
border-radius: 50%;
animation: fall 3s linear forwards;
}
@keyframes fall {
to {
transform: translateY(100vh);
opacity: 0;
}
}
.step-content {
display: none;
}
.step-content.active {
display: block;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen font-sans">
<!-- Header -->
<header class="bg-indigo-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-3">
<i class="fas fa-square-root-alt text-3xl"></i>
<h1 class="text-2xl font-bold">Vedic Math Magic</h1>
</div>
<div class="flex items-center space-x-4">
<div class="flex items-center space-x-2 bg-indigo-500 px-3 py-1 rounded-full">
<i class="fas fa-star text-yellow-300"></i>
<span id="points">0</span>
</div>
<button id="help-btn" class="bg-white text-indigo-600 px-3 py-1 rounded-full font-medium">
<i class="fas fa-question-circle"></i> Help
</button>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<!-- Welcome Section -->
<section id="welcome" class="mb-12 text-center">
<h2 class="text-3xl font-bold text-indigo-800 mb-4">Welcome to Vedic Math Magic!</h2>
<p class="text-lg text-gray-700 max-w-3xl mx-auto mb-6">
Learn ancient Indian calculation techniques that make math faster and more fun!
These tricks will help you solve problems in seconds that normally take minutes.
</p>
<div class="bg-indigo-100 border-l-4 border-indigo-500 p-4 max-w-3xl mx-auto mb-8">
<p class="text-indigo-800 font-medium">
<i class="fas fa-lightbulb mr-2"></i>
Did you know? Vedic Math has 16 main formulas that can solve thousands of math problems!
</p>
</div>
<button id="start-learning" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded-full text-lg shadow-lg transition-all">
Start Learning Now <i class="fas fa-arrow-right ml-2"></i>
</button>
</section>
<!-- Tricks Section (initially hidden) -->
<section id="tricks-section" class="hidden">
<div class="flex justify-between items-center mb-8">
<h2 class="text-2xl font-bold text-indigo-800">Choose a Vedic Math Trick to Learn</h2>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-600">Filter:</span>
<select id="difficulty-filter" class="border rounded px-3 py-1 text-sm">
<option value="all">All Difficulties</option>
<option value="easy">Easy</option>
<option value="medium">Medium</option>
<option value="hard">Hard</option>
</select>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-12">
<!-- Trick Cards -->
<div class="trick-card bg-white rounded-xl shadow-md overflow-hidden border border-gray-200 transition-all cursor-pointer" data-trick="ekadhikena" data-difficulty="easy">
<div class="p-5">
<div class="flex justify-between items-start mb-3">
<h3 class="text-xl font-bold text-indigo-700">Ekadhikena Purvena</h3>
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full">Easy</span>
</div>
<p class="text-gray-600 mb-4">"By one more than the previous one" - Perfect for squaring numbers ending with 5</p>
<div class="flex justify-between items-center">
<div class="flex items-center text-yellow-400">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
</div>
<button class="text-indigo-600 font-medium flex items-center">
Learn <i class="fas fa-chevron-right ml-1"></i>
</button>
</div>
</div>
</div>
<div class="trick-card bg-white rounded-xl shadow-md overflow-hidden border border-gray-200 transition-all cursor-pointer" data-trick="nikhilam" data-difficulty="medium">
<div class="p-5">
<div class="flex justify-between items-start mb-3">
<h3 class="text-xl font-bold text-indigo-700">Nikhilam Navatashcaramam</h3>
<span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded-full">Medium</span>
</div>
<p class="text-gray-600 mb-4">"All from 9 and last from 10" - Multiply numbers near powers of 10</p>
<div class="flex justify-between items-center">
<div class="flex items-center text-yellow-400">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="far fa-star"></i>
</div>
<button class="text-indigo-600 font-medium flex items-center">
Learn <i class="fas fa-chevron-right ml-1"></i>
</button>
</div>
</div>
</div>
<div class="trick-card bg-white rounded-xl shadow-md overflow-hidden border border-gray-200 transition-all cursor-pointer" data-trick="urdhva" data-difficulty="hard">
<div class="p-5">
<div class="flex justify-between items-start mb-3">
<h3 class="text-xl font-bold text-indigo-700">Urdhva-Tiryagbhyam</h3>
<span class="bg-red-100 text-red-800 text-xs px-2 py-1 rounded-full">Hard</span>
</div>
<p class="text-gray-600 mb-4">"Vertically and crosswise" - Universal multiplication method</p>
<div class="flex justify-between items-center">
<div class="flex items-center text-yellow-400">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
</div>
<button class="text-indigo-600 font-medium flex items-center">
Learn <i class="fas fa-chevron-right ml-1"></i>
</button>
</div>
</div>
</div>
</div>
<div class="text-center">
<button id="practice-all" class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-6 rounded-full shadow-md transition-all">
<i class="fas fa-dumbbell mr-2"></i> Practice All Tricks
</button>
</div>
</section>
<!-- Learning Area (initially hidden) -->
<section id="learning-area" class="hidden max-w-4xl mx-auto">
<div class="flex justify-between items-center mb-6">
<button id="back-to-tricks" class="text-indigo-600 font-medium flex items-center">
<i class="fas fa-arrow-left mr-2"></i> Back to Tricks
</button>
<div class="flex space-x-1">
<div class="progress-step w-8 h-8 rounded-full border-2 border-gray-300 flex items-center justify-center font-bold">1</div>
<div class="progress-step w-8 h-8 rounded-full border-2 border-gray-300 flex items-center justify-center font-bold">2</div>
<div class="progress-step w-8 h-8 rounded-full border-2 border-gray-300 flex items-center justify-center font-bold">3</div>
<div class="progress-step w-8 h-8 rounded-full border-2 border-gray-300 flex items-center justify-center font-bold">4</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Trick Explanation -->
<div id="trick-explanation" class="p-6">
<h2 class="text-2xl font-bold text-indigo-800 mb-4" id="trick-title">Ekadhikena Purvena</h2>
<div class="flex items-center mb-4">
<span id="trick-difficulty" class="bg-green-100 text-green-800 text-sm px-3 py-1 rounded-full mr-3">Easy</span>
<div class="flex items-center text-yellow-400">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
</div>
</div>
<div id="step-1" class="step-content active">
<h3 class="text-lg font-semibold text-gray-800 mb-3">What does it mean?</h3>
<p class="text-gray-700 mb-4">
"Ekadhikena Purvena" means "By one more than the previous one".
This sutra is particularly useful for squaring numbers that end with 5.
</p>
<div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-4">
<p class="text-blue-800 font-medium">
<i class="fas fa-info-circle mr-2"></i>
Remember: This trick works only for numbers ending with 5!
</p>
</div>
<button class="next-step bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-full">
Next <i class="fas fa-arrow-right ml-1"></i>
</button>
</div>
<div id="step-2" class="step-content">
<h3 class="text-lg font-semibold text-gray-800 mb-3">How it works</h3>
<p class="text-gray-700 mb-4">
To square a number ending with 5 (like 25, 35, 45 etc.):
</p>
<ol class="list-decimal pl-5 mb-4 space-y-2 text-gray-700">
<li>Take the part before the 5 (for 25, it's 2)</li>
<li>Multiply it by "one more than itself" (2 × 3 = 6)</li>
<li>Write 25 at the end (625)</li>
</ol>
<div class="bg-indigo-100 p-4 rounded-lg mb-4 math-animation">
<div class="flex justify-center items-center space-x-4">
<div class="text-3xl font-bold text-indigo-800">25<sup>2</sup> = </div>
<div class="flex flex-col items-center">
<div class="flex items-center">
<span class="border-b-2 border-indigo-500 px-2">2 × 3</span>
<span class="mx-2">= 6</span>
</div>
<div class="text-3xl font-bold text-indigo-800">625</div>
</div>
</div>
</div>
<button class="next-step bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-full">
Next <i class="fas fa-arrow-right ml-1"></i>
</button>
</div>
<div id="step-3" class="step-content">
<h3 class="text-lg font-semibold text-gray-800 mb-3">Let's try another example</h3>
<div class="bg-yellow-50 border-l-4 border-yellow-500 p-4 mb-4">
<p class="text-yellow-800 font-medium">
<i class="fas fa-lightbulb mr-2"></i>
Try to solve this before revealing the answer!
</p>
</div>
<div class="mb-6">
<p class="text-xl font-medium mb-2">What is 35 squared (35 × 35)?</p>
<div class="flex space-x-4">
<button id="show-hint" class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm">
Show Hint
</button>
<button id="show-solution" class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">
Show Solution
</button>
</div>
<div id="hint" class="hidden mt-4 bg-blue-50 p-3 rounded-lg">
<p class="text-blue-800">Remember: Take the digit before 5 (3), multiply by one more than itself (3 × 4), then write 25 at the end.</p>
</div>
<div id="solution" class="hidden mt-4 bg-green-50 p-3 rounded-lg">
<p class="text-green-800 font-medium">Solution:</p>
<p>3 × 4 = 12</p>
<p>Write 25 at the end: 1225</p>
<p class="text-xl font-bold mt-2">35<sup>2</sup> = 1225</p>
</div>
</div>
<button class="next-step bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-full">
Next <i class="fas fa-arrow-right ml-1"></i>
</button>
</div>
<div id="step-4" class="step-content">
<h3 class="text-lg font-semibold text-gray-800 mb-3">Time to Practice!</h3>
<p class="text-gray-700 mb-4">
Let's test your understanding with some practice problems.
Try to solve them using the Ekadhikena Purvena method.
</p>
<div class="bg-purple-50 p-4 rounded-lg mb-6">
<div class="mb-4">
<p class="font-medium text-purple-800 mb-2">1. What is 45 squared (45 × 45)?</p>
<div class="flex space-x-2">
<input type="text" class="border rounded px-3 py-1 w-24 answer-input" data-answer="2025">
<button class="check-answer bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded-full text-sm">
Check
</button>
</div>
<p class="hidden text-green-600 mt-2 feedback"><i class="fas fa-check-circle mr-1"></i> Correct! 4 × 5 = 20, then add 25 to get 2025.</p>
</div>
<div class="mb-4">
<p class="font-medium text-purple-800 mb-2">2. What is 75 squared (75 × 75)?</p>
<div class="flex space-x-2">
<input type="text" class="border rounded px-3 py-1 w-24 answer-input" data-answer="5625">
<button class="check-answer bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded-full text-sm">
Check
</button>
</div>
<p class="hidden text-green-600 mt-2 feedback"><i class="fas fa-check-circle mr-1"></i> Excellent! 7 × 8 = 56, then add 25 to get 5625.</p>
</div>
<div>
<p class="font-medium text-purple-800 mb-2">3. What is 105 squared (105 × 105)?</p>
<div class="flex space-x-2">
<input type="text" class="border rounded px-3 py-1 w-24 answer-input" data-answer="11025">
<button class="check-answer bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded-full text-sm">
Check
</button>
</div>
<p class="hidden text-green-600 mt-2 feedback"><i class="fas fa-check-circle mr-1"></i> Great job! 10 × 11 = 110, then add 25 to get 11025.</p>
</div>
</div>
<div class="flex justify-between items-center">
<button id="try-another-trick" class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium py-2 px-4 rounded-full">
<i class="fas fa-random mr-1"></i> Try Another Trick
</button>
<button id="celebrate" class="bg-yellow-500 hover:bg-yellow-600 text-white font-medium py-2 px-4 rounded-full">
<i class="fas fa-trophy mr-1"></i> I Did It!
</button>
</div>
</div>
</div>
</div>
</section>
<!-- Practice Mode (initially hidden) -->
<section id="practice-mode" class="hidden max-w-4xl mx-auto">
<div class="flex justify-between items-center mb-6">
<button id="back-to-tricks-practice" class="text-indigo-600 font-medium flex items-center">
<i class="fas fa-arrow-left mr-2"></i> Back to Tricks
</button>
<div class="flex items-center space-x-2">
<span class="text-sm font-medium">Score:</span>
<div class="bg-indigo-100 px-3 py-1 rounded-full font-bold" id="practice-score">0</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden p-6">
<h2 class="text-2xl font-bold text-indigo-800 mb-6">Practice All Vedic Math Tricks</h2>
<div class="mb-8">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-800">Random Practice Problems</h3>
<button id="new-problem" class="bg-indigo-600 hover:bg-indigo-700 text-white text-sm px-3 py-1 rounded-full">
<i class="fas fa-sync-alt mr-1"></i> New Problem
</button>
</div>
<div id="current-problem" class="bg-blue-50 p-6 rounded-lg mb-4 text-center">
<p class="text-xl font-medium mb-2">What is 25 × 25?</p>
<p class="text-sm text-gray-600 mb-4">(Use the Ekadhikena Purvena method)</p>
<div class="flex justify-center space-x-2">
<input type="text" id="practice-answer" class="border rounded px-4 py-2 w-32 text-center text-lg font-bold">
<button id="submit-practice" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-full">
Submit
</button>
</div>
</div>
<div id="practice-feedback" class="hidden p-4 rounded-lg mb-4">
<div class="flex items-start">
<div class="mr-3 text-2xl" id="feedback-icon"></div>
<div>
<p class="font-medium" id="feedback-message"></p>
<p class="text-sm mt-1" id="feedback-explanation"></p>
</div>
</div>
</div>
</div>
<div class="bg-gray-100 p-4 rounded-lg">
<h4 class="font-medium text-gray-800 mb-3">Quick Tips:</h4>
<ul class="list-disc pl-5 space-y-2 text-gray-700">
<li>For numbers ending with 5, use Ekadhikena Purvena</li>
<li>For numbers near 100, use Nikhilam method</li>
<li>For general multiplication, try Urdhva-Tiryagbhyam</li>
</ul>
</div>
</div>
</section>
</main>
<!-- Help Modal -->
<div id="help-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-2xl font-bold text-indigo-800">Help Center</h3>
<button id="close-help" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times text-2xl"></i>
</button>
</div>
<div class="space-y-4">
<div class="bg-blue-50 p-4 rounded-lg">
<h4 class="font-bold text-blue-800 mb-2"><i class="fas fa-question-circle mr-2"></i> How to use this app?</h4>
<p class="text-gray-700">Start by selecting a Vedic Math trick to learn. Each trick has 4 steps: explanation, how it works, example, and practice. Complete all steps to master the technique!</p>
</div>
<div class="bg-green-50 p-4 rounded-lg">
<h4 class="font-bold text-green-800 mb-2"><i class="fas fa-star mr-2"></i> Earning points</h4>
<p class="text-gray-700">You earn points by completing learning steps and solving practice problems correctly. More difficult tricks give more points!</p>
</div>
<div class="bg-yellow-50 p-4 rounded-lg">
<h4 class="font-bold text-yellow-800 mb-2"><i class="fas fa-lightbulb mr-2"></i> Learning tips</h4>
<ul class="list-disc pl-5 space-y-1 text-gray-700">
<li>Take your time with each step</li>
<li>Try examples on paper before checking solutions</li>
<li>Practice daily for best results</li>
</ul>
</div>
</div>
<div class="mt-6 pt-4 border-t border-gray-200">
<h4 class="font-bold text-indigo-800 mb-2">Contact Support</h4>
<p class="text-gray-700">Need more help? Email us at <a href="mailto:support@vedicmathmagic.com" class="text-indigo-600 underline">support@vedicmathmagic.com</a></p>
</div>
</div>
</div>
</div>
<script>
// DOM Elements
const welcomeSection = document.getElementById('welcome');
const tricksSection = document.getElementById('tricks-section');
const learningArea = document.getElementById('learning-area');
const practiceMode = document.getElementById('practice-mode');
const startLearningBtn = document.getElementById('start-learning');
const trickCards = document.querySelectorAll('.trick-card');
const backToTricksBtn = document.getElementById('back-to-tricks');
const backToTricksPracticeBtn = document.getElementById('back-to-tricks-practice');
const nextStepBtns = document.querySelectorAll('.next-step');
const progressSteps = document.querySelectorAll('.progress-step');
const showHintBtn = document.getElementById('show-hint');
const showSolutionBtn = document.getElementById('show-solution');
const hintDiv = document.getElementById('hint');
const solutionDiv = document.getElementById('solution');
const checkAnswerBtns = document.querySelectorAll('.check-answer');
const tryAnotherTrickBtn = document.getElementById('try-another-trick');
const celebrateBtn = document.getElementById('celebrate');
const practiceAllBtn = document.getElementById('practice-all');
const newProblemBtn = document.getElementById('new-problem');
const submitPracticeBtn = document.getElementById('submit-practice');
const practiceAnswerInput = document.getElementById('practice-answer');
const practiceFeedbackDiv = document.getElementById('practice-feedback');
const helpBtn = document.getElementById('help-btn');
const helpModal = document.getElementById('help-modal');
const closeHelpBtn = document.getElementById('close-help');
const pointsDisplay = document.getElementById('points');
const practiceScoreDisplay = document.getElementById('practice-score');
// State
let currentStep = 1;
let currentTrick = '';
let points = 0;
let practiceScore = 0;
// Initialize the app
document.addEventListener('DOMContentLoaded', () => {
// Set first step as active
document.querySelector('.step-content').classList.add('active');
// Add event listeners
setupEventListeners();
});
function setupEventListeners() {
// Navigation buttons
startLearningBtn.addEventListener('click', () => {
welcomeSection.classList.add('hidden');
tricksSection.classList.remove('hidden');
});
trickCards.forEach(card => {
card.addEventListener('click', () => {
currentTrick = card.dataset.trick;
tricksSection.classList.add('hidden');
learningArea.classList.remove('hidden');
// Update UI based on selected trick
document.getElementById('trick-title').textContent = getTrickTitle(currentTrick);
document.getElementById('trick-difficulty').textContent = getTrickDifficulty(currentTrick);
document.getElementById('trick-difficulty').className = getDifficultyClass(card.dataset.difficulty);
// Reset steps
currentStep = 1;
updateProgressSteps();
});
});
backToTricksBtn.addEventListener('click', () => {
learningArea.classList.add('hidden');
tricksSection.classList.remove('hidden');
resetLearningArea();
});
backToTricksPracticeBtn.addEventListener('click', () => {
practiceMode.classList.add('hidden');
tricksSection.classList.remove('hidden');
});
// Step navigation
nextStepBtns.forEach(btn => {
btn.addEventListener('click', () => {
if (currentStep < 4) {
currentStep++;
updateProgressSteps();
// Add points when completing steps
if (currentStep === 4) {
addPoints(20);
}
}
});
});
// Example section buttons
showHintBtn.addEventListener('click', () => {
hintDiv.classList.toggle('hidden');
});
showSolutionBtn.addEventListener('click', () => {
solutionDiv.classList.toggle('hidden');
});
// Practice answer checking
checkAnswerBtns.forEach(btn => {
btn.addEventListener('click', function() {
const input = this.previousElementSibling;
const correctAnswer = input.dataset.answer;
const feedback = this.parentElement.querySelector('.feedback');
if (input.value === correctAnswer) {
input.classList.add('border-green-500');
input.classList.remove('border-red-500');
feedback.classList.remove('hidden');
feedback.classList.add('text-green-600');
feedback.classList.remove('text-red-600');
// Add points for correct answer
addPoints(10);
} else {
input.classList.add('border-red-500');
input.classList.remove('border-green-500');
feedback.classList.remove('hidden');
feedback.classList.add('text-red-600');
feedback.classList.remove('text-green-600');
feedback.innerHTML = `<i class="fas fa-times-circle mr-1"></i> Not quite! Try again. The correct answer is ${correctAnswer}.`;
}
});
});
// Navigation buttons
tryAnotherTrickBtn.addEventListener('click', () => {
learningArea.classList.add('hidden');
tricksSection.classList.remove('hidden');
resetLearningArea();
});
celebrateBtn.addEventListener('click', () => {
createConfetti();
setTimeout(() => {
learningArea.classList.add('hidden');
tricksSection.classList.remove('hidden');
resetLearningArea();
}, 2000);
});
practiceAllBtn.addEventListener('click', () => {
tricksSection.classList.add('hidden');
practiceMode.classList.remove('hidden');
generatePracticeProblem();
});
// Practice mode buttons
newProblemBtn.addEventListener('click', generatePracticeProblem);
submitPracticeBtn.addEventListener('click', checkPracticeAnswer);
practiceAnswerInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
checkPracticeAnswer();
}
});
// Help modal
helpBtn.addEventListener('click', () => {
helpModal.classList.remove('hidden');
});
closeHelpBtn.addEventListener('click', () => {
helpModal.classList.add('hidden');
});
}
// Functions
function updateProgressSteps() {
progressSteps.forEach((step, index) => {
step.classList.remove('active', 'completed');
if (index + 1 === currentStep) {
step.classList.add('active');
} else if (index + 1 < currentStep) {
step.classList.add('completed');
}
});
// Show current step content
document.querySelectorAll('.step-content').forEach(content => {
content.classList.remove('active');
});
document.getElementById(`step-${currentStep}`).classList.add('active');
}
function resetLearningArea() {
currentStep = 1;
updateProgressSteps();
// Reset inputs and feedback
document.querySelectorAll('.answer-input').forEach(input => {
input.value = '';
input.classList.remove('border-green-500', 'border-red-500');
});
document.querySelectorAll('.feedback').forEach(feedback => {
feedback.classList.add('hidden');
});
hintDiv.classList.add('hidden');
solutionDiv.classList.add('hidden');
}
function getTrickTitle(trick) {
const titles = {
'ekadhikena': 'Ekadhikena Purvena',
'nikhilam': 'Nikhilam Navatashcaramam',
'urdhva': 'Urdhva-Tiryagbhyam'
};
return titles[trick] || 'Vedic Math Trick';
}
function getTrickDifficulty(trick) {
const difficulties = {
'ekadhikena': 'Easy',
'nikhilam': 'Medium',
'urdhva': 'Hard'
};
return difficulties[trick] || 'Medium';
}
function getDifficultyClass(difficulty) {
const classes = {
'easy': 'bg-green-100 text-green-800 text-sm px-3 py-1 rounded-full mr-3',
'medium': 'bg-yellow-100 text-yellow-800 text-sm px-3 py-1 rounded-full mr-3',
'hard': 'bg-red-100 text-red-800 text-sm px-3 py-1 rounded-full mr-3'
};
return classes[difficulty] || 'bg-gray-100 text-gray-800 text-sm px-3 py-1 rounded-full mr-3';
}
function createConfetti() {
for (let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * 100 + 'vw';
confetti.style.backgroundColor = `hsl(${Math.random() * 360}, 100%, 50%)`;
confetti.style.animationDuration = Math.random() * 2 + 1 + 's';
document.body.appendChild(confetti);
setTimeout(() => {
confetti.remove();
}, 3000);
}
}
function addPoints(amount) {
points += amount;
pointsDisplay.textContent = points;
// Add animation to points display
pointsDisplay.classList.add('animate-bounce');
setTimeout(() => {
pointsDisplay.classList.remove('animate-bounce');
}, 1000);
}
function generatePracticeProblem() {
const problems = [
{
question: "What is 25 × 25?",
hint: "(Use the Ekadhikena Purvena method)",
answer: "625",
explanation: "2 × 3 = 6, then add 25 to get 625"
},
{
question: "What is 35 × 35?",
hint: "(Use the Ekadhikena Purvena method)",
answer: "1225",
explanation: "3 × 4 = 12, then add 25 to get 1225"
},
{
question: "What is 45 × 45?",
hint: "(Use the Ekadhikena Purvena method)",
answer: "2025",
explanation: "4 × 5 = 20, then add 25 to get 2025"
},
{
question: "What is 75 × 75?",
hint: "(Use the Ekadhikena Purvena method)",
answer: "5625",
explanation: "7 × 8 = 56, then add 25 to get 5625"
},
{
question: "What is 95 × 95?",
hint: "(Use the Ekadhikena Purvena method)",
answer: "9025",
explanation: "9 × 10 = 90, then add 25 to get 9025"
}
];
// Select a random problem
const randomProblem = problems[Math.floor(Math.random() * problems.length)];
// Update the UI
document.querySelector('#current-problem p:nth-child(1)').textContent = randomProblem.question;
document.querySelector('#current-problem p:nth-child(2)').textContent = randomProblem.hint;
practiceAnswerInput.value = '';
practiceAnswerInput.dataset.correctAnswer = randomProblem.answer;
practiceAnswerInput.dataset.explanation = randomProblem.explanation;
practiceFeedbackDiv.classList.add('hidden');
}
function checkPracticeAnswer() {
const userAnswer = practiceAnswerInput.value.trim();
const correctAnswer = practiceAnswerInput.dataset.correctAnswer;
const explanation = practiceAnswerInput.dataset.explanation;
if (userAnswer === correctAnswer) {
// Correct answer
practiceFeedbackDiv.className = 'bg-green-50 p-4 rounded-lg mb-4';
document.getElementById('feedback-icon').innerHTML = '<i class="fas fa-check-circle text-green-500"></i>';
document.getElementById('feedback-message').textContent = 'Correct! Well done!';
document.getElementById('feedback-explanation').textContent = explanation;
// Add to score
practiceScore += 10;
practiceScoreDisplay.textContent = practiceScore;
// Add points
addPoints(5);
} else {
// Incorrect answer
practiceFeedbackDiv.className = 'bg-red-50 p-4 rounded-lg mb-4';
document.getElementById('feedback-icon').innerHTML = '<i class="fas fa-times-circle text-red-500"></i>';
document.getElementById('feedback-message').textContent = 'Not quite right. Try again!';
document.getElementById('feedback-explanation').textContent = `The correct answer is ${correctAnswer}. ${explanation}`;
}
practiceFeedbackDiv.classList.remove('hidden');
}
</script>
</html>