Spaces:
Running
Running
File size: 74,844 Bytes
56d9978 | 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 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | <!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StudyZen - Smart Study Assistant</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://www.gstatic.com/firebasejs/10.1.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.1.0/firebase-auth-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.1.0/firebase-firestore-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.1.0/firebase-storage-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.1.0/firebase-messaging-compat.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary: #3b82f6;
--primary-dark: #2563eb;
}
body {
font-family: 'Inter', sans-serif;
transition: background-color 0.3s ease;
}
.card {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.flashcard {
perspective: 1000px;
}
.flashcard-inner {
transition: transform 0.6s;
transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
backface-visibility: hidden;
}
.flashcard-back {
transform: rotateY(180deg);
}
.loading-spinner {
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.dark {
background-color: #1a202c;
color: #f7fafc;
}
.dark .card {
background-color: #2d3748;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.12);
}
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
</style>
</head>
<body class="h-full bg-gray-50 dark:bg-gray-900">
<!-- Auth Modal -->
<div id="authModal" class="fixed inset-0 z-50 hidden flex items-center justify-center bg-black bg-opacity-50">
<div class="bg-white dark:bg-gray-800 rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Welcome to StudyZen</h3>
<button id="closeAuthModal" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
<i class="fas fa-times"></i>
</button>
</div>
<div id="authTabs" class="flex border-b border-gray-200 dark:border-gray-700 mb-4">
<button id="loginTab" class="py-2 px-4 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400">Login</button>
<button id="signupTab" class="py-2 px-4 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Sign Up</button>
</div>
<div id="loginForm">
<div class="mb-4">
<label for="loginEmail" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Email</label>
<input type="email" id="loginEmail" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div class="mb-4">
<label for="loginPassword" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Password</label>
<input type="password" id="loginPassword" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<button id="loginBtn" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md font-medium transition duration-150 ease-in-out">Login</button>
<div class="mt-4 text-center">
<button id="googleLoginBtn" class="w-full bg-white hover:bg-gray-50 text-gray-700 py-2 px-4 rounded-md font-medium border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 transition duration-150 ease-in-out flex items-center justify-center">
<img src="https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg" alt="Google logo" class="h-4 w-4 mr-2">
Continue with Google
</button>
</div>
</div>
<div id="signupForm" class="hidden">
<div class="mb-4">
<label for="signupEmail" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Email</label>
<input type="email" id="signupEmail" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div class="mb-4">
<label for="signupPassword" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Password</label>
<input type="password" id="signupPassword" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div class="mb-4">
<label for="confirmPassword" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Confirm Password</label>
<input type="password" id="confirmPassword" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<button id="signupBtn" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md font-medium transition duration-150 ease-in-out">Sign Up</button>
</div>
</div>
</div>
<!-- Main App Container -->
<div class="min-h-full">
<!-- Navigation -->
<nav class="bg-white dark:bg-gray-800 shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 flex items-center">
<i class="fas fa-brain text-blue-600 dark:text-blue-400 text-2xl mr-2"></i>
<span class="text-xl font-semibold text-gray-900 dark:text-white">StudyZen</span>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="#" id="dashboardNav" class="border-blue-500 text-gray-900 dark:text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Dashboard</a>
<a href="#" id="summarizeNav" class="border-transparent text-gray-500 dark:text-gray-400 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Summarize</a>
<a href="#" id="flashcardsNav" class="border-transparent text-gray-500 dark:text-gray-400 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Flashcards</a>
<a href="#" id="scheduleNav" class="border-transparent text-gray-500 dark:text-gray-400 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Schedule</a>
</div>
</div>
<div class="hidden sm:ml-6 sm:flex sm:items-center">
<button id="themeToggle" class="p-1 rounded-full text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 focus:outline-none">
<i class="fas fa-moon dark:hidden" id="darkModeIcon"></i>
<i class="fas fa-sun hidden dark:inline-block" id="lightModeIcon"></i>
</button>
<div class="ml-3 relative">
<div>
<button id="userMenuBtn" class="flex text-sm rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<img id="userAvatar" class="h-8 w-8 rounded-full" src="https://ui-avatars.com/api/?background=3b82f6&color=fff" alt="User avatar">
</button>
</div>
<div id="userMenu" class="hidden origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 focus:outline-none z-50">
<a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">Your Profile</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">Settings</a>
<a href="#" id="signOutBtn" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">Sign out</a>
</div>
</div>
</div>
<div class="-mr-2 flex items-center sm:hidden">
<button id="mobileMenuBtn" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500">
<span class="sr-only">Open main menu</span>
<i class="fas fa-bars block h-6 w-6" id="mobileMenuOpenIcon"></i>
<i class="fas fa-times hidden h-6 w-6" id="mobileMenuCloseIcon"></i>
</button>
</div>
</div>
</div>
<!-- Mobile menu -->
<div id="mobileMenu" class="hidden sm:hidden">
<div class="pt-2 pb-3 space-y-1">
<a href="#" id="mobileDashboardNav" class="bg-blue-50 dark:bg-gray-700 border-blue-500 text-blue-700 dark:text-blue-400 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Dashboard</a>
<a href="#" id="mobileSummarizeNav" class="border-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Summarize</a>
<a href="#" id="mobileFlashcardsNav" class="border-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Flashcards</a>
<a href="#" id="mobileScheduleNav" class="border-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Schedule</a>
</div>
<div class="pt-4 pb-3 border-t border-gray-200 dark:border-gray-700">
<div class="flex items-center px-4">
<div class="flex-shrink-0">
<img id="mobileUserAvatar" class="h-10 w-10 rounded-full" src="https://ui-avatars.com/api/?background=3b82f6&color=fff" alt="">
</div>
<div class="ml-3">
<div id="mobileUserName" class="text-base font-medium text-gray-800 dark:text-white"></div>
<div id="mobileUserEmail" class="text-sm font-medium text-gray-500 dark:text-gray-400"></div>
</div>
<button id="mobileThemeToggle" class="ml-auto p-1 rounded-full text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 focus:outline-none">
<i class="fas fa-moon dark:hidden" id="mobileDarkModeIcon"></i>
<i class="fas fa-sun hidden dark:inline-block" id="mobileLightModeIcon"></i>
</button>
</div>
<div class="mt-3 space-y-1">
<a href="#" class="block px-4 py-2 text-base font-medium text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Your Profile</a>
<a href="#" class="block px-4 py-2 text-base font-medium text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Settings</a>
<a href="#" id="mobileSignOutBtn" class="block px-4 py-2 text-base font-medium text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Sign out</a>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<!-- Dashboard Section -->
<div id="dashboardSection">
<div class="mb-6 flex justify-between items-center">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Dashboard</h2>
<div class="text-sm text-gray-500 dark:text-gray-400">
<span id="greetingTime"></span>, <span id="userDisplayName"></span>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-6">
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Recent Summaries</h3>
<a href="#" class="text-sm text-blue-600 dark:text-blue-400 hover:underline">View all</a>
</div>
<div id="recentSummaries" class="space-y-4">
<!-- Filled dynamically -->
<div class="animate-pulse flex space-x-4">
<div class="flex-1 space-y-4 py-1">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"></div>
<div class="space-y-2">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
</div>
</div>
</div>
</div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Upcoming Reviews</h3>
<a href="#" class="text-sm text-blue-600 dark:text-blue-400 hover:underline">View all</a>
</div>
<div id="upcomingReviews" class="space-y-4">
<!-- Filled dynamically -->
<div class="animate-pulse flex space-x-4">
<div class="flex-1 space-y-4 py-1">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"></div>
<div class="space-y-2">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
</div>
</div>
</div>
</div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Study Progress</h3>
</div>
<div class="flex items-center justify-center">
<div class="relative w-32 h-32">
<svg class="w-full h-full" viewBox="0 0 100 100">
<circle class="text-gray-200 dark:text-gray-700" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
<circle class="text-blue-600" stroke-width="8" stroke-dasharray="251.2" stroke-dashoffset="75.36" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
</svg>
<div class="absolute top-0 left-0 w-full h-full flex items-center justify-center flex-col">
<span class="text-2xl font-bold text-gray-900 dark:text-white">70%</span>
<span class="text-sm text-gray-500 dark:text-gray-400">Completion</span>
</div>
</div>
</div>
</div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6 mb-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Recent Flashcards</h3>
<a href="#" class="text-sm text-blue-600 dark:text-blue-400 hover:underline">View all</a>
</div>
<div id="recentFlashcards" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<!-- Filled dynamically -->
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
</div>
</div>
</div>
<!-- Summarize Section -->
<div id="summarizeSection" class="hidden">
<div class="mb-6 flex justify-between items-center">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Summarize Content</h2>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6 lg:col-span-2">
<div class="mb-4">
<label for="contentInput" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Enter text or upload a PDF</label>
<div class="flex rounded-md shadow-sm">
<div class="relative flex-grow focus-within:z-10">
<textarea id="contentInput" rows="10" class="block w-full rounded-l-md border-gray-300 dark:border-gray-600 focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-700 dark:text-white sm:text-sm" placeholder="Paste your text here..."></textarea>
</div>
<button id="uploadPdfBtn" class="-ml-px relative inline-flex items-center space-x-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-sm font-medium rounded-r-md text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600">
<i class="fas fa-file-pdf text-red-500"></i>
<span>Upload PDF</span>
<input type="file" id="pdfUpload" accept=".pdf" class="hidden">
</button>
</div>
</div>
<div class="flex justify-end">
<button id="summarizeBtn" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50" disabled>
<span id="summarizeBtnText">Summarize</span>
<span id="summarizeLoading" class="ml-2 hidden">
<i class="fas fa-circle-notch loading-spinner"></i>
</span>
</button>
</div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">Previous Summaries</h3>
<div id="summaryHistory" class="space-y-3 max-h-[500px] overflow-y-auto">
<!-- Filled dynamically -->
<div class="animate-pulse flex space-x-4">
<div class="flex-1 space-y-4 py-1">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"></div>
<div class="space-y-2">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="summaryResults" class="hidden mt-6">
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6 mb-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Summary</h3>
<div class="flex space-x-2">
<button id="saveSummaryBtn" class="inline-flex items-center px-3 py-1 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-save mr-1"></i> Save
</button>
<button id="copySummaryBtn" class="inline-flex items-center px-3 py-1 border border-gray-300 dark:border-gray-600 text-xs font-medium rounded shadow-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-copy mr-1"></i> Copy
</button>
</div>
</div>
<div id="generatedSummary" class="prose dark:prose-invert max-w-none">
<!-- Filled dynamically -->
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Key Points</h3>
<button id="copyKeyPointsBtn" class="inline-flex items-center px-3 py-1 border border-gray-300 dark:border-gray-600 text-xs font-medium rounded shadow-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-copy mr-1"></i> Copy
</button>
</div>
<div id="generatedKeyPoints" class="space-y-2">
<!-- Filled dynamically -->
</div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Generated Flashcards</h3>
<div class="flex space-x-2">
<button id="saveFlashcardsBtn" class="inline-flex items-center px-3 py-1 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-save mr-1"></i> Save All
</button>
<button id="copyFlashcardsBtn" class="inline-flex items-center px-3 py-1 border border-gray-300 dark:border-gray-600 text-xs font-medium rounded shadow-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-copy mr-1"></i> Copy All
</button>
</div>
</div>
<div id="generatedFlashcards" class="space-y-3 max-h-[400px] overflow-y-auto">
<!-- Filled dynamically -->
</div>
</div>
</div>
</div>
</div>
<!-- Flashcards Section -->
<div id="flashcardsSection" class="hidden">
<div class="mb-6 flex justify-between items-center">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Flashcards Review</h2>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-500 dark:text-gray-400">Sort by:</span>
<select id="flashcardSort" class="block w-full pl-3 pr-10 py-2 text-base border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md bg-white dark:bg-gray-700">
<option value="due">Due Date</option>
<option value="ease">Ease</option>
<option value="newest">Newest First</option>
<option value="oldest">Oldest First</option>
</select>
</div>
</div>
<div class="flex flex-col items-center">
<div id="flashcardContainer" class="w-full max-w-2xl mb-6">
<div class="flashcard cursor-pointer w-full h-64" id="currentFlashcard">
<div class="flashcard-inner relative w-full h-full">
<div class="flashcard-front absolute w-full h-full bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 flex flex-col">
<div class="flex justify-between items-start mb-4">
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Question</span>
<span id="cardProgress" class="text-xs text-gray-500 dark:text-gray-400">1/10</span>
</div>
<div id="flashcardQuestion" class="flex-grow flex items-center justify-center text-xl text-center text-gray-900 dark:text-white">
Click "Start Review" to begin
</div>
<div class="mt-4 text-sm text-gray-500 dark:text-gray-400 text-center">
Click to flip
</div>
</div>
<div class="flashcard-back absolute w-full h-full bg-blue-50 dark:bg-gray-700 rounded-lg shadow-md p-6 flex flex-col">
<div class="flex justify-between items-start mb-4">
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Answer</span>
<span id="cardStats" class="text-xs text-gray-500 dark:text-gray-400">New card</span>
</div>
<div id="flashcardAnswer" class="flex-grow flex items-center justify-center text-xl text-center text-gray-900 dark:text-white">
<!-- Filled dynamically -->
</div>
<div class="mt-4 grid grid-cols-3 gap-2">
<button class="difficultyBtn bg-red-100 dark:bg-red-900 hover:bg-red-200 dark:hover:bg-red-800 text-red-800 dark:text-red-100 px-3 py-2 rounded text-sm font-medium" data-difficulty="1">Hard</button>
<button class="difficultyBtn bg-yellow-100 dark:bg-yellow-900 hover:bg-yellow-200 dark:hover:bg-yellow-800 text-yellow-800 dark:text-yellow-100 px-3 py-2 rounded text-sm font-medium" data-difficulty="2">Good</button>
<button class="difficultyBtn bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-100 px-3 py-2 rounded text-sm font-medium" data-difficulty="3">Easy</button>
</div>
</div>
</div>
</div>
</div>
<div class="flex space-x-4">
<button id="startReviewBtn" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Start Review
</button>
<button id="endReviewBtn" class="hidden inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
End Review
</button>
</div>
</div>
<div class="mt-8">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Your Flashcard Decks</h3>
<button id="createDeckBtn" class="inline-flex items-center px-3 py-1 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-plus mr-1"></i> New Deck
</button>
</div>
<div id="flashcardDecks" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<!-- Filled dynamically -->
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
<div class="animate-pulse h-32 bg-gray-200 dark:bg-gray-700 rounded-lg"></div>
</div>
</div>
</div>
<!-- Schedule Section -->
<div id="scheduleSection" class="hidden">
<div class="mb-6 flex justify-between items-center">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Study Schedule</h2>
<button id="addTaskBtn" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-plus mr-2"></i> Add Task
</button>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6 lg:col-span-2">
<div id="calendar"></div>
</div>
<div class="card bg-white dark:bg-gray-800 rounded-lg p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Upcoming Tasks</h3>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-500 dark:text-gray-400">Filter:</span>
<select id="taskFilter" class="block w-full pl-3 pr-10 py-2 text-base border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md bg-white dark:bg-gray-700">
<option value="all">All</option>
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="overdue">Overdue</option>
</select>
</div>
</div>
<div id="taskList" class="space-y-3 max-h-[500px] overflow-y-auto">
<!-- Filled dynamically -->
<div class="animate-pulse flex space-x-4">
<div class="flex-1 space-y-4 py-1">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"></div>
<div class="space-y-2">
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- Add Task Modal -->
<div id="taskModal" class="fixed inset-0 z-50 hidden flex items-center justify-center bg-black bg-opacity-50">
<div class="bg-white dark:bg-gray-800 rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Add New Task</h3>
<button id="closeTaskModal" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label for="taskTitle" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Title</label>
<input type="text" id="taskTitle" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div>
<label for="taskDescription" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description</label>
<textarea id="taskDescription" rows="3" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"></textarea>
</div>
<div>
<label for="taskDueDate" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Due Date</label>
<input type="date" id="taskDueDate" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div>
<label for="taskPriority" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Priority</label>
<select id="taskPriority" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
</div>
<div>
<label for="taskReminder" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Reminder</label>
<select id="taskReminder" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
<option value="none">None</option>
<option value="15min">15 minutes before</option>
<option value="1hour">1 hour before</option>
<option value="1day">1 day before</option>
</select>
</div>
</div>
<div class="mt-6 flex justify-end space-x-3">
<button id="cancelTaskBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Cancel
</button>
<button id="saveTaskBtn" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Save Task
</button>
</div>
</div>
</div>
<!-- Create Deck Modal -->
<div id="deckModal" class="fixed inset-0 z-50 hidden flex items-center justify-center bg-black bg-opacity-50">
<div class="bg-white dark:bg-gray-800 rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Create New Deck</h3>
<button id="closeDeckModal" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label for="deckTitle" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Title</label>
<input type="text" id="deckTitle" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
</div>
<div>
<label for="deckDescription" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description</label>
<textarea id="deckDescription" rows="3" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"></textarea>
</div>
<div>
<label for="deckColor" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Color</label>
<div class="flex space-x-2">
<button class="colorOption w-8 h-8 rounded-full bg-blue-500 border-2 border-transparent focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" data-color="blue"></button>
<button class="colorOption w-8 h-8 rounded-full bg-green-500 border-2 border-transparent focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" data-color="green"></button>
<button class="colorOption w-8 h-8 rounded-full bg-red-500 border-2 border-transparent focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" data-color="red"></button>
<button class="colorOption w-8 h-8 rounded-full bg-yellow-500 border-2 border-transparent focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" data-color="yellow"></button>
<button class="colorOption w-8 h-8 rounded-full bg-purple-500 border-2 border-transparent focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" data-color="purple"></button>
</div>
</div>
</div>
<div class="mt-6 flex justify-end space-x-3">
<button id="cancelDeckBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Cancel
</button>
<button id="saveDeckBtn" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Create Deck
</button>
</div>
</div>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-4 right-4 hidden">
<div class="bg-gray-800 text-white px-4 py-3 rounded-md shadow-lg flex items-start">
<div class="flex-shrink-0">
<i id="toastIcon" class="fas fa-check-circle"></i>
</div>
<div class="ml-3">
<p id="toastMessage" class="text-sm"></p>
</div>
<button id="closeToast" class="ml-4 text-gray-300 hover:text-white">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<script>
// Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDEXAMPLEEXAMPLEEXAMPLEEXAMPLE",
authDomain: "studyzen-app.firebaseapp.com",
projectId: "studyzen-app",
storageBucket: "studyzen-app.appspot.com",
messagingSenderId: "123456789012",
appId: "1:123456789012:web:abcd1234abcd1234abcd12"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
const storage = firebase.storage();
const messaging = firebase.messaging();
// Cloudflare Worker API endpoint
const API_ENDPOINT = "https://studyzen-api.workers.dev";
// DOM Elements
const elements = {
// Auth
authModal: document.getElementById('authModal'),
closeAuthModal: document.getElementById('closeAuthModal'),
loginTab: document.getElementById('loginTab'),
signupTab: document.getElementById('signupTab'),
loginForm: document.getElementById('loginForm'),
signupForm: document.getElementById('signupForm'),
loginBtn: document.getElementById('loginBtn'),
signupBtn: document.getElementById('signupBtn'),
googleLoginBtn: document.getElementById('googleLoginBtn'),
loginEmail: document.getElementById('loginEmail'),
loginPassword: document.getElementById('loginPassword'),
signupEmail: document.getElementById('signupEmail'),
signupPassword: document.getElementById('signupPassword'),
confirmPassword: document.getElementById('confirmPassword'),
// Navigation
dashboardNav: document.getElementById('dashboardNav'),
summarizeNav: document.getElementById('summarizeNav'),
flashcardsNav: document.getElementById('flashcardsNav'),
scheduleNav: document.getElementById('scheduleNav'),
mobileDashboardNav: document.getElementById('mobileDashboardNav'),
mobileSummarizeNav: document.getElementById('mobileSummarizeNav'),
mobileFlashcardsNav: document.getElementById('mobileFlashcardsNav'),
mobileScheduleNav: document.getElementById('mobileScheduleNav'),
// Sections
dashboardSection: document.getElementById('dashboardSection'),
summarizeSection: document.getElementById('summarizeSection'),
flashcardsSection: document.getElementById('flashcardsSection'),
scheduleSection: document.getElementById('scheduleSection'),
// User menu
userMenuBtn: document.getElementById('userMenuBtn'),
userMenu: document.getElementById('userMenu'),
userAvatar: document.getElementById('userAvatar'),
userDisplayName: document.getElementById('userDisplayName'),
signOutBtn: document.getElementById('signOutBtn'),
mobileSignOutBtn: document.getElementById('mobileSignOutBtn'),
mobileUserName: document.getElementById('mobileUserName'),
mobileUserEmail: document.getElementById('mobileUserEmail'),
mobileUserAvatar: document.getElementById('mobileUserAvatar'),
// Theme
themeToggle: document.getElementById('themeToggle'),
darkModeIcon: document.getElementById('darkModeIcon'),
lightModeIcon: document.getElementById('lightModeIcon'),
mobileThemeToggle: document.getElementById('mobileThemeToggle'),
mobileDarkModeIcon: document.getElementById('mobileDarkModeIcon'),
mobileLightModeIcon: document.getElementById('mobileLightModeIcon'),
// Mobile menu
mobileMenuBtn: document.getElementById('mobileMenuBtn'),
mobileMenuOpenIcon: document.getElementById('mobileMenuOpenIcon'),
mobileMenuCloseIcon: document.getElementById('mobileMenuCloseIcon'),
mobileMenu: document.getElementById('mobileMenu'),
// Dashboard
greetingTime: document.getElementById('greetingTime'),
recentSummaries: document.getElementById('recentSummaries'),
upcomingReviews: document.getElementById('upcomingReviews'),
recentFlashcards: document.getElementById('recentFlashcards'),
// Summarize
contentInput: document.getElementById('contentInput'),
uploadPdfBtn: document.getElementById('uploadPdfBtn'),
pdfUpload: document.getElementById('pdfUpload'),
summarizeBtn: document.getElementById('summarizeBtn'),
summarizeBtnText: document.getElementById('summarizeBtnText'),
summarizeLoading: document.getElementById('summarizeLoading'),
summaryHistory: document.getElementById('summaryHistory'),
summaryResults: document.getElementById('summaryResults'),
generatedSummary: document.getElementById('generatedSummary'),
generatedKeyPoints: document.getElementById('generatedKeyPoints'),
generatedFlashcards: document.getElementById('generatedFlashcards'),
saveSummaryBtn: document.getElementById('saveSummaryBtn'),
copySummaryBtn: document.getElementById('copySummaryBtn'),
copyKeyPointsBtn: document.getElementById('copyKeyPointsBtn'),
saveFlashcardsBtn: document.getElementById('saveFlashcardsBtn'),
copyFlashcardsBtn: document.getElementById('copyFlashcardsBtn'),
// Flashcards
flashcardSort: document.getElementById('flashcardSort'),
startReviewBtn: document.getElementById('startReviewBtn'),
endReviewBtn: document.getElementById('endReviewBtn'),
currentFlashcard: document.getElementById('currentFlashcard'),
flashcardQuestion: document.getElementById('flashcardQuestion'),
flashcardAnswer: document.getElementById('flashcardAnswer'),
cardProgress: document.getElementById('cardProgress'),
cardStats: document.getElementById('cardStats'),
difficultyBtns: document.querySelectorAll('.difficultyBtn'),
flashcardDecks: document.getElementById('flashcardDecks'),
createDeckBtn: document.getElementById('createDeckBtn'),
// Schedule
addTaskBtn: document.getElementById('addTaskBtn'),
taskFilter: document.getElementById('taskFilter'),
taskList: document.getElementById('taskList'),
calendar: document.getElementById('calendar'),
// Modals
taskModal: document.getElementById('taskModal'),
closeTaskModal: document.getElementById('closeTaskModal'),
taskTitle: document.getElementById('taskTitle'),
taskDescription: document.getElementById('taskDescription'),
taskDueDate: document.getElementById('taskDueDate'),
taskPriority: document.getElementById('taskPriority'),
taskReminder: document.getElementById('taskReminder'),
cancelTaskBtn: document.getElementById('cancelTaskBtn'),
saveTaskBtn: document.getElementById('saveTaskBtn'),
deckModal: document.getElementById('deckModal'),
closeDeckModal: document.getElementById('closeDeckModal'),
deckTitle: document.getElementById('deckTitle'),
deckDescription: document.getElementById('deckDescription'),
colorOptions: document.querySelectorAll('.colorOption'),
cancelDeckBtn: document.getElementById('cancelDeckBtn'),
saveDeckBtn: document.getElementById('saveDeckBtn'),
// Toast
toast: document.getElementById('toast'),
toastIcon: document.getElementById('toastIcon'),
toastMessage: document.getElementById('toastMessage'),
closeToast: document.getElementById('closeToast')
};
// App State
let state = {
currentUser: null,
currentSection: 'dashboard',
darkMode: localStorage.getItem('darkMode') === 'true',
flashcardQueue: [],
currentFlashcardIndex: 0,
currentDeck: null,
selectedColor: 'blue',
currentSummary: null,
tasks: []
};
// Initialize the app
function init() {
setupEventListeners();
checkAuthState();
updateGreeting();
setupTheme();
// Check for service worker support
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
initializeMessaging();
})
.catch(err => {
console.log('ServiceWorker registration failed: ', err);
});
}
}
// Set up all event listeners
function setupEventListeners() {
// Auth
elements.closeAuthModal.addEventListener('click', () => toggleAuthModal(false));
elements.loginTab.addEventListener('click', () => showAuthForm('login'));
elements.signupTab.addEventListener('click', () => showAuthForm('signup'));
elements.loginBtn.addEventListener('click', handleLogin);
elements.signupBtn.addEventListener('click', handleSignup);
elements.googleLoginBtn.addEventListener('click', handleGoogleLogin);
elements.signOutBtn.addEventListener('click', handleSignOut);
elements.mobileSignOutBtn.addEventListener('click', handleSignOut);
// Navigation
elements.dashboardNav.addEventListener('click', () => showSection('dashboard'));
elements.summarizeNav.addEventListener('click', () => showSection('summarize'));
elements.flashcardsNav.addEventListener('click', () => showSection('flashcards'));
elements.scheduleNav.addEventListener('click', () => showSection('schedule'));
elements.mobileDashboardNav.addEventListener('click', () => {
showSection('dashboard');
toggleMobileMenu(false);
});
elements.mobileSummarizeNav.addEventListener('click', () => {
showSection('summarize');
toggleMobileMenu(false);
});
elements.mobileFlashcardsNav.addEventListener('click', () => {
showSection('flashcards');
toggleMobileMenu(false);
});
elements.mobileScheduleNav.addEventListener('click', () => {
showSection('schedule');
toggleMobileMenu(false);
});
// User menu
elements.userMenuBtn.addEventListener('click', () => toggleUserMenu());
document.addEventListener('click', (e) => {
if (!elements.userMenuBtn.contains(e.target) && !elements.userMenu.contains(e.target)) {
elements.userMenu.classList.add('hidden');
}
});
// Theme
elements.themeToggle.addEventListener('click', toggleTheme);
elements.mobileThemeToggle.addEventListener('click', toggleTheme);
// Mobile menu
elements.mobileMenuBtn.addEventListener('click', () => toggleMobileMenu());
// Summarize
elements.contentInput.addEventListener('input', () => {
elements.summarizeBtn.disabled = elements.contentInput.value.trim() === '';
});
elements.uploadPdfBtn.addEventListener('click', () => elements.pdfUpload.click());
elements.pdfUpload.addEventListener('change', handlePdfUpload);
elements.summarizeBtn.addEventListener('click', handleSummarize);
elements.saveSummaryBtn.addEventListener('click', saveSummary);
elements.copySummaryBtn.addEventListener('click', copySummary);
elements.copyKeyPointsBtn.addEventListener('click', copyKeyPoints);
elements.saveFlashcardsBtn.addEventListener('click', saveFlashcards);
elements.copyFlashcardsBtn.addEventListener('click', copyFlashcards);
// Flashcards
elements.startReviewBtn.addEventListener('click', startFlashcardReview);
elements.endReviewBtn.addEventListener('click', endFlashcardReview);
elements.currentFlashcard.addEventListener('click', flipFlashcard);
elements.difficultyBtns.forEach(btn => {
btn.addEventListener('click', () => rateFlashcard(parseInt(btn.dataset.difficulty)));
});
elements.flashcardSort.addEventListener('change', loadFlashcards);
elements.createDeckBtn.addEventListener('click', () => toggleDeckModal(true));
elements.saveDeckBtn.addEventListener('click', createDeck);
elements.cancelDeckBtn.addEventListener('click', () => toggleDeckModal(false));
elements.closeDeckModal.addEventListener('click', () => toggleDeckModal(false));
elements.colorOptions.forEach(option => {
option.addEventListener('click', () => {
state.selectedColor = option.dataset.color;
elements.colorOptions.forEach(opt => opt.classList.remove('border-blue-500'));
option.classList.add('border-blue-500');
});
});
// Schedule
elements.addTaskBtn.addEventListener('click', () => toggleTaskModal(true));
elements.taskFilter.addEventListener('change', loadTasks);
elements.saveTaskBtn.addEventListener('click', saveTask);
elements.cancelTaskBtn.addEventListener('click', () => toggleTaskModal(false));
elements.closeTaskModal.addEventListener('click', () => toggleTaskModal(false));
// Toast
elements.closeToast.addEventListener('click', () => toggleToast(false));
}
// Check auth state and update UI
function checkAuthState() {
auth.onAuthStateChanged(user => {
state.currentUser = user;
if (user) {
// User is signed in
updateUserUI(user);
loadDashboardData();
showSection(state.currentSection);
toggleAuthModal(false);
} else {
// No user is signed in
toggleAuthModal(true);
showSection('dashboard');
}
});
}
// Update user UI elements
function updateUserUI(user) {
const displayName = user.displayName || 'User';
const email = user.email || '';
const photoURL = user.photoURL || `https://ui-avatars.com/api/?name=${encodeURIComponent(displayName)}&background=3b82f6&color=fff`;
elements.userAvatar.src = photoURL;
elements.mobileUserAvatar.src = photoURL;
elements.mobileUserName.textContent = displayName;
elements.mobileUserEmail.textContent = email;
elements.userDisplayName.textContent = displayName;
}
// Toggle auth modal
function toggleAuthModal(show) {
elements.authModal.classList.toggle('hidden', !show);
if (show) {
showAuthForm('login');
}
}
// Show login or signup form
function showAuthForm(form) {
const isLogin = form === 'login';
elements.loginForm.classList.toggle('hidden', !isLogin);
elements.signupForm.classList.toggle('hidden', isLogin);
elements.loginTab.classList.toggle('text-blue-600', isLogin);
elements.loginTab.classList.toggle('dark:text-blue-400', isLogin);
elements.loginTab.classList.toggle('border-blue-600', isLogin);
elements.loginTab.classList.toggle('dark:border-blue-400', isLogin);
elements.loginTab.classList.toggle('text-gray-500', !isLogin);
elements.loginTab.classList.toggle('dark:text-gray-400', !isLogin);
elements.signupTab.classList.toggle('text-blue-600', !isLogin);
elements.signupTab.classList.toggle('dark:text-blue-400', !isLogin);
elements.signupTab.classList.toggle('border-blue-600', !isLogin);
elements.signupTab.classList.toggle('dark:border-blue-400', !isLogin);
elements.signupTab.classList.toggle('text-gray-500', isLogin);
elements.signupTab.classList.toggle('dark:text-gray-400', isLogin);
}
// Handle email/password login
async function handleLogin() {
const email = elements.loginEmail.value.trim();
const password = elements.loginPassword.value.trim();
if (!email || !password) {
showToast('Please enter both email and password', 'error');
return;
}
try {
await auth.signInWithEmailAndPassword(email, password);
showToast('Logged in successfully', 'success');
} catch (error) {
console.error('Login error:', error);
showToast(error.message, 'error');
}
}
// Handle email/password signup
async function handleSignup() {
const email = elements.signupEmail.value.trim();
const password = elements.signupPassword.value.trim();
const confirmPassword = elements.confirmPassword.value.trim();
if (!email || !password || !confirmPassword) {
showToast('Please fill in all fields', 'error');
return;
}
if (password !== confirmPassword) {
showToast('Passwords do not match', 'error');
return;
}
if (password.length < 6) {
showToast('Password should be at least 6 characters', 'error');
return;
}
try {
await auth.createUserWithEmailAndPassword(email, password);
showToast('Account created successfully', 'success');
} catch (error) {
console.error('Signup error:', error);
showToast(error.message, 'error');
}
}
// Handle Google login
async function handleGoogleLogin() {
const provider = new firebase.auth.GoogleAuthProvider();
try {
await auth.signInWithPopup(provider);
showToast('Logged in with Google', 'success');
} catch (error) {
console.error('Google login error:', error);
showToast(error.message, 'error');
}
}
// Handle sign out
async function handleSignOut() {
try {
await auth.signOut();
showToast('Logged out successfully', 'success');
} catch (error) {
console.error('Sign out error:', error);
showToast(error.message, 'error');
}
}
// Toggle user menu
function toggleUserMenu() {
elements.userMenu.classList.toggle('hidden');
}
// Toggle mobile menu
function toggleMobileMenu(show) {
if (typeof show === 'undefined') {
show = elements.mobileMenu.classList.contains('hidden');
}
elements.mobileMenu.classList.toggle('hidden', !show);
elements.mobileMenuOpenIcon.classList.toggle('hidden', show);
elements.mobileMenuCloseIcon.classList.toggle('hidden', !show);
}
// Show specific section
function showSection(section) {
state.currentSection = section;
// Hide all sections
elements.dashboardSection.classList.add('hidden');
elements.summarizeSection.classList.add('hidden');
elements.flashcardsSection.classList.add('hidden');
elements.scheduleSection.classList.add('hidden');
// Update nav highlights
elements.dashboardNav.classList.remove('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.dashboardNav.classList.add('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.summarizeNav.classList.remove('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.summarizeNav.classList.add('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.flashcardsNav.classList.remove('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.flashcardsNav.classList.add('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.scheduleNav.classList.remove('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.scheduleNav.classList.add('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.mobileDashboardNav.classList.remove('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
elements.mobileDashboardNav.classList.add('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileSummarizeNav.classList.remove('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
elements.mobileSummarizeNav.classList.add('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileFlashcardsNav.classList.remove('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
elements.mobileFlashcardsNav.classList.add('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileScheduleNav.classList.remove('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
elements.mobileScheduleNav.classList.add('border-transparent', 'text-gray-600', 'dark:text-gray-400');
// Show selected section and update nav
switch (section) {
case 'dashboard':
elements.dashboardSection.classList.remove('hidden');
elements.dashboardNav.classList.remove('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.dashboardNav.classList.add('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.mobileDashboardNav.classList.remove('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileDashboardNav.classList.add('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
loadDashboardData();
break;
case 'summarize':
elements.summarizeSection.classList.remove('hidden');
elements.summarizeNav.classList.remove('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.summarizeNav.classList.add('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.mobileSummarizeNav.classList.remove('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileSummarizeNav.classList.add('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
loadSummaryHistory();
break;
case 'flashcards':
elements.flashcardsSection.classList.remove('hidden');
elements.flashcardsNav.classList.remove('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.flashcardsNav.classList.add('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.mobileFlashcardsNav.classList.remove('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileFlashcardsNav.classList.add('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
loadFlashcards();
loadFlashcardDecks();
break;
case 'schedule':
elements.scheduleSection.classList.remove('hidden');
elements.scheduleNav.classList.remove('border-transparent', 'text-gray-500', 'dark:text-gray-400');
elements.scheduleNav.classList.add('border-blue-500', 'text-gray-900', 'dark:text-white');
elements.mobileScheduleNav.classList.remove('border-transparent', 'text-gray-600', 'dark:text-gray-400');
elements.mobileScheduleNav.classList.add('bg-blue-50', 'dark:bg-gray-700', 'border-blue-500', 'text-blue-700', 'dark:text-blue-400');
loadTasks();
break;
}
}
// Load dashboard data
function loadDashboardData() {
if (!state.currentUser) return;
// Recent summaries
db.collection('summaries')
.where('userId', '==', state.currentUser.uid)
.orderBy('createdAt', 'desc')
.limit(3)
.get()
.then(querySnapshot => {
elements.recentSummaries.innerHTML = '';
if (querySnapshot.empty) {
elements.recentSummaries.innerHTML = '<p class="text-gray-500 dark:text-gray-400 text-center">No recent summaries found</p>';
return;
}
querySnapshot.forEach(doc => {
const data = doc.data();
const summaryEl = document.createElement('div');
summaryEl.className = 'border-b border-gray-200 dark:border-gray-700 pb-3 last:border-0 last:pb-0';
summaryEl.innerHTML = `
<h4 class="font-medium text-gray-900 dark:text-white truncate">${data.title || 'Untitled Summary'}</h4>
<p class="text-sm text-gray-600 dark:text-gray-300 mt-1 line-clamp-2">${data.summary || ''}</p>
<div class="mt-2 flex justify-between items-center">
<span class="text-xs text-gray-500 dark:text-gray-400">${formatDate(data.createdAt?.toDate())}</span>
<a href="#" class="text-xs text-blue-600 dark:text-blue-400 hover:underline" data-id="${doc.id}">View</a>
</div>
`;
elements.recentSummaries.appendChild(summaryEl);
// Add click event to view summary
summaryEl.querySelector('a').addEventListener('click', (e) => {
e.preventDefault();
showSection('summarize');
// In a real app, we would load the full summary here
});
});
})
.catch(error => {
console.error('Error loading recent summaries:', error);
elements.recentSummaries.innerHTML = '<p class="text-red-500 dark:text-red-400">Error loading summaries</p>';
});
// Upcoming reviews
const now = new Date();
const nextWeek = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
db.collection('flashcards')
.where('userId', '==', state.currentUser.uid)
.where('nextReviewTs', '>=', now)
.where('nextReviewTs', '<=', nextWeek)
.orderBy('nextReviewTs')
.limit(5)
.get()
.then(querySnapshot => {
elements.upcomingReviews.innerHTML = '';
if (querySnapshot.empty) {
elements.upcomingReviews.innerHTML = '<p class="text-gray-500 dark:text-gray-400 text-center">No upcoming reviews</p>';
return;
}
query
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Only1bigX/scholarplug" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |