Add 2 files
Browse files- README.md +7 -5
- index.html +380 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: share
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,380 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Task Manager</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.task-completed {
|
| 11 |
+
text-decoration: line-through;
|
| 12 |
+
color: #9ca3af;
|
| 13 |
+
}
|
| 14 |
+
.priority-high {
|
| 15 |
+
border-left: 4px solid #ef4444;
|
| 16 |
+
}
|
| 17 |
+
.priority-medium {
|
| 18 |
+
border-left: 4px solid #f59e0b;
|
| 19 |
+
}
|
| 20 |
+
.priority-low {
|
| 21 |
+
border-left: 4px solid #10b981;
|
| 22 |
+
}
|
| 23 |
+
.fade-in {
|
| 24 |
+
animation: fadeIn 0.3s ease-in;
|
| 25 |
+
}
|
| 26 |
+
@keyframes fadeIn {
|
| 27 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 28 |
+
to { opacity: 1; transform: translateY(0); }
|
| 29 |
+
}
|
| 30 |
+
</style>
|
| 31 |
+
</head>
|
| 32 |
+
<body class="bg-gray-50 min-h-screen">
|
| 33 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
| 34 |
+
<div class="flex justify-between items-center mb-8">
|
| 35 |
+
<h1 class="text-3xl font-bold text-gray-800">My Tasks</h1>
|
| 36 |
+
<button id="addTaskBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center transition-colors">
|
| 37 |
+
<i class="fas fa-plus mr-2"></i> Add Task
|
| 38 |
+
</button>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<!-- Task Filters -->
|
| 42 |
+
<div class="bg-white rounded-lg shadow p-4 mb-6">
|
| 43 |
+
<div class="flex flex-wrap items-center gap-4">
|
| 44 |
+
<div class="flex-1 min-w-[200px]">
|
| 45 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Search</label>
|
| 46 |
+
<input type="text" id="searchInput" placeholder="Filter tasks..." class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 47 |
+
</div>
|
| 48 |
+
<div>
|
| 49 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
| 50 |
+
<select id="priorityFilter" class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 51 |
+
<option value="all">All Priorities</option>
|
| 52 |
+
<option value="high">High</option>
|
| 53 |
+
<option value="medium">Medium</option>
|
| 54 |
+
<option value="low">Low</option>
|
| 55 |
+
</select>
|
| 56 |
+
</div>
|
| 57 |
+
<div>
|
| 58 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
| 59 |
+
<select id="statusFilter" class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 60 |
+
<option value="all">All Statuses</option>
|
| 61 |
+
<option value="completed">Completed</option>
|
| 62 |
+
<option value="pending">Pending</option>
|
| 63 |
+
</select>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
<!-- Task Table -->
|
| 69 |
+
<div class="bg-white rounded-lg shadow overflow-hidden">
|
| 70 |
+
<div class="overflow-x-auto">
|
| 71 |
+
<table class="min-w-full divide-y divide-gray-200">
|
| 72 |
+
<thead class="bg-gray-50">
|
| 73 |
+
<tr>
|
| 74 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
|
| 75 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Task</th>
|
| 76 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Priority</th>
|
| 77 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Due Date</th>
|
| 78 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
| 79 |
+
</tr>
|
| 80 |
+
</thead>
|
| 81 |
+
<tbody id="taskTableBody" class="bg-white divide-y divide-gray-200">
|
| 82 |
+
<!-- Tasks will be added here dynamically -->
|
| 83 |
+
</tbody>
|
| 84 |
+
</table>
|
| 85 |
+
</div>
|
| 86 |
+
<div id="emptyState" class="py-12 text-center">
|
| 87 |
+
<i class="fas fa-tasks text-4xl text-gray-300 mb-4"></i>
|
| 88 |
+
<h3 class="text-lg font-medium text-gray-500">No tasks found</h3>
|
| 89 |
+
<p class="text-gray-400 mt-1">Add your first task by clicking the button above</p>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<!-- Add/Edit Task Modal -->
|
| 95 |
+
<div id="taskModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 96 |
+
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 97 |
+
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 98 |
+
<h3 id="modalTitle" class="text-lg font-semibold text-gray-800">Add New Task</h3>
|
| 99 |
+
<button id="closeModalBtn" class="text-gray-400 hover:text-gray-500">
|
| 100 |
+
<i class="fas fa-times"></i>
|
| 101 |
+
</button>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="p-6">
|
| 104 |
+
<form id="taskForm">
|
| 105 |
+
<input type="hidden" id="taskId">
|
| 106 |
+
<div class="mb-4">
|
| 107 |
+
<label for="taskTitle" class="block text-sm font-medium text-gray-700 mb-1">Task Title</label>
|
| 108 |
+
<input type="text" id="taskTitle" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 109 |
+
</div>
|
| 110 |
+
<div class="mb-4">
|
| 111 |
+
<label for="taskDescription" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
|
| 112 |
+
<textarea id="taskDescription" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
| 113 |
+
</div>
|
| 114 |
+
<div class="grid grid-cols-2 gap-4 mb-4">
|
| 115 |
+
<div>
|
| 116 |
+
<label for="taskPriority" class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
| 117 |
+
<select id="taskPriority" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 118 |
+
<option value="high">High</option>
|
| 119 |
+
<option value="medium" selected>Medium</option>
|
| 120 |
+
<option value="low">Low</option>
|
| 121 |
+
</select>
|
| 122 |
+
</div>
|
| 123 |
+
<div>
|
| 124 |
+
<label for="taskDueDate" class="block text-sm font-medium text-gray-700 mb-1">Due Date</label>
|
| 125 |
+
<input type="date" id="taskDueDate" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
<div class="flex justify-end space-x-3 mt-6">
|
| 129 |
+
<button type="button" id="cancelTaskBtn" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">Cancel</button>
|
| 130 |
+
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">Save Task</button>
|
| 131 |
+
</div>
|
| 132 |
+
</form>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
<script>
|
| 138 |
+
// Sample tasks data
|
| 139 |
+
let tasks = [
|
| 140 |
+
{ id: 1, title: 'Complete project proposal', description: 'Finish the draft and send for review', priority: 'high', dueDate: '2023-06-15', completed: false },
|
| 141 |
+
{ id: 2, title: 'Buy groceries', description: 'Milk, eggs, bread, fruits', priority: 'medium', dueDate: '2023-06-10', completed: true },
|
| 142 |
+
{ id: 3, title: 'Schedule team meeting', description: 'Discuss quarterly goals', priority: 'low', dueDate: '2023-06-12', completed: false },
|
| 143 |
+
{ id: 4, title: 'Update portfolio website', description: 'Add new projects and testimonials', priority: 'medium', dueDate: '2023-06-20', completed: false }
|
| 144 |
+
];
|
| 145 |
+
|
| 146 |
+
// DOM elements
|
| 147 |
+
const taskTableBody = document.getElementById('taskTableBody');
|
| 148 |
+
const emptyState = document.getElementById('emptyState');
|
| 149 |
+
const searchInput = document.getElementById('searchInput');
|
| 150 |
+
const priorityFilter = document.getElementById('priorityFilter');
|
| 151 |
+
const statusFilter = document.getElementById('statusFilter');
|
| 152 |
+
const addTaskBtn = document.getElementById('addTaskBtn');
|
| 153 |
+
const taskModal = document.getElementById('taskModal');
|
| 154 |
+
const closeModalBtn = document.getElementById('closeModalBtn');
|
| 155 |
+
const cancelTaskBtn = document.getElementById('cancelTaskBtn');
|
| 156 |
+
const taskForm = document.getElementById('taskForm');
|
| 157 |
+
const modalTitle = document.getElementById('modalTitle');
|
| 158 |
+
const taskIdInput = document.getElementById('taskId');
|
| 159 |
+
const taskTitleInput = document.getElementById('taskTitle');
|
| 160 |
+
const taskDescriptionInput = document.getElementById('taskDescription');
|
| 161 |
+
const taskPriorityInput = document.getElementById('taskPriority');
|
| 162 |
+
const taskDueDateInput = document.getElementById('taskDueDate');
|
| 163 |
+
|
| 164 |
+
// Current date for due date input
|
| 165 |
+
const today = new Date().toISOString().split('T')[0];
|
| 166 |
+
taskDueDateInput.min = today;
|
| 167 |
+
|
| 168 |
+
// Render tasks
|
| 169 |
+
function renderTasks() {
|
| 170 |
+
const searchTerm = searchInput.value.toLowerCase();
|
| 171 |
+
const priorityFilterValue = priorityFilter.value;
|
| 172 |
+
const statusFilterValue = statusFilter.value;
|
| 173 |
+
|
| 174 |
+
const filteredTasks = tasks.filter(task => {
|
| 175 |
+
const matchesSearch = task.title.toLowerCase().includes(searchTerm) ||
|
| 176 |
+
task.description.toLowerCase().includes(searchTerm);
|
| 177 |
+
const matchesPriority = priorityFilterValue === 'all' || task.priority === priorityFilterValue;
|
| 178 |
+
const matchesStatus = statusFilterValue === 'all' ||
|
| 179 |
+
(statusFilterValue === 'completed' && task.completed) ||
|
| 180 |
+
(statusFilterValue === 'pending' && !task.completed);
|
| 181 |
+
|
| 182 |
+
return matchesSearch && matchesPriority && matchesStatus;
|
| 183 |
+
});
|
| 184 |
+
|
| 185 |
+
if (filteredTasks.length === 0) {
|
| 186 |
+
taskTableBody.innerHTML = '';
|
| 187 |
+
emptyState.classList.remove('hidden');
|
| 188 |
+
return;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
emptyState.classList.add('hidden');
|
| 192 |
+
taskTableBody.innerHTML = '';
|
| 193 |
+
|
| 194 |
+
filteredTasks.forEach(task => {
|
| 195 |
+
const row = document.createElement('tr');
|
| 196 |
+
row.className = `fade-in ${task.completed ? 'bg-gray-50' : ''} priority-${task.priority}`;
|
| 197 |
+
|
| 198 |
+
// Status cell
|
| 199 |
+
const statusCell = document.createElement('td');
|
| 200 |
+
statusCell.className = 'px-6 py-4 whitespace-nowrap';
|
| 201 |
+
const statusCheckbox = document.createElement('input');
|
| 202 |
+
statusCheckbox.type = 'checkbox';
|
| 203 |
+
statusCheckbox.className = 'h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded cursor-pointer';
|
| 204 |
+
statusCheckbox.checked = task.completed;
|
| 205 |
+
statusCheckbox.addEventListener('change', () => toggleTaskStatus(task.id));
|
| 206 |
+
statusCell.appendChild(statusCheckbox);
|
| 207 |
+
row.appendChild(statusCell);
|
| 208 |
+
|
| 209 |
+
// Task title cell
|
| 210 |
+
const titleCell = document.createElement('td');
|
| 211 |
+
titleCell.className = 'px-6 py-4';
|
| 212 |
+
const titleDiv = document.createElement('div');
|
| 213 |
+
titleDiv.className = 'flex items-center';
|
| 214 |
+
|
| 215 |
+
const titleText = document.createElement('div');
|
| 216 |
+
titleText.className = 'ml-4';
|
| 217 |
+
|
| 218 |
+
const title = document.createElement('div');
|
| 219 |
+
title.className = `text-sm font-medium ${task.completed ? 'task-completed' : 'text-gray-900'}`;
|
| 220 |
+
title.textContent = task.title;
|
| 221 |
+
|
| 222 |
+
const description = document.createElement('div');
|
| 223 |
+
description.className = `text-sm ${task.completed ? 'task-completed' : 'text-gray-500'}`;
|
| 224 |
+
description.textContent = task.description;
|
| 225 |
+
|
| 226 |
+
titleText.appendChild(title);
|
| 227 |
+
titleText.appendChild(description);
|
| 228 |
+
titleDiv.appendChild(titleText);
|
| 229 |
+
titleCell.appendChild(titleDiv);
|
| 230 |
+
row.appendChild(titleCell);
|
| 231 |
+
|
| 232 |
+
// Priority cell
|
| 233 |
+
const priorityCell = document.createElement('td');
|
| 234 |
+
priorityCell.className = 'px-6 py-4 whitespace-nowrap';
|
| 235 |
+
const priorityBadge = document.createElement('span');
|
| 236 |
+
priorityBadge.className = `px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${
|
| 237 |
+
task.priority === 'high' ? 'bg-red-100 text-red-800' :
|
| 238 |
+
task.priority === 'medium' ? 'bg-yellow-100 text-yellow-800' :
|
| 239 |
+
'bg-green-100 text-green-800'
|
| 240 |
+
}`;
|
| 241 |
+
priorityBadge.textContent = task.priority.charAt(0).toUpperCase() + task.priority.slice(1);
|
| 242 |
+
priorityCell.appendChild(priorityBadge);
|
| 243 |
+
row.appendChild(priorityCell);
|
| 244 |
+
|
| 245 |
+
// Due date cell
|
| 246 |
+
const dueDateCell = document.createElement('td');
|
| 247 |
+
dueDateCell.className = 'px-6 py-4 whitespace-nowrap';
|
| 248 |
+
const dueDateDiv = document.createElement('div');
|
| 249 |
+
dueDateDiv.className = `text-sm ${task.completed ? 'task-completed' : 'text-gray-900'}`;
|
| 250 |
+
|
| 251 |
+
const dueDate = new Date(task.dueDate);
|
| 252 |
+
const now = new Date();
|
| 253 |
+
now.setHours(0, 0, 0, 0);
|
| 254 |
+
|
| 255 |
+
if (dueDate < now && !task.completed) {
|
| 256 |
+
dueDateDiv.innerHTML = `<span class="text-red-600">${formatDate(task.dueDate)} (Overdue)</span>`;
|
| 257 |
+
} else {
|
| 258 |
+
dueDateDiv.textContent = formatDate(task.dueDate);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
dueDateCell.appendChild(dueDateDiv);
|
| 262 |
+
row.appendChild(dueDateCell);
|
| 263 |
+
|
| 264 |
+
// Actions cell
|
| 265 |
+
const actionsCell = document.createElement('td');
|
| 266 |
+
actionsCell.className = 'px-6 py-4 whitespace-nowrap text-right text-sm font-medium';
|
| 267 |
+
|
| 268 |
+
const editBtn = document.createElement('button');
|
| 269 |
+
editBtn.className = 'text-blue-600 hover:text-blue-900 mr-4';
|
| 270 |
+
editBtn.innerHTML = '<i class="fas fa-edit"></i>';
|
| 271 |
+
editBtn.addEventListener('click', () => openEditModal(task.id));
|
| 272 |
+
|
| 273 |
+
const deleteBtn = document.createElement('button');
|
| 274 |
+
deleteBtn.className = 'text-red-600 hover:text-red-900';
|
| 275 |
+
deleteBtn.innerHTML = '<i class="fas fa-trash"></i>';
|
| 276 |
+
deleteBtn.addEventListener('click', () => deleteTask(task.id));
|
| 277 |
+
|
| 278 |
+
actionsCell.appendChild(editBtn);
|
| 279 |
+
actionsCell.appendChild(deleteBtn);
|
| 280 |
+
row.appendChild(actionsCell);
|
| 281 |
+
|
| 282 |
+
taskTableBody.appendChild(row);
|
| 283 |
+
});
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
// Format date
|
| 287 |
+
function formatDate(dateString) {
|
| 288 |
+
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
| 289 |
+
return new Date(dateString).toLocaleDateString(undefined, options);
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
// Toggle task status
|
| 293 |
+
function toggleTaskStatus(taskId) {
|
| 294 |
+
const taskIndex = tasks.findIndex(task => task.id === taskId);
|
| 295 |
+
if (taskIndex !== -1) {
|
| 296 |
+
tasks[taskIndex].completed = !tasks[taskIndex].completed;
|
| 297 |
+
renderTasks();
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
// Delete task
|
| 302 |
+
function deleteTask(taskId) {
|
| 303 |
+
if (confirm('Are you sure you want to delete this task?')) {
|
| 304 |
+
tasks = tasks.filter(task => task.id !== taskId);
|
| 305 |
+
renderTasks();
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Open add task modal
|
| 310 |
+
function openAddModal() {
|
| 311 |
+
taskIdInput.value = '';
|
| 312 |
+
taskTitleInput.value = '';
|
| 313 |
+
taskDescriptionInput.value = '';
|
| 314 |
+
taskPriorityInput.value = 'medium';
|
| 315 |
+
taskDueDateInput.value = '';
|
| 316 |
+
modalTitle.textContent = 'Add New Task';
|
| 317 |
+
taskModal.classList.remove('hidden');
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Open edit task modal
|
| 321 |
+
function openEditModal(taskId) {
|
| 322 |
+
const task = tasks.find(task => task.id === taskId);
|
| 323 |
+
if (task) {
|
| 324 |
+
taskIdInput.value = task.id;
|
| 325 |
+
taskTitleInput.value = task.title;
|
| 326 |
+
taskDescriptionInput.value = task.description;
|
| 327 |
+
taskPriorityInput.value = task.priority;
|
| 328 |
+
taskDueDateInput.value = task.dueDate;
|
| 329 |
+
modalTitle.textContent = 'Edit Task';
|
| 330 |
+
taskModal.classList.remove('hidden');
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
// Close modal
|
| 335 |
+
function closeModal() {
|
| 336 |
+
taskModal.classList.add('hidden');
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
// Handle form submission
|
| 340 |
+
function handleFormSubmit(e) {
|
| 341 |
+
e.preventDefault();
|
| 342 |
+
|
| 343 |
+
const taskData = {
|
| 344 |
+
id: taskIdInput.value ? parseInt(taskIdInput.value) : Date.now(),
|
| 345 |
+
title: taskTitleInput.value,
|
| 346 |
+
description: taskDescriptionInput.value,
|
| 347 |
+
priority: taskPriorityInput.value,
|
| 348 |
+
dueDate: taskDueDateInput.value,
|
| 349 |
+
completed: false
|
| 350 |
+
};
|
| 351 |
+
|
| 352 |
+
if (taskIdInput.value) {
|
| 353 |
+
// Update existing task
|
| 354 |
+
const taskIndex = tasks.findIndex(task => task.id === parseInt(taskIdInput.value));
|
| 355 |
+
if (taskIndex !== -1) {
|
| 356 |
+
tasks[taskIndex] = taskData;
|
| 357 |
+
}
|
| 358 |
+
} else {
|
| 359 |
+
// Add new task
|
| 360 |
+
tasks.push(taskData);
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
closeModal();
|
| 364 |
+
renderTasks();
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Event listeners
|
| 368 |
+
addTaskBtn.addEventListener('click', openAddModal);
|
| 369 |
+
closeModalBtn.addEventListener('click', closeModal);
|
| 370 |
+
cancelTaskBtn.addEventListener('click', closeModal);
|
| 371 |
+
taskForm.addEventListener('submit', handleFormSubmit);
|
| 372 |
+
searchInput.addEventListener('input', renderTasks);
|
| 373 |
+
priorityFilter.addEventListener('change', renderTasks);
|
| 374 |
+
statusFilter.addEventListener('change', renderTasks);
|
| 375 |
+
|
| 376 |
+
// Initial render
|
| 377 |
+
renderTasks();
|
| 378 |
+
</script>
|
| 379 |
+
<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=Hamid-x/share" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 380 |
+
</html>
|