Spaces:
Running
Running
continue building the page
Browse files- README.md +9 -5
- index.html +443 -19
README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: undefined
|
| 3 |
+
colorFrom: blue
|
| 4 |
+
colorTo: green
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
| 14 |
+
|
index.html
CHANGED
|
@@ -1,19 +1,443 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Tasky McTaskface - Your Magical Task Manager</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script>
|
| 11 |
+
tailwind.config = {
|
| 12 |
+
theme: {
|
| 13 |
+
extend: {
|
| 14 |
+
colors: {
|
| 15 |
+
primary: '#7C3AED',
|
| 16 |
+
secondary: '#10B981'
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
</script>
|
| 22 |
+
<style>
|
| 23 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
| 24 |
+
body {
|
| 25 |
+
font-family: 'Poppins', sans-serif;
|
| 26 |
+
}
|
| 27 |
+
.task-card {
|
| 28 |
+
transition: all 0.3s ease;
|
| 29 |
+
}
|
| 30 |
+
.task-card:hover {
|
| 31 |
+
transform: translateY(-2px);
|
| 32 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 33 |
+
}
|
| 34 |
+
.custom-scrollbar::-webkit-scrollbar {
|
| 35 |
+
width: 6px;
|
| 36 |
+
}
|
| 37 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
| 38 |
+
background: #f1f1f1;
|
| 39 |
+
border-radius: 10px;
|
| 40 |
+
}
|
| 41 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
| 42 |
+
background: #c4b5fd;
|
| 43 |
+
border-radius: 10px;
|
| 44 |
+
}
|
| 45 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
| 46 |
+
background: #8b5cf6;
|
| 47 |
+
}
|
| 48 |
+
</style>
|
| 49 |
+
</head>
|
| 50 |
+
<body class="bg-gray-50 min-h-screen">
|
| 51 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
| 52 |
+
<!-- Header -->
|
| 53 |
+
<header class="flex flex-col md:flex-row justify-between items-center mb-10">
|
| 54 |
+
<div>
|
| 55 |
+
<h1 class="text-3xl md:text-4xl font-bold text-primary">Tasky McTaskface</h1>
|
| 56 |
+
<p class="text-gray-600 mt-1">Your magical task manager ✨</p>
|
| 57 |
+
</div>
|
| 58 |
+
<div class="mt-4 md:mt-0 flex items-center space-x-4">
|
| 59 |
+
<button id="historyBtn" class="flex items-center text-gray-600 hover:text-primary transition-colors">
|
| 60 |
+
<i data-feather="clock"></i>
|
| 61 |
+
<span class="ml-2">History</span>
|
| 62 |
+
</button>
|
| 63 |
+
<button id="themeToggle" class="p-2 rounded-full bg-gray-200 text-gray-700 hover:bg-gray-300 transition-colors">
|
| 64 |
+
<i data-feather="moon"></i>
|
| 65 |
+
</button>
|
| 66 |
+
</div>
|
| 67 |
+
</header>
|
| 68 |
+
|
| 69 |
+
<!-- Main Content -->
|
| 70 |
+
<main class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 71 |
+
<!-- Add Task Section -->
|
| 72 |
+
<div class="lg:col-span-1 bg-white p-6 rounded-xl shadow-sm">
|
| 73 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">Add New Task</h2>
|
| 74 |
+
<form id="taskForm" class="space-y-4">
|
| 75 |
+
<div>
|
| 76 |
+
<label for="taskTitle" class="block text-sm font-medium text-gray-700 mb-1">Task Title</label>
|
| 77 |
+
<input type="text" id="taskTitle" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="What needs to be done?" required>
|
| 78 |
+
</div>
|
| 79 |
+
<div>
|
| 80 |
+
<label for="taskPriority" class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
| 81 |
+
<select id="taskPriority" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
|
| 82 |
+
<option value="low">Low</option>
|
| 83 |
+
<option value="medium" selected>Medium</option>
|
| 84 |
+
<option value="high">High</option>
|
| 85 |
+
</select>
|
| 86 |
+
</div>
|
| 87 |
+
<div>
|
| 88 |
+
<label for="taskDueDate" class="block text-sm font-medium text-gray-700 mb-1">Due Date</label>
|
| 89 |
+
<input type="date" id="taskDueDate" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
|
| 90 |
+
</div>
|
| 91 |
+
<div>
|
| 92 |
+
<label for="taskDescription" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
|
| 93 |
+
<textarea id="taskDescription" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="Any additional details..."></textarea>
|
| 94 |
+
</div>
|
| 95 |
+
<button type="submit" class="w-full bg-primary hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors flex items-center justify-center">
|
| 96 |
+
<i data-feather="plus" class="mr-2"></i>
|
| 97 |
+
Add Task
|
| 98 |
+
</button>
|
| 99 |
+
</form>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<!-- Task List Section -->
|
| 103 |
+
<div class="lg:col-span-2 space-y-6">
|
| 104 |
+
<div class="flex justify-between items-center">
|
| 105 |
+
<h2 class="text-xl font-semibold text-gray-800">Your Tasks</h2>
|
| 106 |
+
<div class="flex space-x-2">
|
| 107 |
+
<button id="filterAll" class="px-3 py-1 text-xs bg-primary text-white rounded-full">All</button>
|
| 108 |
+
<button id="filterActive" class="px-3 py-1 text-xs bg-gray-200 text-gray-700 rounded-full hover:bg-gray-300">Active</button>
|
| 109 |
+
<button id="filterCompleted" class="px-3 py-1 text-xs bg-gray-200 text-gray-700 rounded-full hover:bg-gray-300">Completed</button>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div id="taskList" class="space-y-4 max-h-[600px] overflow-y-auto custom-scrollbar">
|
| 114 |
+
<!-- Task items will be dynamically inserted here -->
|
| 115 |
+
<div class="task-card bg-white p-4 rounded-lg shadow-sm border-l-4 border-primary">
|
| 116 |
+
<div class="flex justify-between items-start">
|
| 117 |
+
<div class="flex items-start space-x-3">
|
| 118 |
+
<button class="task-checkbox mt-1">
|
| 119 |
+
<i data-feather="circle" class="text-gray-300 hover:text-primary"></i>
|
| 120 |
+
</button>
|
| 121 |
+
<div>
|
| 122 |
+
<h3 class="font-medium text-gray-800">Example Task</h3>
|
| 123 |
+
<p class="text-sm text-gray-500 mt-1">This is an example task description that shows how tasks will appear.</p>
|
| 124 |
+
<div class="flex items-center mt-2 space-x-4">
|
| 125 |
+
<span class="text-xs px-2 py-1 bg-purple-100 text-primary rounded-full">Medium</span>
|
| 126 |
+
<span class="text-xs text-gray-500"><i data-feather="calendar" class="inline w-3 h-3 mr-1"></i> Tomorrow</span>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
<button class="task-delete text-gray-400 hover:text-red-500">
|
| 131 |
+
<i data-feather="trash-2"></i>
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
</main>
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<!-- History Modal -->
|
| 141 |
+
<div id="historyModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50 hidden">
|
| 142 |
+
<div class="bg-white rounded-xl w-full max-w-2xl max-h-[80vh] overflow-hidden flex flex-col">
|
| 143 |
+
<div class="p-6 border-b border-gray-200">
|
| 144 |
+
<div class="flex justify-between items-center">
|
| 145 |
+
<h2 class="text-xl font-semibold text-gray-800">Task History</h2>
|
| 146 |
+
<button id="closeHistoryModal" class="text-gray-500 hover:text-gray-700">
|
| 147 |
+
<i data-feather="x"></i>
|
| 148 |
+
</button>
|
| 149 |
+
</div>
|
| 150 |
+
</div>
|
| 151 |
+
<div id="historyList" class="overflow-y-auto p-6 space-y-4">
|
| 152 |
+
<!-- History items will be dynamically inserted here -->
|
| 153 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
| 154 |
+
<div class="flex justify-between">
|
| 155 |
+
<span class="font-medium text-gray-700 line-through">Example Completed Task</span>
|
| 156 |
+
<span class="text-sm text-gray-500">Completed: Today</span>
|
| 157 |
+
</div>
|
| 158 |
+
<div class="flex items-center mt-2">
|
| 159 |
+
<span class="text-xs px-2 py-1 bg-green-100 text-secondary rounded-full mr-2">Medium</span>
|
| 160 |
+
<span class="text-xs text-gray-500">Completed in 2 days</span>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
<div class="p-4 border-t border-gray-200 flex justify-end">
|
| 165 |
+
<button id="clearHistory" class="text-sm text-red-500 hover:text-red-700 flex items-center">
|
| 166 |
+
<i data-feather="trash-2" class="w-4 h-4 mr-1"></i>
|
| 167 |
+
Clear History
|
| 168 |
+
</button>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<script>
|
| 174 |
+
// Initialize Feather Icons
|
| 175 |
+
feather.replace();
|
| 176 |
+
|
| 177 |
+
// DOM Elements
|
| 178 |
+
const taskForm = document.getElementById('taskForm');
|
| 179 |
+
const taskTitle = document.getElementById('taskTitle');
|
| 180 |
+
const taskPriority = document.getElementById('taskPriority');
|
| 181 |
+
const taskDueDate = document.getElementById('taskDueDate');
|
| 182 |
+
const taskDescription = document.getElementById('taskDescription');
|
| 183 |
+
const taskList = document.getElementById('taskList');
|
| 184 |
+
const historyBtn = document.getElementById('historyBtn');
|
| 185 |
+
const historyModal = document.getElementById('historyModal');
|
| 186 |
+
const closeHistoryModal = document.getElementById('closeHistoryModal');
|
| 187 |
+
const historyList = document.getElementById('historyList');
|
| 188 |
+
const clearHistory = document.getElementById('clearHistory');
|
| 189 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 190 |
+
const filterAll = document.getElementById('filterAll');
|
| 191 |
+
const filterActive = document.getElementById('filterActive');
|
| 192 |
+
const filterCompleted = document.getElementById('filterCompleted');
|
| 193 |
+
|
| 194 |
+
// Sample tasks data
|
| 195 |
+
let tasks = [
|
| 196 |
+
{
|
| 197 |
+
id: 1,
|
| 198 |
+
title: 'Complete project proposal',
|
| 199 |
+
description: 'Finish the draft and send for review',
|
| 200 |
+
priority: 'high',
|
| 201 |
+
dueDate: '2023-05-20',
|
| 202 |
+
completed: false,
|
| 203 |
+
createdAt: new Date().toISOString()
|
| 204 |
+
},
|
| 205 |
+
{
|
| 206 |
+
id: 2,
|
| 207 |
+
title: 'Buy groceries',
|
| 208 |
+
description: 'Milk, eggs, bread, fruits',
|
| 209 |
+
priority: 'medium',
|
| 210 |
+
dueDate: '2023-05-18',
|
| 211 |
+
completed: false,
|
| 212 |
+
createdAt: new Date().toISOString()
|
| 213 |
+
}
|
| 214 |
+
];
|
| 215 |
+
|
| 216 |
+
let completedTasks = [
|
| 217 |
+
{
|
| 218 |
+
id: 3,
|
| 219 |
+
title: 'Call mom',
|
| 220 |
+
description: 'Wish her happy birthday',
|
| 221 |
+
priority: 'high',
|
| 222 |
+
dueDate: '2023-05-15',
|
| 223 |
+
completed: true,
|
| 224 |
+
completedAt: new Date().toISOString(),
|
| 225 |
+
createdAt: new Date('2023-05-10').toISOString()
|
| 226 |
+
}
|
| 227 |
+
];
|
| 228 |
+
|
| 229 |
+
// Theme management
|
| 230 |
+
function toggleTheme() {
|
| 231 |
+
document.documentElement.classList.toggle('dark');
|
| 232 |
+
const isDark = document.documentElement.classList.contains('dark');
|
| 233 |
+
localStorage.setItem('darkMode', isDark);
|
| 234 |
+
feather.replace();
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// Initialize theme
|
| 238 |
+
if (localStorage.getItem('darkMode') === 'true') {
|
| 239 |
+
document.documentElement.classList.add('dark');
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
themeToggle.addEventListener('click', toggleTheme);
|
| 243 |
+
|
| 244 |
+
// Task rendering functions
|
| 245 |
+
function renderTasks(filter = 'all') {
|
| 246 |
+
taskList.innerHTML = '';
|
| 247 |
+
const filteredTasks = tasks.filter(task => {
|
| 248 |
+
if (filter === 'active') return !task.completed;
|
| 249 |
+
if (filter === 'completed') return task.completed;
|
| 250 |
+
return true;
|
| 251 |
+
});
|
| 252 |
+
|
| 253 |
+
if (filteredTasks.length === 0) {
|
| 254 |
+
taskList.innerHTML = `
|
| 255 |
+
<div class="text-center py-8 text-gray-500">
|
| 256 |
+
<i data-feather="inbox" class="w-12 h-12 mx-auto text-gray-300"></i>
|
| 257 |
+
<p class="mt-2">No tasks found</p>
|
| 258 |
+
</div>
|
| 259 |
+
`;
|
| 260 |
+
feather.replace();
|
| 261 |
+
return;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
filteredTasks.forEach(task => {
|
| 265 |
+
const taskElement = document.createElement('div');
|
| 266 |
+
taskElement.className = `task-card bg-white p-4 rounded-lg shadow-sm border-l-4 ${task.priority === 'high' ? 'border-red-500' : task.priority === 'medium' ? 'border-primary' : 'border-blue-500'}`;
|
| 267 |
+
|
| 268 |
+
const priorityColors = {
|
| 269 |
+
high: 'bg-red-100 text-red-800',
|
| 270 |
+
medium: 'bg-purple-100 text-primary',
|
| 271 |
+
low: 'bg-blue-100 text-blue-800'
|
| 272 |
+
};
|
| 273 |
+
|
| 274 |
+
taskElement.innerHTML = `
|
| 275 |
+
<div class="flex justify-between items-start">
|
| 276 |
+
<div class="flex items-start space-x-3">
|
| 277 |
+
<button class="task-checkbox mt-1" data-id="${task.id}">
|
| 278 |
+
<i data-feather="${task.completed ? 'check-circle' : 'circle'}" class="${task.completed ? 'text-secondary' : 'text-gray-300 hover:text-primary'}"></i>
|
| 279 |
+
</button>
|
| 280 |
+
<div>
|
| 281 |
+
<h3 class="font-medium text-gray-800 ${task.completed ? 'line-through text-gray-500' : ''}">${task.title}</h3>
|
| 282 |
+
<p class="text-sm text-gray-500 mt-1 ${task.completed ? 'line-through' : ''}">${task.description}</p>
|
| 283 |
+
<div class="flex items-center mt-2 space-x-4">
|
| 284 |
+
<span class="text-xs px-2 py-1 ${priorityColors[task.priority]} rounded-full">${task.priority.charAt(0).toUpperCase() + task.priority.slice(1)}</span>
|
| 285 |
+
${task.dueDate ? `<span class="text-xs text-gray-500"><i data-feather="calendar" class="inline w-3 h-3 mr-1"></i> ${formatDate(task.dueDate)}</span>` : ''}
|
| 286 |
+
</div>
|
| 287 |
+
</div>
|
| 288 |
+
</div>
|
| 289 |
+
<button class="task-delete text-gray-400 hover:text-red-500" data-id="${task.id}">
|
| 290 |
+
<i data-feather="trash-2"></i>
|
| 291 |
+
</button>
|
| 292 |
+
</div>
|
| 293 |
+
`;
|
| 294 |
+
taskList.appendChild(taskElement);
|
| 295 |
+
});
|
| 296 |
+
feather.replace();
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
function formatDate(dateString) {
|
| 300 |
+
const date = new Date(dateString);
|
| 301 |
+
const today = new Date();
|
| 302 |
+
const tomorrow = new Date(today);
|
| 303 |
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
| 304 |
+
|
| 305 |
+
if (date.toDateString() === today.toDateString()) {
|
| 306 |
+
return 'Today';
|
| 307 |
+
} else if (date.toDateString() === tomorrow.toDateString()) {
|
| 308 |
+
return 'Tomorrow';
|
| 309 |
+
} else {
|
| 310 |
+
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// Handle form submission
|
| 315 |
+
taskForm.addEventListener('submit', function(e) {
|
| 316 |
+
e.preventDefault();
|
| 317 |
+
|
| 318 |
+
const newTask = {
|
| 319 |
+
id: Date.now(),
|
| 320 |
+
title: taskTitle.value,
|
| 321 |
+
description: taskDescription.value,
|
| 322 |
+
priority: taskPriority.value,
|
| 323 |
+
dueDate: taskDueDate.value,
|
| 324 |
+
completed: false,
|
| 325 |
+
createdAt: new Date().toISOString()
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
tasks.unshift(newTask);
|
| 329 |
+
renderTasks();
|
| 330 |
+
taskForm.reset();
|
| 331 |
+
});
|
| 332 |
+
|
| 333 |
+
// Event delegation for task actions
|
| 334 |
+
taskList.addEventListener('click', function(e) {
|
| 335 |
+
const target = e.target.closest('.task-checkbox') || e.target.closest('.task-delete');
|
| 336 |
+
if (!target) return;
|
| 337 |
+
|
| 338 |
+
const taskId = parseInt(target.dataset.id);
|
| 339 |
+
const taskIndex = tasks.findIndex(task => task.id === taskId);
|
| 340 |
+
|
| 341 |
+
if (target.classList.contains('task-checkbox')) {
|
| 342 |
+
tasks[taskIndex].completed = !tasks[taskIndex].completed;
|
| 343 |
+
if (tasks[taskIndex].completed) {
|
| 344 |
+
tasks[taskIndex].completedAt = new Date().toISOString();
|
| 345 |
+
}
|
| 346 |
+
renderTasks();
|
| 347 |
+
} else if (target.classList.contains('task-delete')) {
|
| 348 |
+
tasks.splice(taskIndex, 1);
|
| 349 |
+
renderTasks();
|
| 350 |
+
}
|
| 351 |
+
});
|
| 352 |
+
|
| 353 |
+
// Filter buttons
|
| 354 |
+
filterAll.addEventListener('click', () => {
|
| 355 |
+
filterAll.classList.add('bg-primary', 'text-white');
|
| 356 |
+
filterAll.classList.remove('bg-gray-200', 'text-gray-700');
|
| 357 |
+
filterActive.classList.add('bg-gray-200', 'text-gray-700');
|
| 358 |
+
filterActive.classList.remove('bg-primary', 'text-white');
|
| 359 |
+
filterCompleted.classList.add('bg-gray-200', 'text-gray-700');
|
| 360 |
+
filterCompleted.classList.remove('bg-primary', 'text-white');
|
| 361 |
+
renderTasks('all');
|
| 362 |
+
});
|
| 363 |
+
|
| 364 |
+
filterActive.addEventListener('click', () => {
|
| 365 |
+
filterActive.classList.add('bg-primary', 'text-white');
|
| 366 |
+
filterActive.classList.remove('bg-gray-200', 'text-gray-700');
|
| 367 |
+
filterAll.classList.add('bg-gray-200', 'text-gray-700');
|
| 368 |
+
filterAll.classList.remove('bg-primary', 'text-white');
|
| 369 |
+
filterCompleted.classList.add('bg-gray-200', 'text-gray-700');
|
| 370 |
+
filterCompleted.classList.remove('bg-primary', 'text-white');
|
| 371 |
+
renderTasks('active');
|
| 372 |
+
});
|
| 373 |
+
|
| 374 |
+
filterCompleted.addEventListener('click', () => {
|
| 375 |
+
filterCompleted.classList.add('bg-primary', 'text-white');
|
| 376 |
+
filterCompleted.classList.remove('bg-gray-200', 'text-gray-700');
|
| 377 |
+
filterAll.classList.add('bg-gray-200', 'text-gray-700');
|
| 378 |
+
filterAll.classList.remove('bg-primary', 'text-white');
|
| 379 |
+
filterActive.classList.add('bg-gray-200', 'text-gray-700');
|
| 380 |
+
filterActive.classList.remove('bg-primary', 'text-white');
|
| 381 |
+
renderTasks('completed');
|
| 382 |
+
});
|
| 383 |
+
|
| 384 |
+
// History modal
|
| 385 |
+
historyBtn.addEventListener('click', () => {
|
| 386 |
+
renderHistory();
|
| 387 |
+
historyModal.classList.remove('hidden');
|
| 388 |
+
});
|
| 389 |
+
|
| 390 |
+
closeHistoryModal.addEventListener('click', () => {
|
| 391 |
+
historyModal.classList.add('hidden');
|
| 392 |
+
});
|
| 393 |
+
|
| 394 |
+
function renderHistory() {
|
| 395 |
+
historyList.innerHTML = '';
|
| 396 |
+
|
| 397 |
+
if (completedTasks.length === 0) {
|
| 398 |
+
historyList.innerHTML = `
|
| 399 |
+
<div class="text-center py-8 text-gray-500">
|
| 400 |
+
<i data-feather="clock" class="w-12 h-12 mx-auto text-gray-300"></i>
|
| 401 |
+
<p class="mt-2">No completed tasks yet</p>
|
| 402 |
+
</div>
|
| 403 |
+
`;
|
| 404 |
+
feather.replace();
|
| 405 |
+
return;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
completedTasks.forEach(task => {
|
| 409 |
+
const historyElement = document.createElement('div');
|
| 410 |
+
historyElement.className = 'bg-gray-50 p-4 rounded-lg';
|
| 411 |
+
|
| 412 |
+
const completedDate = new Date(task.completedAt);
|
| 413 |
+
const createdAt = new Date(task.createdAt);
|
| 414 |
+
const daysToComplete = Math.floor((completedDate - createdAt) / (1000 * 60 * 60 * 24));
|
| 415 |
+
|
| 416 |
+
historyElement.innerHTML = `
|
| 417 |
+
<div class="flex justify-between">
|
| 418 |
+
<span class="font-medium text-gray-700 line-through">${task.title}</span>
|
| 419 |
+
<span class="text-sm text-gray-500">Completed: ${formatDate(task.completedAt)}</span>
|
| 420 |
+
</div>
|
| 421 |
+
<div class="flex items-center mt-2">
|
| 422 |
+
<span class="text-xs px-2 py-1 ${task.priority === 'high' ? 'bg-red-100 text-red-800' : task.priority === 'medium' ? 'bg-purple-100 text-primary' : 'bg-blue-100 text-blue-800'} rounded-full mr-2">
|
| 423 |
+
${task.priority.charAt(0).toUpperCase() + task.priority.slice(1)}
|
| 424 |
+
</span>
|
| 425 |
+
<span class="text-xs text-gray-500">Completed in ${daysToComplete} day${daysToComplete !== 1 ? 's' : ''}</span>
|
| 426 |
+
</div>
|
| 427 |
+
${task.description ? `<p class="text-sm text-gray-500 mt-2 line-through">${task.description}</p>` : ''}
|
| 428 |
+
`;
|
| 429 |
+
historyList.appendChild(historyElement);
|
| 430 |
+
});
|
| 431 |
+
feather.replace();
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
clearHistory.addEventListener('click', () => {
|
| 435 |
+
completedTasks = [];
|
| 436 |
+
renderHistory();
|
| 437 |
+
});
|
| 438 |
+
|
| 439 |
+
// Initialize
|
| 440 |
+
renderTasks();
|
| 441 |
+
</script>
|
| 442 |
+
</body>
|
| 443 |
+
</html>
|