taskmaster-pro / calendar.html
batteryfix's picture
once the task is seen on the pop up if i click off the pop up it has to vanish allowing me to see the calendar once more and this action can be repeated
cc93e8a verified
Raw History Blame Contribute Delete
8.99 kB
<!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>