-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
320 lines (269 loc) · 13.2 KB
/
Copy pathindex.html
File metadata and controls
320 lines (269 loc) · 13.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="google-adsense-account" content="ca-pub-9347592075109566">
<title>Todol | The Best Todolist</title>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<link rel="icon" href="img/icon.webp" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<style>
.gradient-text {
background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.task-item:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.fade-in {
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.completed {
text-decoration: line-through;
color: #9ca3af;
}
.priority-high {
border-left: 4px solid #ef4444;
}
.priority-medium {
border-left: 4px solid #f59e0b;
}
.priority-low {
border-left: 4px solid #10b981;
}
</style>
</head>
<body class="bg-gray-50" data-aos="fade-down-right">
<div class="container py-8 mx-auto px-4">
<div class="max-w-3xl mx-auto">
<h1 class="text-4xl font-bold text-center mb-8 gradient-text">Todol</h1>
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
<div class="bg-white p-4 rounded-lg shadow-md text-center">
<h3 class="text-gray-500">Total Tasks</h3>
<p id="totalTasks" class="text-2xl font-bold text-blue-600">0</p>
</div>
<div class="bg-white p-4 rounded-lg shadow-md text-center">
<h3 class="text-gray-500">Pending</h3>
<p id="pendingTasks" class="text-2xl font-bold text-yellow-600">0</p>
</div>
<div class="bg-white p-4 rounded-lg shadow-md text-center">
<h3 class="text-gray-500">Completed</h3>
<p id="completedTasks" class="text-2xl font-bold text-green-600">0</p>
</div>
</div>
<!-- Add Task Card -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
<div class="p-6">
<div class="flex flex-col md:flex-row gap-4">
<input type="text" id="taskInput" class="flex-grow px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition" placeholder="Add a new task...">
<div class="flex gap-2">
<select id="prioritySelect" class="px-3 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none">
<option value="low">Low Priority</option>
<option value="medium">Medium Priority</option>
<option value="high">High Priority</option>
</select>
<button id="addTaskBtn" class="px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition flex items-center gap-2">
<i class="bi bi-plus-lg"></i> Add Task
</button>
</div>
</div>
<div class="mt-4 flex flex-wrap gap-2">
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-blue-100 text-blue-800 hover:bg-blue-200 transition" data-filter="all">All</button>
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-green-100 text-green-800 hover:bg-green-200 transition" data-filter="completed">Completed</button>
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-yellow-100 text-yellow-800 hover:bg-yellow-200 transition" data-filter="pending">Pending</button>
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-red-100 text-red-800 hover:bg-red-200 transition" data-filter="high">High Priority</button>
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-orange-100 text-orange-800 hover:bg-orange-200 transition" data-filter="medium">Medium Priority</button>
<button class="filter-btn px-3 py-1 rounded-full text-sm bg-emerald-100 text-emerald-800 hover:bg-emerald-200 transition" data-filter="low">Low Priority</button>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="bi bi-list-check"></i> Active Tasks
</h2>
<ul id="taskList" class="space-y-3"></ul>
</div>
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="bi bi-check-circle"></i> Completed Tasks
<span id="completedCount" class="ml-auto text-sm bg-green-100 text-green-800 px-2 py-1 rounded-full">0</span>
</h2>
<ul id="completedTaskList" class="space-y-3"></ul>
</div>
</div>
</div>
</div>
<footer class="bg-blue-600 text-white py-6 mt-12">
<div class="container mx-auto px-4 text-center">
<p class="font-medium">
© <span id="currentYear"></span> Copyrights By
<a href="https://menula-de-silva.glitch.me" class="hover:underline font-semibold">Menula De Silva</a>
</p>
<div class="mt-2 flex justify-center space-x-4">
<a href="#" class="hover:text-blue-200 transition"><i class="bi bi-github"></i></a>
<a href="#" class="hover:text-blue-200 transition"><i class="bi bi-twitter"></i></a>
<a href="#" class="hover:text-blue-200 transition"><i class="bi bi-linkedin"></i></a>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script>
AOS.init();
document.getElementById('currentYear').textContent = new Date().getFullYear();
const taskInput = document.getElementById('taskInput');
const addTaskBtn = document.getElementById('addTaskBtn');
const taskList = document.getElementById('taskList');
const completedTaskList = document.getElementById('completedTaskList');
const prioritySelect = document.getElementById('prioritySelect');
const filterButtons = document.querySelectorAll('.filter-btn');
const totalTasksElement = document.getElementById('totalTasks');
const pendingTasksElement = document.getElementById('pendingTasks');
const completedTasksElement = document.getElementById('completedTasks');
const completedCountElement = document.getElementById('completedCount');
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
function updateStats() {
const totalTasks = tasks.length;
const completedTasks = tasks.filter(task => task.completed).length;
const pendingTasks = totalTasks - completedTasks;
totalTasksElement.textContent = totalTasks;
pendingTasksElement.textContent = pendingTasks;
completedTasksElement.textContent = completedTasks;
completedCountElement.textContent = completedTasks;
localStorage.setItem('tasks', JSON.stringify(tasks));
}
function renderTasks(filter = 'all') {
taskList.innerHTML = '';
completedTaskList.innerHTML = '';
let filteredTasks = [...tasks];
if (filter === 'completed') {
filteredTasks = tasks.filter(task => task.completed);
} else if (filter === 'pending') {
filteredTasks = tasks.filter(task => !task.completed);
} else if (filter === 'high') {
filteredTasks = tasks.filter(task => task.priority === 'high');
} else if (filter === 'medium') {
filteredTasks = tasks.filter(task => task.priority === 'medium');
} else if (filter === 'low') {
filteredTasks = tasks.filter(task => task.priority === 'low');
}
filteredTasks.forEach((task, index) => {
const listItem = document.createElement('li');
listItem.className = `task-item bg-white p-4 rounded-lg shadow-sm border-l-4 ${task.priority ? `priority-${task.priority}` : ''} ${task.completed ? 'opacity-75' : ''} fade-in transition-all duration-200 ease-in-out`;
const taskContent = document.createElement('div');
taskContent.className = 'flex items-center justify-between';
const taskLeft = document.createElement('div');
taskLeft.className = 'flex items-center gap-3';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.checked = task.completed;
checkbox.className = 'form-checkbox h-5 w-5 text-blue-600 rounded focus:ring-blue-500';
checkbox.addEventListener('change', () => toggleTaskCompletion(index));
const taskSpan = document.createElement('span');
taskSpan.textContent = task.text;
taskSpan.className = task.completed ? 'completed text-gray-500' : 'text-gray-800';
if (!task.completed) {
const priorityBadge = document.createElement('span');
priorityBadge.className = `text-xs 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'
}`;
priorityBadge.textContent = task.priority === 'high' ? 'High' :
task.priority === 'medium' ? 'Medium' : 'Low';
taskLeft.appendChild(priorityBadge);
}
taskLeft.prepend(checkbox);
taskLeft.appendChild(taskSpan);
const taskButtons = document.createElement('div');
taskButtons.className = 'flex gap-2';
const editBtn = document.createElement('button');
editBtn.className = 'p-2 text-gray-500 hover:text-blue-600 transition';
editBtn.innerHTML = '<i class="bi bi-pencil"></i>';
editBtn.addEventListener('click', () => editTask(index));
const deleteBtn = document.createElement('button');
deleteBtn.className = 'p-2 text-gray-500 hover:text-red-600 transition';
deleteBtn.innerHTML = '<i class="bi bi-trash"></i>';
deleteBtn.addEventListener('click', () => deleteTask(index));
taskButtons.appendChild(editBtn);
taskButtons.appendChild(deleteBtn);
taskContent.appendChild(taskLeft);
taskContent.appendChild(taskButtons);
listItem.appendChild(taskContent);
if (task.completed) {
completedTaskList.appendChild(listItem);
} else {
taskList.appendChild(listItem);
}
});
updateStats();
}
function addTask() {
const taskText = taskInput.value.trim();
const priority = prioritySelect.value;
if (taskText === '') {
alert('Please enter a task!');
return;
}
tasks.push({
text: taskText,
completed: false,
priority: priority,
createdAt: new Date().toISOString()
});
taskInput.value = '';
renderTasks();
}
function toggleTaskCompletion(index) {
tasks[index].completed = !tasks[index].completed;
renderTasks();
}
function deleteTask(index) {
if (confirm('Are you sure you want to delete this task?')) {
tasks.splice(index, 1);
renderTasks();
}
}
function editTask(index) {
const newText = prompt('Edit task:', tasks[index].text);
if (newText !== null && newText.trim() !== '') {
tasks[index].text = newText.trim();
const newPriority = prompt('Set new priority (high/medium/low):', tasks[index].priority);
if (newPriority && ['high', 'medium', 'low'].includes(newPriority.toLowerCase())) {
tasks[index].priority = newPriority.toLowerCase();
}
renderTasks();
}
}
filterButtons.forEach(button => {
button.addEventListener('click', () => {
const filter = button.dataset.filter;
renderTasks(filter);
// Update active filter button
filterButtons.forEach(btn => btn.classList.remove('bg-blue-600', 'text-white'));
button.classList.add('bg-blue-600', 'text-white');
});
});
addTaskBtn.addEventListener('click', addTask);
taskInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') addTask();
});
renderTasks();
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9347592075109566" crossorigin="anonymous"></script>
</body>
</html>