Spaces:
Running
Running
File size: 37,846 Bytes
9a024bf | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ScheduleMaster | Your Personal Schedule Manager</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>
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Animation for task completion */
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; transform: translateX(20px); }
}
.completed-task {
animation: fadeOut 0.5s forwards;
}
/* Custom checkbox */
.custom-checkbox {
appearance: none;
-webkit-appearance: none;
width: 20px;
height: 20px;
border: 2px solid #3b82f6;
border-radius: 4px;
cursor: pointer;
position: relative;
}
.custom-checkbox:checked {
background-color: #3b82f6;
}
.custom-checkbox:checked::after {
content: '\f00c';
font-family: 'Font Awesome 6 Free';
font-weight: 900;
color: white;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 12px;
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-indigo-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-4 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-calendar-alt text-2xl"></i>
<h1 class="text-2xl font-bold">ScheduleMaster</h1>
</div>
<div class="flex items-center space-x-4">
<button id="theme-toggle" class="p-2 rounded-full hover:bg-indigo-500 transition">
<i class="fas fa-moon"></i>
</button>
<div class="relative">
<img src="https://ui-avatars.com/api/?name=User&background=random" alt="User" class="w-10 h-10 rounded-full cursor-pointer">
<div class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 hidden" id="user-dropdown">
<a href="#" class="block px-4 py-2 text-gray-800 hover:bg-indigo-100">Profile</a>
<a href="#" class="block px-4 py-2 text-gray-800 hover:bg-indigo-100">Settings</a>
<a href="#" class="block px-4 py-2 text-gray-800 hover:bg-indigo-100">Sign out</a>
</div>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow container mx-auto px-4 py-6 flex flex-col md:flex-row gap-6">
<!-- Sidebar -->
<aside class="w-full md:w-64 bg-white rounded-lg shadow-md p-4 h-fit">
<div class="mb-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Navigation</h2>
<nav>
<ul class="space-y-2">
<li>
<a href="#" class="flex items-center space-x-2 p-2 rounded-lg bg-indigo-100 text-indigo-700">
<i class="fas fa-calendar-day w-5"></i>
<span>Today</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-2 p-2 rounded-lg hover:bg-gray-100 text-gray-700">
<i class="fas fa-calendar-week w-5"></i>
<span>This Week</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-2 p-2 rounded-lg hover:bg-gray-100 text-gray-700">
<i class="fas fa-calendar w-5"></i>
<span>All Tasks</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-2 p-2 rounded-lg hover:bg-gray-100 text-gray-700">
<i class="fas fa-star w-5"></i>
<span>Important</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-2 p-2 rounded-lg hover:bg-gray-100 text-gray-700">
<i class="fas fa-check-circle w-5"></i>
<span>Completed</span>
</a>
</li>
</ul>
</nav>
</div>
<div>
<h2 class="text-xl font-semibold text-gray-800 mb-4">Categories</h2>
<div class="space-y-2">
<div class="flex items-center space-x-2">
<span class="w-3 h-3 rounded-full bg-red-500"></span>
<span>Work</span>
</div>
<div class="flex items-center space-x-2">
<span class="w-3 h-3 rounded-full bg-blue-500"></span>
<span>Personal</span>
</div>
<div class="flex items-center space-x-2">
<span class="w-3 h-3 rounded-full bg-green-500"></span>
<span>Health</span>
</div>
<div class="flex items-center space-x-2">
<span class="w-3 h-3 rounded-full bg-yellow-500"></span>
<span>Study</span>
</div>
<button class="mt-3 text-indigo-600 hover:text-indigo-800 flex items-center space-x-1">
<i class="fas fa-plus"></i>
<span>Add Category</span>
</button>
</div>
</div>
</aside>
<!-- Main Content Area -->
<div class="flex-grow">
<!-- Date and Add Task -->
<div class="bg-white rounded-lg shadow-md p-4 mb-6">
<div class="flex justify-between items-center">
<div>
<h2 class="text-2xl font-bold text-gray-800">Today's Schedule</h2>
<p class="text-gray-600" id="current-date">Loading date...</p>
</div>
<button id="add-task-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition">
<i class="fas fa-plus"></i>
<span>Add Task</span>
</button>
</div>
</div>
<!-- Task List -->
<div class="bg-white rounded-lg shadow-md p-4">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-800">Tasks</h3>
<div class="flex space-x-2">
<button class="p-2 text-gray-600 hover:text-indigo-600">
<i class="fas fa-filter"></i>
</button>
<button class="p-2 text-gray-600 hover:text-indigo-600">
<i class="fas fa-sort"></i>
</button>
</div>
</div>
<!-- Task Filters -->
<div class="flex space-x-2 mb-4 overflow-x-auto pb-2">
<button class="px-3 py-1 bg-indigo-100 text-indigo-700 rounded-full text-sm">All</button>
<button class="px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm">Work</button>
<button class="px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm">Personal</button>
<button class="px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm">Health</button>
<button class="px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm">Study</button>
</div>
<!-- Tasks -->
<div class="space-y-3" id="task-list">
<!-- Task items will be added here dynamically -->
</div>
<!-- Completed Tasks Toggle -->
<div class="mt-6">
<button id="toggle-completed" class="text-indigo-600 hover:text-indigo-800 flex items-center space-x-1">
<i class="fas fa-chevron-down"></i>
<span>Show Completed (3)</span>
</button>
<div id="completed-tasks" class="mt-2 space-y-3 hidden">
<!-- Completed tasks will be shown here -->
</div>
</div>
</div>
</div>
<!-- Calendar Section -->
<div class="w-full md:w-80 bg-white rounded-lg shadow-md p-4 h-fit">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Calendar</h2>
<div class="flex space-x-2">
<button class="p-2 text-gray-600 hover:text-indigo-600">
<i class="fas fa-chevron-left"></i>
</button>
<button class="p-2 text-gray-600 hover:text-indigo-600">
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
<div class="grid grid-cols-7 gap-1 mb-2">
<div class="text-center text-xs font-medium text-gray-500">Sun</div>
<div class="text-center text-xs font-medium text-gray-500">Mon</div>
<div class="text-center text-xs font-medium text-gray-500">Tue</div>
<div class="text-center text-xs font-medium text-gray-500">Wed</div>
<div class="text-center text-xs font-medium text-gray-500">Thu</div>
<div class="text-center text-xs font-medium text-gray-500">Fri</div>
<div class="text-center text-xs font-medium text-gray-500">Sat</div>
</div>
<div class="grid grid-cols-7 gap-1" id="calendar-days">
<!-- Calendar days will be generated here -->
</div>
<div class="mt-6">
<h3 class="text-lg font-semibold text-gray-800 mb-2">Upcoming Events</h3>
<div class="space-y-2">
<div class="flex items-start space-x-2 p-2 hover:bg-gray-50 rounded-lg">
<div class="w-2 h-2 mt-2 rounded-full bg-red-500"></div>
<div>
<p class="text-sm font-medium">Team Meeting</p>
<p class="text-xs text-gray-500">Tomorrow, 10:00 AM</p>
</div>
</div>
<div class="flex items-start space-x-2 p-2 hover:bg-gray-50 rounded-lg">
<div class="w-2 h-2 mt-2 rounded-full bg-blue-500"></div>
<div>
<p class="text-sm font-medium">Dentist Appointment</p>
<p class="text-xs text-gray-500">Wed, 2:30 PM</p>
</div>
</div>
<div class="flex items-start space-x-2 p-2 hover:bg-gray-50 rounded-lg">
<div class="w-2 h-2 mt-2 rounded-full bg-green-500"></div>
<div>
<p class="text-sm font-medium">Gym Session</p>
<p class="text-xs text-gray-500">Fri, 6:00 PM</p>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Add Task Modal -->
<div id="add-task-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
<div class="flex justify-between items-center border-b px-6 py-4">
<h3 class="text-lg font-semibold">Add New Task</h3>
<button id="close-modal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<form id="task-form">
<div class="mb-4">
<label for="task-title" class="block text-sm font-medium text-gray-700 mb-1">Task Title</label>
<input type="text" id="task-title" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="What needs to be done?" required>
</div>
<div class="mb-4">
<label for="task-description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="task-description" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Add details..."></textarea>
</div>
<div class="grid grid-cols-2 gap-4 mb-4">
<div>
<label for="task-date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
<input type="date" id="task-date" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<div>
<label for="task-time" class="block text-sm font-medium text-gray-700 mb-1">Time</label>
<input type="time" id="task-time" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
<div class="flex space-x-2">
<button type="button" class="category-btn px-3 py-1 bg-red-100 text-red-700 rounded-full text-sm" data-category="work">Work</button>
<button type="button" class="category-btn px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm" data-category="personal">Personal</button>
<button type="button" class="category-btn px-3 py-1 bg-green-100 text-green-700 rounded-full text-sm" data-category="health">Health</button>
<button type="button" class="category-btn px-3 py-1 bg-yellow-100 text-yellow-700 rounded-full text-sm" data-category="study">Study</button>
</div>
<input type="hidden" id="task-category" value="">
</div>
<div class="flex items-center mb-6">
<input type="checkbox" id="task-important" class="custom-checkbox mr-2">
<label for="task-important" class="text-sm font-medium text-gray-700">Mark as important</label>
</div>
<div class="flex justify-end space-x-3">
<button type="button" id="cancel-task" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">Cancel</button>
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Add Task</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Set current date
const now = new Date();
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
document.getElementById('current-date').textContent = now.toLocaleDateString('en-US', options);
// Generate calendar days
generateCalendarDays();
// Sample tasks data
const tasks = [
{ id: 1, title: 'Complete project proposal', description: 'Finish the proposal document and send to manager', date: '2023-07-20', time: '14:00', category: 'work', important: true, completed: false },
{ id: 2, title: 'Grocery shopping', description: 'Buy fruits, vegetables, and milk', date: '2023-07-20', time: '18:00', category: 'personal', important: false, completed: false },
{ id: 3, title: 'Morning workout', description: '30 minutes cardio and strength training', date: '2023-07-21', time: '07:00', category: 'health', important: true, completed: false },
{ id: 4, title: 'Study React hooks', description: 'Complete tutorial on useEffect and useState', date: '2023-07-21', time: '20:00', category: 'study', important: false, completed: true },
{ id: 5, title: 'Team meeting', description: 'Weekly sync with development team', date: '2023-07-22', time: '10:00', category: 'work', important: true, completed: false },
{ id: 6, title: 'Dentist appointment', description: 'Regular dental checkup', date: '2023-07-22', time: '15:30', category: 'health', important: false, completed: false }
];
// Render tasks
renderTasks(tasks);
// Modal functionality
const addTaskBtn = document.getElementById('add-task-btn');
const addTaskModal = document.getElementById('add-task-modal');
const closeModal = document.getElementById('close-modal');
const cancelTask = document.getElementById('cancel-task');
addTaskBtn.addEventListener('click', () => {
addTaskModal.classList.remove('hidden');
document.getElementById('task-date').valueAsDate = new Date();
});
closeModal.addEventListener('click', () => {
addTaskModal.classList.add('hidden');
});
cancelTask.addEventListener('click', () => {
addTaskModal.classList.add('hidden');
});
// Category selection
const categoryBtns = document.querySelectorAll('.category-btn');
const taskCategory = document.getElementById('task-category');
categoryBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Remove active class from all buttons
categoryBtns.forEach(b => {
b.classList.remove('bg-indigo-100', 'text-indigo-700');
b.classList.add(b.dataset.category === 'work' ? 'bg-red-100' :
b.dataset.category === 'personal' ? 'bg-blue-100' :
b.dataset.category === 'health' ? 'bg-green-100' : 'bg-yellow-100');
b.classList.add(b.dataset.category === 'work' ? 'text-red-700' :
b.dataset.category === 'personal' ? 'text-blue-700' :
b.dataset.category === 'health' ? 'text-green-700' : 'text-yellow-700');
});
// Add active class to clicked button
btn.classList.remove(btn.dataset.category === 'work' ? 'bg-red-100' :
btn.dataset.category === 'personal' ? 'bg-blue-100' :
btn.dataset.category === 'health' ? 'bg-green-100' : 'bg-yellow-100');
btn.classList.remove(btn.dataset.category === 'work' ? 'text-red-700' :
btn.dataset.category === 'personal' ? 'text-blue-700' :
btn.dataset.category === 'health' ? 'text-green-700' : 'text-yellow-700');
btn.classList.add('bg-indigo-100', 'text-indigo-700');
// Set the category value
taskCategory.value = btn.dataset.category;
});
});
// Form submission
const taskForm = document.getElementById('task-form');
taskForm.addEventListener('submit', function(e) {
e.preventDefault();
const title = document.getElementById('task-title').value;
const description = document.getElementById('task-description').value;
const date = document.getElementById('task-date').value;
const time = document.getElementById('task-time').value;
const category = document.getElementById('task-category').value || 'personal';
const important = document.getElementById('task-important').checked;
// In a real app, you would save this to a database
const newTask = {
id: tasks.length + 1,
title,
description,
date,
time,
category,
important,
completed: false
};
tasks.unshift(newTask);
renderTasks(tasks);
// Reset form and close modal
taskForm.reset();
addTaskModal.classList.add('hidden');
});
// Toggle completed tasks
const toggleCompleted = document.getElementById('toggle-completed');
const completedTasks = document.getElementById('completed-tasks');
toggleCompleted.addEventListener('click', () => {
if (completedTasks.classList.contains('hidden')) {
completedTasks.classList.remove('hidden');
toggleCompleted.querySelector('i').classList.replace('fa-chevron-down', 'fa-chevron-up');
} else {
completedTasks.classList.add('hidden');
toggleCompleted.querySelector('i').classList.replace('fa-chevron-up', 'fa-chevron-down');
}
});
// Theme toggle
const themeToggle = document.getElementById('theme-toggle');
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('bg-gray-900');
document.body.classList.toggle('bg-gray-100');
if (document.body.classList.contains('bg-gray-900')) {
// Dark mode
themeToggle.innerHTML = '<i class="fas fa-sun"></i>';
// Update other elements for dark mode
document.querySelectorAll('.bg-white').forEach(el => {
el.classList.add('bg-gray-800');
el.classList.remove('bg-white');
});
document.querySelectorAll('.text-gray-800').forEach(el => {
el.classList.add('text-gray-100');
el.classList.remove('text-gray-800');
});
document.querySelectorAll('.text-gray-700').forEach(el => {
el.classList.add('text-gray-300');
el.classList.remove('text-gray-700');
});
document.querySelectorAll('.text-gray-600').forEach(el => {
el.classList.add('text-gray-400');
el.classList.remove('text-gray-600');
});
document.querySelectorAll('.bg-gray-100').forEach(el => {
el.classList.add('bg-gray-700');
el.classList.remove('bg-gray-100');
});
document.querySelectorAll('.hover:bg-gray-100').forEach(el => {
el.classList.add('hover:bg-gray-700');
el.classList.remove('hover:bg-gray-100');
});
document.querySelectorAll('.border-gray-300').forEach(el => {
el.classList.add('border-gray-600');
el.classList.remove('border-gray-300');
});
} else {
// Light mode
themeToggle.innerHTML = '<i class="fas fa-moon"></i>';
// Revert to light mode
document.querySelectorAll('.bg-gray-800').forEach(el => {
el.classList.add('bg-white');
el.classList.remove('bg-gray-800');
});
document.querySelectorAll('.text-gray-100').forEach(el => {
el.classList.add('text-gray-800');
el.classList.remove('text-gray-100');
});
document.querySelectorAll('.text-gray-300').forEach(el => {
el.classList.add('text-gray-700');
el.classList.remove('text-gray-300');
});
document.querySelectorAll('.text-gray-400').forEach(el => {
el.classList.add('text-gray-600');
el.classList.remove('text-gray-400');
});
document.querySelectorAll('.bg-gray-700').forEach(el => {
el.classList.add('bg-gray-100');
el.classList.remove('bg-gray-700');
});
document.querySelectorAll('.hover:bg-gray-700').forEach(el => {
el.classList.add('hover:bg-gray-100');
el.classList.remove('hover:bg-gray-700');
});
document.querySelectorAll('.border-gray-600').forEach(el => {
el.classList.add('border-gray-300');
el.classList.remove('border-gray-600');
});
}
});
// User dropdown
const userAvatar = document.querySelector('img[alt="User"]');
const userDropdown = document.getElementById('user-dropdown');
userAvatar.addEventListener('click', () => {
userDropdown.classList.toggle('hidden');
});
// Close dropdown when clicking outside
document.addEventListener('click', (e) => {
if (!userAvatar.contains(e.target) && !userDropdown.contains(e.target)) {
userDropdown.classList.add('hidden');
}
});
});
function generateCalendarDays() {
const calendarDays = document.getElementById('calendar-days');
calendarDays.innerHTML = '';
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
const firstDay = new Date(year, month, 1).getDay();
const daysInMonth = new Date(year, month + 1, 0).getDate();
// Add empty cells for days before the first day of the month
for (let i = 0; i < firstDay; i++) {
const emptyCell = document.createElement('div');
emptyCell.className = 'h-8';
calendarDays.appendChild(emptyCell);
}
// Add cells for each day of the month
for (let day = 1; day <= daysInMonth; day++) {
const dayCell = document.createElement('div');
dayCell.className = 'h-8 flex items-center justify-center text-sm rounded-full cursor-pointer hover:bg-gray-100';
if (day === now.getDate()) {
dayCell.classList.add('bg-indigo-600', 'text-white', 'font-medium');
}
dayCell.textContent = day;
calendarDays.appendChild(dayCell);
}
}
function renderTasks(tasks) {
const taskList = document.getElementById('task-list');
const completedTasks = document.getElementById('completed-tasks');
// Clear existing tasks
taskList.innerHTML = '';
completedTasks.innerHTML = '';
// Count completed tasks for the toggle button
let completedCount = 0;
tasks.forEach(task => {
if (task.completed) {
completedCount++;
renderTask(task, completedTasks, true);
} else {
renderTask(task, taskList, false);
}
});
// Update completed tasks count
document.querySelector('#toggle-completed span').textContent = `Show Completed (${completedCount})`;
}
function renderTask(task, container, isCompleted) {
const taskElement = document.createElement('div');
taskElement.className = `bg-white p-4 rounded-lg border border-gray-200 shadow-sm ${isCompleted ? 'opacity-70' : ''}`;
taskElement.dataset.id = task.id;
// Determine category color
let categoryColor = 'gray';
let categoryText = 'Personal';
if (task.category === 'work') {
categoryColor = 'red';
categoryText = 'Work';
} else if (task.category === 'health') {
categoryColor = 'green';
categoryText = 'Health';
} else if (task.category === 'study') {
categoryColor = 'yellow';
categoryText = 'Study';
}
// Format date and time
const taskDate = task.date ? new Date(task.date) : null;
const formattedDate = taskDate ? taskDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }) : '';
const formattedTime = task.time ? formatTime(task.time) : '';
taskElement.innerHTML = `
<div class="flex justify-between items-start">
<div class="flex items-start space-x-3">
<input type="checkbox" class="custom-checkbox mt-1" ${isCompleted ? 'checked' : ''}>
<div>
<h4 class="font-medium ${isCompleted ? 'line-through text-gray-500' : 'text-gray-800'}">${task.title}</h4>
${task.description ? `<p class="text-sm text-gray-600 mt-1">${task.description}</p>` : ''}
<div class="flex items-center space-x-3 mt-2">
${formattedDate ? `<span class="flex items-center text-xs text-gray-500">
<i class="fas fa-calendar-day mr-1"></i> ${formattedDate}
</span>` : ''}
${formattedTime ? `<span class="flex items-center text-xs text-gray-500">
<i class="fas fa-clock mr-1"></i> ${formattedTime}
</span>` : ''}
<span class="flex items-center text-xs px-2 py-1 bg-${categoryColor}-100 text-${categoryColor}-700 rounded-full">
${categoryText}
</span>
</div>
</div>
</div>
<div class="flex space-x-2">
${task.important ? `<span class="text-yellow-500"><i class="fas fa-star"></i></span>` : ''}
<button class="text-gray-400 hover:text-gray-600 edit-task">
<i class="fas fa-edit"></i>
</button>
<button class="text-gray-400 hover:text-gray-600 delete-task">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
`;
container.appendChild(taskElement);
// Add event listeners to the new task
const checkbox = taskElement.querySelector('input[type="checkbox"]');
const deleteBtn = taskElement.querySelector('.delete-task');
const editBtn = taskElement.querySelector('.edit-task');
checkbox.addEventListener('change', function() {
task.completed = this.checked;
if (task.completed) {
taskElement.classList.add('completed-task');
setTimeout(() => {
container.removeChild(taskElement);
renderTask(task, document.getElementById('completed-tasks'), true);
updateCompletedCount();
}, 500);
}
});
deleteBtn.addEventListener('click', function() {
if (confirm('Are you sure you want to delete this task?')) {
// In a real app, you would remove from database
const index = tasks.findIndex(t => t.id === task.id);
if (index !== -1) {
tasks.splice(index, 1);
container.removeChild(taskElement);
updateCompletedCount();
}
}
});
editBtn.addEventListener('click', function() {
// In a real app, you would implement edit functionality
alert('Edit functionality would be implemented here');
});
}
function formatTime(timeString) {
const [hours, minutes] = timeString.split(':');
const hour = parseInt(hours);
const ampm = hour >= 12 ? 'PM' : 'AM';
const hour12 = hour % 12 || 12;
return `${hour12}:${minutes} ${ampm}`;
}
function updateCompletedCount() {
const completedTasks = document.querySelectorAll('#completed-tasks > div').length;
document.querySelector('#toggle-completed span').textContent = `Show Completed (${completedTasks})`;
}
</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=EJSong/schedulemaster" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |