Spaces:
Running
Running
File size: 40,868 Bytes
51458a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | <!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> |