Spaces:
Running
Running
File size: 41,980 Bytes
1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 c972c04 1dc6460 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Launchmate Study</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">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: '#6366f1',
secondary: '#8b5cf6',
dark: '#0f172a',
darker: '#020617'
}
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
background-color: #020617;
color: #e2e8f0;
}
.progress-ring__circle {
transition: stroke-dashoffset 0.3s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: #1e293b;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background-color: #475569;
border-radius: 20px;
}
</style>
</head>
<body class="min-h-screen overflow-x-hidden">
<div class="flex h-screen">
<!-- Sidebar -->
<div class="hidden md:flex flex-col w-64 bg-slate-900 border-r border-slate-800">
<div class="flex items-center justify-between p-4 border-b border-slate-800">
<div class="flex items-center space-x-2">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-primary to-secondary flex items-center justify-center">
<i class="fas fa-rocket text-white text-sm"></i>
</div>
<span class="text-xl font-bold">Launchmate</span>
</div>
</div>
<div class="flex-1 overflow-y-auto custom-scrollbar p-4">
<div class="space-y-1">
<button id="subjects-btn" class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg bg-slate-800 text-primary">
<i class="fas fa-book"></i>
<span>Subjects</span>
</button>
<button id="progress-btn" class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg hover:bg-slate-800 text-slate-400 hover:text-slate-200">
<i class="fas fa-chart-line"></i>
<span>Progress</span>
</button>
<button id="mobile-settings-btn" class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg hover:bg-slate-800 text-slate-400 hover:text-slate-200">
<i class="fas fa-cog"></i>
<span>Settings</span>
</button>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 flex flex-col h-screen overflow-hidden bg-slate-950">
<!-- Mobile Header -->
<div class="md:hidden flex items-center justify-between p-4 border-b border-slate-800">
<h1 class="text-xl font-bold flex items-center space-x-2">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-primary to-secondary flex items-center justify-center">
<i class="fas fa-rocket text-white text-sm"></i>
</div>
<span>Launchmate</span>
</h1>
<button id="mobile-menu-btn" class="p-2 rounded-lg hover:bg-slate-800">
<i class="fas fa-bars"></i>
</button>
</div>
<!-- Mobile Menu -->
<div id="mobile-menu" class="md:hidden hidden absolute top-16 right-2 z-50 w-56 bg-slate-900 rounded-lg shadow-lg border border-slate-800">
<div class="p-2 space-y-1">
<button id="mobile-subjects-btn" class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg bg-slate-800 text-primary">
<i class="fas fa-book"></i>
<span>Subjects</span>
</button>
<button id="mobile-progress-btn" class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg hover:bg-slate-800 text-slate-400 hover:text-slate-200">
<i class="fas fa-chart-line"></i>
<span>Progress</span>
</button>
<button class="w-full flex items-center space-x-3 px-3 py-2 rounded-lg hover:bg-slate-800 text-slate-400 hover:text-slate-200">
<i class="fas fa-cog"></i>
<span>Settings</span>
</button>
</div>
</div>
<!-- Content -->
<div class="flex-1 overflow-y-auto custom-scrollbar">
<!-- Subjects View -->
<div id="subjects-view" class="p-4">
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold">Your Subjects</h1>
<button id="add-subject-btn" class="px-3 py-1 bg-primary hover:bg-primary/90 rounded-lg flex items-center space-x-1">
<i class="fas fa-plus text-sm"></i>
<span>Add Subject</span>
</button>
</div>
<div id="subjects-list" class="space-y-4">
<!-- Subjects will be added here dynamically -->
</div>
</div>
<!-- Progress View (Hidden by default) -->
<div id="progress-view" class="hidden p-4">
<h1 class="text-2xl font-bold mb-6">Your Progress</h1>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
<div class="bg-slate-900 p-4 rounded-xl border border-slate-800">
<div class="flex justify-between mb-2">
<span class="text-slate-400">Total Subjects</span>
<span id="total-subjects-count" class="font-semibold">0</span>
</div>
<div class="flex justify-between">
<span class="text-slate-400">Total Chapters</span>
<span id="total-chapters-count" class="font-semibold">0</span>
</div>
</div>
<div class="bg-slate-900 p-4 rounded-xl border border-slate-800">
<div class="flex justify-between mb-2">
<span class="text-slate-400">Completed Chapters</span>
<span id="completed-chapters-count" class="font-semibold">0</span>
</div>
<div class="flex justify-between">
<span class="text-slate-400">Completion %</span>
<span id="completion-percentage" class="font-semibold">0%</span>
</div>
</div>
<div class="bg-slate-900 p-4 rounded-xl border border-slate-800">
<div class="flex items-center justify-between mb-2">
<span class="text-slate-400">Overall Progress</span>
</div>
<div class="w-full bg-slate-800 rounded-full h-2.5">
<div id="overall-progress-bar" class="bg-gradient-to-r from-primary to-secondary h-2.5 rounded-full" style="width: 0%"></div>
</div>
</div>
</div>
<h2 class="text-xl font-semibold mb-4">Subject Breakdown</h2>
<div id="subject-progress-cards" class="grid grid-cols-1 gap-4">
<!-- Progress cards will be added here dynamically -->
</div>
</div>
<!-- Add Subject Modal -->
<div id="add-subject-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden">
<div class="bg-slate-900 rounded-xl border border-slate-800 w-full max-w-md mx-4">
<div class="p-4 border-b border-slate-800">
<h2 class="text-xl font-semibold">Add New Subject</h2>
</div>
<div class="p-4">
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Subject Name</label>
<input id="subject-name-input" type="text" class="w-full px-3 py-2 bg-slate-800 border border-slate-700 rounded-lg focus:outline-none focus:ring-1 focus:ring-primary">
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Or add multiple (comma separated)</label>
<textarea id="batch-subjects-input" class="w-full px-3 py-2 bg-slate-800 border border-slate-700 rounded-lg focus:outline-none focus:ring-1 focus:ring-primary h-24" placeholder="Math, Science, History"></textarea>
</div>
</div>
<div class="p-4 border-t border-slate-800 flex justify-end space-x-2">
<button id="cancel-subject-btn" class="px-4 py-2 rounded-lg border border-slate-700 hover:bg-slate-800">Cancel</button>
<button id="save-subject-btn" class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/90">Add Subject</button>
</div>
</div>
</div>
<!-- Add Chapter Modal -->
<div id="add-chapter-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden">
<div class="bg-slate-900 rounded-xl border border-slate-800 w-full max-w-md mx-4">
<div class="p-4 border-b border-slate-800">
<h2 id="add-chapter-modal-title" class="text-xl font-semibold">Add Chapter to <span id="current-subject-title"></span></h2>
</div>
<div class="p-4">
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Chapter Name</label>
<input id="chapter-name-input" type="text" class="w-full px-3 py-2 bg-slate-800 border border-slate-700 rounded-lg focus:outline-none focus:ring-1 focus:ring-primary">
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Or add multiple (comma separated)</label>
<textarea id="batch-chapters-input" class="w-full px-3 py-2 bg-slate-800 border border-slate-700 rounded-lg focus:outline-none focus:ring-1 focus:ring-primary h-24" placeholder="Chapter 1, Chapter 2, Chapter 3"></textarea>
</div>
</div>
<div class="p-4 border-t border-slate-800 flex justify-end space-x-2">
<button id="cancel-chapter-btn" class="px-4 py-2 rounded-lg border border-slate-700 hover:bg-slate-800">Cancel</button>
<button id="save-chapter-btn" class="px-4 py-2 rounded-lg bg-primary hover:bg-primary/90">Add Chapter</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Data structure to store all subjects and chapters
let studyData = JSON.parse(localStorage.getItem('studyData')) || {
subjects: []
};
// Current selected subject for adding chapters
let currentSubjectId = null;
// DOM Elements
const subjectsView = document.getElementById('subjects-view');
const progressView = document.getElementById('progress-view');
const subjectsBtn = document.getElementById('subjects-btn');
const progressBtn = document.getElementById('progress-btn');
const mobileSubjectsBtn = document.getElementById('mobile-subjects-btn');
const mobileProgressBtn = document.getElementById('mobile-progress-btn');
const mobileMenuBtn = document.getElementById('mobile-menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
const addSubjectBtn = document.getElementById('add-subject-btn');
const addSubjectModal = document.getElementById('add-subject-modal');
const cancelSubjectBtn = document.getElementById('cancel-subject-btn');
const saveSubjectBtn = document.getElementById('save-subject-btn');
const subjectNameInput = document.getElementById('subject-name-input');
const batchSubjectsInput = document.getElementById('batch-subjects-input');
const addChapterModal = document.getElementById('add-chapter-modal');
const chapterNameInput = document.getElementById('chapter-name-input');
const batchChaptersInput = document.getElementById('batch-chapters-input');
const cancelChapterBtn = document.getElementById('cancel-chapter-btn');
const saveChapterBtn = document.getElementById('save-chapter-btn');
const currentSubjectTitle = document.getElementById('current-subject-title');
const subjectsList = document.getElementById('subjects-list');
const subjectProgressCards = document.getElementById('subject-progress-cards');
const totalSubjectsCount = document.getElementById('total-subjects-count');
const totalChaptersCount = document.getElementById('total-chapters-count');
const completedChaptersCount = document.getElementById('completed-chapters-count');
const completionPercentage = document.getElementById('completion-percentage');
const overallProgressBar = document.getElementById('overall-progress-bar');
// Edit chapter name
function editChapter(chapterId) {
const newName = prompt('Enter new chapter name:');
if (newName && newName.trim()) {
for (const subject of studyData.subjects) {
const chapter = subject.chapters.find(c => c.id === chapterId);
if (chapter) {
chapter.name = newName.trim();
saveData();
renderSubjects();
break;
}
}
}
}
// Delete chapter
function deleteChapter(chapterId) {
if (confirm('Are you sure you want to delete this chapter?')) {
for (const subject of studyData.subjects) {
const chapterIndex = subject.chapters.findIndex(c => c.id === chapterId);
if (chapterIndex !== -1) {
subject.chapters.splice(chapterIndex, 1);
saveData();
renderSubjects();
updateProgressMetrics();
break;
}
}
}
}
// Delete subject
function deleteSubject(subjectId) {
if (confirm('Are you sure you want to delete this subject and all its chapters?')) {
const subjectIndex = studyData.subjects.findIndex(s => s.id === subjectId);
if (subjectIndex !== -1) {
studyData.subjects.splice(subjectIndex, 1);
saveData();
renderSubjects();
updateProgressMetrics();
}
}
}
// Initialize the app
function initApp() {
renderSubjects();
updateProgressMetrics();
// Load subjects view by default
showSubjectsView();
}
// Render all subjects
function renderSubjects() {
subjectsList.innerHTML = '';
if (studyData.subjects.length === 0) {
subjectsList.innerHTML = `
<div class="text-center py-10">
<i class="fas fa-book-open text-5xl text-slate-600 mb-4"></i>
<h3 class="text-lg font-semibold text-slate-400 mb-1">No subjects yet</h3>
<p class="text-sm text-slate-500">Add your first subject to get started</p>
</div>
`;
return;
}
studyData.subjects.forEach((subject, subjectIndex) => {
const subjectElement = document.createElement('div');
subjectElement.className = 'bg-slate-900 rounded-xl border border-slate-800 overflow-hidden';
// Count completed chapters in this subject
const completedChapters = subject.chapters.filter(chapter =>
chapter.completion.theory && chapter.completion.revision && chapter.completion.pyq
).length;
const completionPercentage = subject.chapters.length > 0
? Math.round((completedChapters / subject.chapters.length) * 100)
: 0;
subjectElement.innerHTML = `
<div class="p-4">
<div class="flex justify-between items-center mb-2">
<h2 class="font-semibold text-lg">${subject.name}</h2>
<div class="flex items-center space-x-2">
<span class="text-xs text-slate-400">${completedChapters}/${subject.chapters.length} chapters</span>
<button data-subject-id="${subject.id}" class="add-chapter-btn px-2 py-1 text-xs rounded bg-slate-800 hover:bg-slate-700">
<i class="fas fa-plus mr-1"></i> Add Chapter
</button>
<button data-subject-id="${subject.id}" class="delete-subject-btn px-2 py-1 text-xs rounded bg-red-900/50 hover:bg-red-900 text-red-400">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
<div class="flex items-center space-x-2">
<div class="w-full bg-slate-800 rounded-full h-2">
<div class="bg-gradient-to-r from-primary to-secondary h-2 rounded-full" style="width: ${completionPercentage}%"></div>
</div>
<span class="text-xs text-slate-400">${completionPercentage}%</span>
</div>
</div>
<div class="border-t border-slate-800">
<div class="p-4 chapters-list-${subject.id}">
${subject.chapters.length === 0 ? `
<div class="text-center py-4 text-slate-500">
No chapters yet. Add your first chapter to start tracking.
</div>
` : renderChaptersList(subject.chapters)}
</div>
</div>
`;
subjectsList.appendChild(subjectElement);
});
// Add event listeners to all add chapter buttons
document.querySelectorAll('.add-chapter-btn').forEach(btn => {
btn.addEventListener('click', function() {
const subjectId = this.getAttribute('data-subject-id');
openAddChapterModal(subjectId);
});
});
}
// Render chapters list for a subject
function renderChaptersList(chapters) {
return chapters.map(chapter => {
// Calculate completion percentage (0 to 100)
const completedCount = [chapter.completion.theory, chapter.completion.revision, chapter.completion.pyq].filter(Boolean).length;
const completionPercentage = Math.round((completedCount / 3) * 100);
// Calculate stroke dashoffset for circular progress
const circumference = 2 * Math.PI * 14;
const strokeDashoffset = circumference - (completionPercentage / 100) * circumference;
return `
<div class="chapter-item mb-3 last:mb-0" data-chapter-id="${chapter.id}">
<div class="flex items-start">
<div class="relative mr-3 mt-1">
<svg class="w-8 h-8">
<circle
class="progress-ring__circle"
stroke="url(#gradient-${chapter.id})"
stroke-width="3"
fill="transparent"
r="14"
cx="16"
cy="16"
stroke-dasharray="${circumference}"
stroke-dashoffset="${strokeDashoffset}"
/>
<defs>
<linearGradient id="gradient-${chapter.id}" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#6366f1" />
<stop offset="100%" stop-color="#8b5cf6" />
</linearGradient>
</defs>
</svg>
<div class="absolute inset-0 flex items-center justify-center">
${completedCount === 3 ? `
<i class="fas fa-check text-xs text-white"></i>
` : `
<span class="text-xs font-medium">${completedCount}/3</span>
`}
</div>
</div>
<div class="flex-1">
<h3 class="font-medium">${chapter.name}</h3>
<div class="flex flex-wrap gap-2 mt-1">
<button data-check-type="theory" class="checkpoint-btn text-xs px-2 py-1 rounded-md ${chapter.completion.theory ? 'bg-primary/20 text-primary' : 'bg-slate-800 text-slate-400'}">
Theory ${chapter.completion.theory ? '<i class="fas fa-check ml-1"></i>' : ''}
</button>
<button data-check-type="revision" class="checkpoint-btn text-xs px-2 py-1 rounded-md ${chapter.completion.revision ? 'bg-primary/20 text-primary' : 'bg-slate-800 text-slate-400'}">
Revision ${chapter.completion.revision ? '<i class="fas fa-check ml-1"></i>' : ''}
</button>
<button data-check-type="pyq" class="checkpoint-btn text-xs px-2 py-1 rounded-md ${chapter.completion.pyq ? 'bg-primary/20 text-primary' : 'bg-slate-800 text-slate-400'}">
PYQ ${chapter.completion.pyq ? '<i class="fas fa-check ml-1"></i>' : ''}
</button>
</div>
</div>
<div class="ml-2 flex space-x-2">
<button data-chapter-id="${chapter.id}" class="delete-chapter-btn p-1 text-slate-500 hover:text-red-400">
<i class="fas fa-trash text-xs"></i>
</button>
</div>
</div>
</div>
`;
}).join('');
}
// Render progress view
function renderProgressView() {
subjectProgressCards.innerHTML = '';
if (studyData.subjects.length === 0) {
subjectProgressCards.innerHTML = `
<div class="text-center py-10">
<i class="fas fa-chart-pie text-5xl text-slate-600 mb-4"></i>
<h3 class="text-lg font-semibold text-slate-400 mb-1">No data to display</h3>
<p class="text-sm text-slate-500">Add subjects and chapters to track your progress</p>
</div>
`;
return;
}
studyData.subjects.forEach(subject => {
const completedChapters = subject.chapters.filter(chapter =>
chapter.completion.theory && chapter.completion.revision && chapter.completion.pyq
).length;
const completionPercentage = subject.chapters.length > 0
? Math.round((completedChapters / subject.chapters.length) * 100)
: 0;
const card = document.createElement('div');
card.className = 'bg-slate-900 rounded-xl border border-slate-800 p-4';
card.innerHTML = `
<div class="flex justify-between items-start mb-2">
<h3 class="font-semibold">${subject.name}</h3>
<span class="text-sm ${completionPercentage === 100 ? 'text-emerald-400' : completionPercentage > 50 ? 'text-primary' : 'text-amber-400'}">${completionPercentage}%</span>
</div>
<div class="flex items-center space-x-2 mb-3">
<div class="w-full bg-slate-800 rounded-full h-2">
<div class="bg-gradient-to-r from-primary to-secondary h-2 rounded-full" style="width: ${completionPercentage}%"></div>
</div>
</div>
<div class="flex justify-between text-sm text-slate-400">
<span>${completedChapters}/${subject.chapters.length} chapters</span>
<span>${subject.chapters.filter(c => c.completion.theory).length} theory</span>
<span>${subject.chapters.filter(c => c.completion.revision).length} revision</span>
<span>${subject.chapters.filter(c => c.completion.pyq).length} PYQ</span>
</div>
`;
subjectProgressCards.appendChild(card);
});
}
// Update progress metrics
function updateProgressMetrics() {
const totalSubjects = studyData.subjects.length;
let totalChapters = 0;
let completedChapters = 0;
studyData.subjects.forEach(subject => {
totalChapters += subject.chapters.length;
completedChapters += subject.chapters.filter(chapter =>
chapter.completion.theory && chapter.completion.revision && chapter.completion.pyq
).length;
});
const overallCompletion = totalChapters > 0 ? Math.round((completedChapters / totalChapters) * 100) : 0;
totalSubjectsCount.textContent = totalSubjects;
totalChaptersCount.textContent = totalChapters;
completedChaptersCount.textContent = completedChapters;
completionPercentage.textContent = `${overallCompletion}%`;
overallProgressBar.style.width = `${overallCompletion}%`;
}
// Show subjects view
function showSubjectsView() {
subjectsView.classList.remove('hidden');
progressView.classList.add('hidden');
subjectsBtn.classList.add('bg-slate-800', 'text-primary');
subjectsBtn.classList.remove('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
progressBtn.classList.remove('bg-slate-800', 'text-primary');
progressBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileSubjectsBtn.classList.add('bg-slate-800', 'text-primary');
mobileSubjectsBtn.classList.remove('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileProgressBtn.classList.remove('bg-slate-800', 'text-primary');
mobileProgressBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
}
// Show settings view
function showSettingsView() {
subjectsView.classList.add('hidden');
progressView.classList.add('hidden');
document.getElementById('settings-view').classList.remove('hidden');
// Update button states
subjectsBtn.classList.remove('bg-slate-800', 'text-primary');
subjectsBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
progressBtn.classList.remove('bg-slate-800', 'text-primary');
progressBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileSubjectsBtn.classList.remove('bg-slate-800', 'text-primary');
mobileSubjectsBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileProgressBtn.classList.remove('bg-slate-800', 'text-primary');
mobileProgressBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
// Close mobile menu if open
mobileMenu.classList.add('hidden');
}
// Show progress view
function showProgressView() {
subjectsView.classList.add('hidden');
progressView.classList.remove('hidden');
settingsView.classList.add('hidden');
subjectsView.classList.add('hidden');
progressView.classList.remove('hidden');
progressBtn.classList.add('bg-slate-800', 'text-primary');
progressBtn.classList.remove('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
subjectsBtn.classList.remove('bg-slate-800', 'text-primary');
subjectsBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileProgressBtn.classList.add('bg-slate-800', 'text-primary');
mobileProgressBtn.classList.remove('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
mobileSubjectsBtn.classList.remove('bg-slate-800', 'text-primary');
mobileSubjectsBtn.classList.add('text-slate-400', 'hover:bg-slate-800', 'hover:text-slate-200');
renderProgressView();
}
// Open add subject modal
function openAddSubjectModal() {
addSubjectModal.classList.remove('hidden');
subjectNameInput.focus();
}
// Close add subject modal
function closeAddSubjectModal() {
addSubjectModal.classList.add('hidden');
subjectNameInput.value = '';
batchSubjectsInput.value = '';
}
// Open add chapter modal
function openAddChapterModal(subjectId) {
currentSubjectId = subjectId;
const subject = studyData.subjects.find(s => s.id === subjectId);
currentSubjectTitle.textContent = subject.name;
addChapterModal.classList.remove('hidden');
chapterNameInput.focus();
}
// Close add chapter modal
function closeAddChapterModal() {
addChapterModal.classList.add('hidden');
chapterNameInput.value = '';
batchChaptersInput.value = '';
currentSubjectId = null;
}
// Save subject to data
function saveSubject() {
const singleSubject = subjectNameInput.value.trim();
const batchSubjects = batchSubjectsInput.value.trim();
if (singleSubject || batchSubjects) {
if (singleSubject) {
const newSubject = {
id: generateId(),
name: singleSubject,
chapters: []
};
studyData.subjects.push(newSubject);
}
if (batchSubjects) {
const subjectsArray = batchSubjects.split(',')
.map(s => s.trim())
.filter(s => s.length > 0);
subjectsArray.forEach(subjectName => {
const newSubject = {
id: generateId(),
name: subjectName,
chapters: []
};
studyData.subjects.push(newSubject);
});
}
saveData();
renderSubjects();
updateProgressMetrics();
closeAddSubjectModal();
}
}
// Save chapter to data
function saveChapter() {
const singleChapter = chapterNameInput.value.trim();
const batchChapters = batchChaptersInput.value.trim();
if ((singleChapter || batchChapters) && currentSubjectId) {
const subjectIndex = studyData.subjects.findIndex(s => s.id === currentSubjectId);
if (subjectIndex !== -1) {
if (singleChapter) {
const newChapter = {
id: generateId(),
name: singleChapter,
completion: {
theory: false,
revision: false,
pyq: false
}
};
studyData.subjects[subjectIndex].chapters.push(newChapter);
}
if (batchChapters) {
const chaptersArray = batchChapters.split(',')
.map(c => c.trim())
.filter(c => c.length > 0);
chaptersArray.forEach(chapterName => {
const newChapter = {
id: generateId(),
name: chapterName,
completion: {
theory: false,
revision: false,
pyq: false
}
};
studyData.subjects[subjectIndex].chapters.push(newChapter);
});
}
saveData();
renderSubjects();
updateProgressMetrics();
closeAddChapterModal();
}
}
}
// Toggle chapter checkpoint
function toggleChapterCheckpoint(chapterId, checkType) {
for (const subject of studyData.subjects) {
const chapter = subject.chapters.find(c => c.id === chapterId);
if (chapter) {
chapter.completion[checkType] = !chapter.completion[checkType];
saveData();
renderSubjects();
updateProgressMetrics();
// If we're on the progress view, update it too
if (!progressView.classList.contains('hidden')) {
renderProgressView();
}
break;
}
}
}
// Generate unique ID
function generateId() {
return Date.now().toString(36) + Math.random().toString(36).substring(2);
}
// Save data to localStorage
function saveData() {
localStorage.setItem('studyData', JSON.stringify(studyData));
}
// Event Listeners
subjectsBtn.addEventListener('click', showSubjectsView);
progressBtn.addEventListener('click', showProgressView);
mobileSubjectsBtn.addEventListener('click', () => {
showSubjectsView();
mobileMenu.classList.add('hidden');
});
mobileProgressBtn.addEventListener('click', () => {
showProgressView();
mobileMenu.classList.add('hidden');
});
mobileMenuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
addSubjectBtn.addEventListener('click', openAddSubjectModal);
cancelSubjectBtn.addEventListener('click', closeAddSubjectModal);
saveSubjectBtn.addEventListener('click', saveSubject);
cancelChapterBtn.addEventListener('click', closeAddChapterModal);
saveChapterBtn.addEventListener('click', saveChapter);
// Close modals when clicking outside
window.addEventListener('click', (e) => {
if (e.target === addSubjectModal) {
closeAddSubjectModal();
}
if (e.target === addChapterModal) {
closeAddChapterModal();
}
if (!mobileMenu.contains(e.target) && e.target !== mobileMenuBtn) {
mobileMenu.classList.add('hidden');
}
});
// Delegated event listener for checkpoint buttons
subjectsList.addEventListener('click', (e) => {
if (e.target.classList.contains('checkpoint-btn') || e.target.closest('.checkpoint-btn')) {
const btn = e.target.classList.contains('checkpoint-btn') ? e.target : e.target.closest('.checkpoint-btn');
const chapterItem = btn.closest('.chapter-item');
const chapterId = chapterItem.getAttribute('data-chapter-id');
const checkType = btn.getAttribute('data-check-type');
toggleChapterCheckpoint(chapterId, checkType);
}
else if (e.target.classList.contains('edit-chapter-btn') || e.target.closest('.edit-chapter-btn')) {
const btn = e.target.classList.contains('edit-chapter-btn') ? e.target : e.target.closest('.edit-chapter-btn');
const chapterId = btn.getAttribute('data-chapter-id');
editChapter(chapterId);
}
else if (e.target.classList.contains('delete-chapter-btn') || e.target.closest('.delete-chapter-btn')) {
const btn = e.target.classList.contains('delete-chapter-btn') ? e.target : e.target.closest('.delete-chapter-btn');
const chapterId = btn.getAttribute('data-chapter-id');
deleteChapter(chapterId);
}
else if (e.target.classList.contains('delete-subject-btn') || e.target.closest('.delete-subject-btn')) {
const btn = e.target.classList.contains('delete-subject-btn') ? e.target : e.target.closest('.delete-subject-btn');
const subjectId = btn.getAttribute('data-subject-id');
deleteSubject(subjectId);
}
});
// Settings buttons
document.getElementById('settings-btn').addEventListener('click', showSettingsView);
document.getElementById('mobile-settings-btn').addEventListener('click', showSettingsView);
// Initialize the app
document.addEventListener('DOMContentLoaded', initApp);
</script>
<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=harsh02564/studyspace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |