Spaces:
Running
Running
File size: 8,986 Bytes
06d6aa3 2207d90 cc93e8a 2207d90 15b59ae 2207d90 15b59ae 2207d90 06d6aa3 15b59ae 06d6aa3 15b59ae 06d6aa3 15b59ae 2207d90 15b59ae 2207d90 15b59ae 2207d90 15b59ae 06d6aa3 2207d90 06d6aa3 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calendar | TaskMaster Pro</title>
<link rel="stylesheet" href="style.css">
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.css" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
<custom-navbar></custom-navbar>
<main class="flex-1 container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<h1 class="text-3xl font-bold text-gray-800 mb-8">Task Calendar</h1>
<div id="calendar" class="bg-white rounded-xl shadow-sm border border-gray-100 p-4"></div>
</div>
</main>
<!-- Enhanced Task Info Modal -->
<div class="modal fade fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden" id="taskInfoModal" onclick="if(event.target === this) this.classList.add('hidden')">
<div class="bg-white rounded-xl shadow-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto" onclick="event.stopPropagation()">
<div class="flex justify-between items-center sticky top-0 bg-white p-4 border-b border-gray-200 z-10">
<h3 class="text-xl font-semibold text-gray-800">Task Details</h3>
<button onclick="document.getElementById('taskInfoModal').classList.add('hidden')"
class="text-gray-500 hover:text-gray-700 p-1 rounded-full hover:bg-gray-100">
<i data-feather="x"></i>
</button>
</div>
<div class="p-6" id="taskInfoContent"></div>
</div>
</div>
<custom-footer></custom-footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const calendarEl = document.getElementById('calendar');
const calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
events: JSON.parse(localStorage.getItem('tasks'))?.map(task => ({
title: task.title,
start: task.dueDate || task.createdAt,
extendedProps: {
description: task.description,
priority: task.priority,
comments: task.comments || []
},
backgroundColor:
task.priority === 'high' ? '#ef4444' :
task.priority === 'medium' ? '#f59e0b' :
'#10b981',
borderColor: 'transparent'
})) || [],
dateClick: function(info) {
const clickedDate = info.date;
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
const tasksOnDate = tasks.filter(task => {
const taskDate = task.dueDate ? new Date(task.dueDate) : new Date(task.createdAt);
return taskDate.toDateString() === clickedDate.toDateString();
});
if (tasksOnDate.length > 0) {
let content = `<div class="p-4 max-w-xs">`;
tasksOnDate.forEach(task => {
const daysDiff = Math.floor((new Date(task.dueDate) - clickedDate) / (1000 * 60 * 60 * 24));
let highlightColor = '';
if (daysDiff <= 5) highlightColor = 'bg-red-100';
else if (daysDiff <= 10) highlightColor = 'bg-orange-100';
else if (daysDiff <= 15) highlightColor = 'bg-green-100';
content += `
<div class="mb-6 p-4 rounded-lg border border-gray-200 ${highlightColor}">
<div class="flex justify-between items-start">
<div>
<h3 class="text-lg font-bold text-gray-800 mb-1">${task.title}</h3>
<div class="flex items-center gap-2 mb-2 text-sm text-gray-500">
<span class="px-2 py-1 rounded-full ${task.priority === 'high' ? 'bg-red-100 text-red-800' :
task.priority === 'medium' ? 'bg-yellow-100 text-yellow-800' : 'bg-green-100 text-green-800'}">
${task.priority} priority
</span>
<span class="px-2 py-1 rounded-full ${task.status === 'completed' ? 'bg-green-100 text-green-800' :
task.status === 'in-progress' ? 'bg-blue-100 text-blue-800' : 'bg-yellow-100 text-yellow-800'}">
${task.status}
</span>
</div>
</div>
<div class="text-sm text-gray-500">
Due: ${task.dueDate ? new Date(task.dueDate).toLocaleDateString() : 'No due date'}
</div>
</div>
<div class="prose max-w-none mt-3 text-gray-700">
<p>${task.description || 'No description provided.'}</p>
</div>
${task.comments?.length ? `
<div class="mt-4 border-t border-gray-200 pt-4">
<h4 class="text-sm font-medium text-gray-700 mb-3">Comments (${task.comments.length})</h4>
<div class="space-y-3">
${task.comments.map(c => `
<div class="flex gap-3">
<div class="flex-shrink-0">
<div class="h-8 w-8 rounded-full bg-gray-200 flex items-center justify-center">
<i data-feather="user" class="w-4 h-4 text-gray-500"></i>
</div>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm text-gray-700">${c}</p>
<p class="text-xs text-gray-500 mt-1">${new Date(task.createdAt).toLocaleString()}</p>
</div>
</div>
`).join('')}
</div>
</div>` : ''}
</div>
`;
});
content += `</div>`;
document.getElementById('taskInfoModal').classList.remove('hidden');
document.getElementById('taskInfoContent').innerHTML = content;
}
},
dayCellClassNames: function(arg) {
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
const today = new Date(arg.date);
let classes = [];
tasks.forEach(task => {
if (!task.dueDate) return;
const taskDate = new Date(task.dueDate);
const daysDiff = Math.floor((taskDate - today) / (1000 * 60 * 60 * 24));
if (daysDiff >= 0 && daysDiff <= 15) {
if (daysDiff <= 5) classes.push('bg-red-50');
else if (daysDiff <= 10) classes.push('bg-orange-50');
else if (daysDiff <= 15) classes.push('bg-green-50');
}
});
return classes;
}
});
calendar.render();
});
</script>
<script>
feather.replace();
</script>
</body>
</html> |