-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.html
321 lines (280 loc) · 9.35 KB
/
todo.html
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
321
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enhanced To-Do List</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f5f5f5;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#app {
background-color: #fff;
border-radius: 10px;
overflow: hidden;
width: 400px;
max-width: 90%;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
#taskList {
list-style: none;
padding: 0;
margin: 0;
}
.task {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
margin: 10px 0;
border-radius: 8px;
background-color: #e0e0e0;
color: #333;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
animation: fadeIn 0.5s ease-out, slideInLeft 0.5s ease-out;
cursor: pointer;
transition: transform 0.3s ease-out, box-shadow 0.3s ease-out, background-color 0.3s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideInLeft {
from {
transform: translateX(-20px);
}
to {
transform: translateX(0);
}
}
.task:hover {
transform: scale(1.05);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
background-color: #c0c0c0;
}
.completed {
background-color: #7fbf7f;
color: #fff;
text-decoration: line-through;
}
.delete-btn {
cursor: pointer;
color: #ff4d4d;
font-weight: bold;
border: none;
background: none;
outline: none;
}
.add-task-form {
display: flex;
flex-direction: column;
padding: 20px;
animation: slideInUp 0.5s ease-out;
}
@keyframes slideInUp {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
#newTask {
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
#addBtn {
cursor: pointer;
padding: 10px;
border: none;
border-radius: 4px;
background-color: #4CAF50;
color: #fff;
font-weight: bold;
outline: none;
animation: rotate 0.5s ease-out;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#madeBy {
text-align: center;
margin-top: 20px;
color: #777;
font-size: 12px;
animation: fadeIn 0.5s ease-out, slideInDown 0.5s ease-out;
}
@keyframes slideInDown {
from {
transform: translateY(-20px);
}
to {
transform: translateY(0);
}
}
/* New Styles for Additional Features */
.priority {
margin-top: 10px;
padding: 8px;
font-size: 14px;
border: 1px solid #ccc;
border-radius: 4px;
}
.due-date {
margin-top: 10px;
padding: 8px;
font-size: 14px;
border: 1px solid #ccc;
border-radius: 4px;
color: #555;
}
</style>
</head>
<body>
<div id="app">
<ul id="taskList"></ul>
<div class="add-task-form">
<input type="text" id="newTask" placeholder="Add a new task">
<button id="addBtn" onclick="addTask()">Add</button>
<select class="priority">
<option value="" disabled selected hidden>Priority</option>
<option value="high">High</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
<input type="date" class="due-date">
</div>
<div id="madeBy">Made by Neal Aringale</div>
</div>
<script>
function addTask() {
const taskInput = document.getElementById('newTask');
const taskText = taskInput.value.trim();
if (taskText !== '') {
const taskList = document.getElementById('taskList');
const prioritySelect = document.querySelector('.priority');
const dueDateInput = document.querySelector('.due-date');
const taskElement = document.createElement('li');
taskElement.className = 'task animate__animated animate__fadeIn animate__faster';
taskElement.innerHTML = `
<span>${taskText}</span>
<button class="delete-btn" onclick="deleteTask(this)">Delete</button>
<input type="checkbox" onchange="completeTask(this)">
<span class="priority"></span>
<span class="due-date"></span>
`;
taskList.appendChild(taskElement);
// Display priority and due date
const priorityValue = prioritySelect.value;
const dueDateValue = dueDateInput.value;
taskElement.querySelector('.priority').textContent = `Priority: ${priorityValue}`;
taskElement.querySelector('.due-date').textContent = `Due Date: ${dueDateValue}`;
// Style and save tasks
taskElement.style.backgroundColor = getPriorityColor(priorityValue);
saveTasks();
// Clear input fields
taskInput.value = '';
prioritySelect.selectedIndex = 0;
dueDateInput.value = '';
}
}
function deleteTask(deleteButton) {
const taskElement = deleteButton.parentNode;
const taskList = document.getElementById('taskList');
taskElement.classList.remove('animate__fadeIn');
taskElement.classList.add('animate__fadeOut');
setTimeout(() => {
taskList.removeChild(taskElement);
saveTasks();
}, 500);
}
function completeTask(checkbox) {
const taskElement = checkbox.parentNode;
taskElement.classList.toggle('completed');
saveTasks();
}
function getPriorityColor(priority) {
switch (priority) {
case 'high':
return '#ff6666'; // Red for high priority
case 'medium':
return '#ffcc66'; // Yellow for medium priority
case 'low':
return '#66ff66'; // Green for low priority
default:
return '#e0e0e0'; // Default color
}
}
function saveTasks() {
const taskList = document.getElementById('taskList');
const tasks = [];
taskList.querySelectorAll('.task span').forEach(task => {
const taskElement = task.parentNode;
tasks.push({
text: task.textContent,
completed: taskElement.classList.contains('completed'),
priority: taskElement.querySelector('.priority').textContent.split(': ')[1].toLowerCase(),
dueDate: taskElement.querySelector('.due-date').textContent.split(': ')[1]
});
});
localStorage.setItem('tasks', JSON.stringify(tasks));
}
function loadTasks() {
const taskList = document.getElementById('taskList');
const savedTasks = localStorage.getItem('tasks');
if (savedTasks) {
const tasks = JSON.parse(savedTasks);
tasks.forEach(task => {
const taskElement = document.createElement('li');
taskElement.className = 'task';
if (task.completed) {
taskElement.classList.add('completed');
}
taskElement.innerHTML = `
<span>${task.text}</span>
<button class="delete-btn" onclick="deleteTask(this)">Delete</button>
<input type="checkbox" onchange="completeTask(this)" ${task.completed ? 'checked' : ''}>
<span class="priority">Priority: ${task.priority}</span>
<span class="due-date">Due Date: ${task.dueDate}</span>
`;
taskList.appendChild(taskElement);
taskElement.style.backgroundColor = getPriorityColor(task.priority);
});
}
}
loadTasks();
</script>
</body>
</html>