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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>Todo App</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 17 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
display: flex;
|
| 20 |
+
flex-direction: column;
|
| 21 |
+
align-items: center;
|
| 22 |
+
justify-content: center;
|
| 23 |
+
padding: 20px;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.header {
|
| 27 |
+
width: 100%;
|
| 28 |
+
max-width: 600px;
|
| 29 |
+
margin-bottom: 20px;
|
| 30 |
+
display: flex;
|
| 31 |
+
justify-content: space-between;
|
| 32 |
+
align-items: center;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.title {
|
| 36 |
+
font-size: 2rem;
|
| 37 |
+
font-weight: 700;
|
| 38 |
+
color: white;
|
| 39 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.built-with {
|
| 43 |
+
font-size: 0.8rem;
|
| 44 |
+
color: rgba(255,255,255,0.8);
|
| 45 |
+
text-decoration: none;
|
| 46 |
+
transition: opacity 0.3s ease;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.built-with:hover {
|
| 50 |
+
opacity: 0.7;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.todo-container {
|
| 54 |
+
width: 100%;
|
| 55 |
+
max-width: 600px;
|
| 56 |
+
background: white;
|
| 57 |
+
border-radius: 16px;
|
| 58 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
| 59 |
+
overflow: hidden;
|
| 60 |
+
display: flex;
|
| 61 |
+
flex-direction: column;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.input-section {
|
| 65 |
+
padding: 20px;
|
| 66 |
+
border-bottom: 1px solid #f0f0f0;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.input-group {
|
| 70 |
+
display: flex;
|
| 71 |
+
gap: 10px;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.todo-input {
|
| 75 |
+
flex: 1;
|
| 76 |
+
padding: 12px 16px;
|
| 77 |
+
border: 2px solid #e0e0e0;
|
| 78 |
+
border-radius: 8px;
|
| 79 |
+
font-size: 1rem;
|
| 80 |
+
transition: all 0.3s ease;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.todo-input:focus {
|
| 84 |
+
outline: none;
|
| 85 |
+
border-color: #667eea;
|
| 86 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.add-btn {
|
| 90 |
+
padding: 12px 20px;
|
| 91 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 92 |
+
color: white;
|
| 93 |
+
border: none;
|
| 94 |
+
border-radius: 8px;
|
| 95 |
+
cursor: pointer;
|
| 96 |
+
font-weight: 600;
|
| 97 |
+
transition: all 0.3s ease;
|
| 98 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.add-btn:hover {
|
| 102 |
+
transform: translateY(-2px);
|
| 103 |
+
box-shadow: 0 6px 8px rgba(0,0,0,0.15);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.add-btn:active {
|
| 107 |
+
transform: translateY(0);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.todo-list {
|
| 111 |
+
flex: 1;
|
| 112 |
+
overflow-y: auto;
|
| 113 |
+
max-height: 400px;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.todo-item {
|
| 117 |
+
display: flex;
|
| 118 |
+
align-items: center;
|
| 119 |
+
padding: 16px 20px;
|
| 120 |
+
border-bottom: 1px solid #f0f0f0;
|
| 121 |
+
transition: all 0.3s ease;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.todo-item:hover {
|
| 125 |
+
background-color: #f8f9ff;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.todo-checkbox {
|
| 129 |
+
width: 20px;
|
| 130 |
+
height: 20px;
|
| 131 |
+
border-radius: 4px;
|
| 132 |
+
border: 2px solid #e0e0e0;
|
| 133 |
+
cursor: pointer;
|
| 134 |
+
transition: all 0.3s ease;
|
| 135 |
+
margin-right: 12px;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.todo-checkbox:checked {
|
| 139 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 140 |
+
border-color: transparent;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.todo-text {
|
| 144 |
+
flex: 1;
|
| 145 |
+
font-size: 1rem;
|
| 146 |
+
color: #333;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.todo-item.completed .todo-text {
|
| 150 |
+
text-decoration: line-through;
|
| 151 |
+
color: #999;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.delete-btn {
|
| 155 |
+
background: none;
|
| 156 |
+
border: none;
|
| 157 |
+
color: #ff4444;
|
| 158 |
+
cursor: pointer;
|
| 159 |
+
font-size: 1.2rem;
|
| 160 |
+
padding: 8px;
|
| 161 |
+
border-radius: 4px;
|
| 162 |
+
transition: all 0.3s ease;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.delete-btn:hover {
|
| 166 |
+
background-color: rgba(255, 68, 68, 0.1);
|
| 167 |
+
transform: scale(1.1);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.footer {
|
| 171 |
+
text-align: center;
|
| 172 |
+
margin-top: 20px;
|
| 173 |
+
color: rgba(255,255,255,0.8);
|
| 174 |
+
font-size: 0.9rem;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.footer a {
|
| 178 |
+
color: white;
|
| 179 |
+
text-decoration: none;
|
| 180 |
+
font-weight: 600;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
.empty-state {
|
| 184 |
+
padding: 40px 20px;
|
| 185 |
+
text-align: center;
|
| 186 |
+
color: #999;
|
| 187 |
+
font-size: 1rem;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
@media (max-width: 480px) {
|
| 191 |
+
.title {
|
| 192 |
+
font-size: 1.5rem;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
.input-group {
|
| 196 |
+
flex-direction: column;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.add-btn {
|
| 200 |
+
width: 100%;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.todo-container {
|
| 204 |
+
border-radius: 12px;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
</style>
|
| 208 |
+
</head>
|
| 209 |
+
<body>
|
| 210 |
+
<div class="header">
|
| 211 |
+
<h1 class="title">Todo App</h1>
|
| 212 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" class="built-with" target="_blank">Built with anycoder</a>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<div class="todo-container">
|
| 216 |
+
<div class="input-section">
|
| 217 |
+
<div class="input-group">
|
| 218 |
+
<input type="text" class="todo-input" placeholder="Add a new task..." id="todoInput">
|
| 219 |
+
<button class="add-btn" id="addBtn">Add</button>
|
| 220 |
+
</div>
|
| 221 |
+
</div>
|
| 222 |
+
|
| 223 |
+
<div class="todo-list" id="todoList">
|
| 224 |
+
<div class="empty-state">
|
| 225 |
+
No tasks yet. Add one above!
|
| 226 |
+
</div>
|
| 227 |
+
</div>
|
| 228 |
+
</div>
|
| 229 |
+
|
| 230 |
+
<div class="footer">
|
| 231 |
+
Made with ❤️ by <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">anycoder</a> | v1.0.0
|
| 232 |
+
</div>
|
| 233 |
+
|
| 234 |
+
<script>
|
| 235 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 236 |
+
const todoInput = document.getElementById('todoInput');
|
| 237 |
+
const addBtn = document.getElementById('addBtn');
|
| 238 |
+
const todoList = document.getElementById('todoList');
|
| 239 |
+
const emptyState = document.querySelector('.empty-state');
|
| 240 |
+
|
| 241 |
+
// Load todos from localStorage
|
| 242 |
+
loadTodos();
|
| 243 |
+
|
| 244 |
+
// Add todo when button is clicked
|
| 245 |
+
addBtn.addEventListener('click', addTodo);
|
| 246 |
+
|
| 247 |
+
// Add todo when Enter key is pressed
|
| 248 |
+
todoInput.addEventListener('keypress', function(e) {
|
| 249 |
+
if (e.key === 'Enter') {
|
| 250 |
+
addTodo();
|
| 251 |
+
}
|
| 252 |
+
});
|
| 253 |
+
|
| 254 |
+
function addTodo() {
|
| 255 |
+
const todoText = todoInput.value.trim();
|
| 256 |
+
|
| 257 |
+
if (todoText === '') {
|
| 258 |
+
alert('Please enter a task!');
|
| 259 |
+
return;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// Create todo object
|
| 263 |
+
const todo = {
|
| 264 |
+
id: Date.now(),
|
| 265 |
+
text: todoText,
|
| 266 |
+
completed: false
|
| 267 |
+
};
|
| 268 |
+
|
| 269 |
+
// Save to localStorage
|
| 270 |
+
saveTodo(todo);
|
| 271 |
+
|
| 272 |
+
// Render the todo
|
| 273 |
+
renderTodo(todo);
|
| 274 |
+
|
| 275 |
+
// Clear input
|
| 276 |
+
todoInput.value = '';
|
| 277 |
+
|
| 278 |
+
// Hide empty state if there are todos
|
| 279 |
+
if (todoList.children.length > 1) {
|
| 280 |
+
emptyState.style.display = 'none';
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
function renderTodo(todo) {
|
| 285 |
+
const todoItem = document.createElement('div');
|
| 286 |
+
todoItem.className = 'todo-item';
|
| 287 |
+
if (todo.completed) {
|
| 288 |
+
todoItem.classList.add('completed');
|
| 289 |
+
}
|
| 290 |
+
todoItem.dataset.id = todo.id;
|
| 291 |
+
|
| 292 |
+
const checkbox = document.createElement('input');
|
| 293 |
+
checkbox.type = 'checkbox';
|
| 294 |
+
checkbox.className = 'todo-checkbox';
|
| 295 |
+
checkbox.checked = todo.completed;
|
| 296 |
+
checkbox.addEventListener('change', function() {
|
| 297 |
+
toggleTodoComplete(todo.id);
|
| 298 |
+
});
|
| 299 |
+
|
| 300 |
+
const textSpan = document.createElement('span');
|
| 301 |
+
textSpan.className = 'todo-text';
|
| 302 |
+
textSpan.textContent = todo.text;
|
| 303 |
+
|
| 304 |
+
const deleteBtn = document.createElement('button');
|
| 305 |
+
deleteBtn.className = 'delete-btn';
|
| 306 |
+
deleteBtn.innerHTML = '<i class="fas fa-trash"></i>';
|
| 307 |
+
deleteBtn.addEventListener('click', function(e) {
|
| 308 |
+
e.stopPropagation();
|
| 309 |
+
deleteTodo(todo.id);
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
todoItem.appendChild(checkbox);
|
| 313 |
+
todoItem.appendChild(textSpan);
|
| 314 |
+
todoItem.appendChild(deleteBtn);
|
| 315 |
+
|
| 316 |
+
// Insert before empty state
|
| 317 |
+
todoList.insertBefore(todoItem, emptyState);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function saveTodo(todo) {
|
| 321 |
+
let todos = JSON.parse(localStorage.getItem('todos')) || [];
|
| 322 |
+
todos.push(todo);
|
| 323 |
+
localStorage.setItem('todos', JSON.stringify(todos));
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
function loadTodos() {
|
| 327 |
+
let todos = JSON.parse(localStorage.getItem('todos')) || [];
|
| 328 |
+
|
| 329 |
+
if (todos.length > 0) {
|
| 330 |
+
emptyState.style.display = 'none';
|
| 331 |
+
todos.forEach(todo => renderTodo(todo));
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
function toggleTodoComplete(id) {
|
| 336 |
+
let todos = JSON.parse(localStorage.getItem('todos')) || [];
|
| 337 |
+
todos = todos.map(todo => {
|
| 338 |
+
if (todo.id == id) {
|
| 339 |
+
todo.completed = !todo.completed;
|
| 340 |
+
}
|
| 341 |
+
return todo;
|
| 342 |
+
});
|
| 343 |
+
localStorage.setItem('todos', JSON.stringify(todos));
|
| 344 |
+
|
| 345 |
+
// Update UI
|
| 346 |
+
const todoItem = document.querySelector(`.todo-item[data-id="${id}"]`);
|
| 347 |
+
if (todoItem) {
|
| 348 |
+
todoItem.classList.toggle('completed');
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
function deleteTodo(id) {
|
| 353 |
+
if (confirm('Are you sure you want to delete this task?')) {
|
| 354 |
+
let todos = JSON.parse(localStorage.getItem('todos')) || [];
|
| 355 |
+
todos = todos.filter(todo => todo.id != id);
|
| 356 |
+
localStorage.setItem('todos', JSON.stringify(todos));
|
| 357 |
+
|
| 358 |
+
// Remove from UI
|
| 359 |
+
const todoItem = document.querySelector(`.todo-item[data-id="${id}"]`);
|
| 360 |
+
if (todoItem) {
|
| 361 |
+
todoItem.remove();
|
| 362 |
+
|
| 363 |
+
// Show empty state if no todos left
|
| 364 |
+
if (todoList.children.length === 1) {
|
| 365 |
+
emptyState.style.display = 'block';
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
});
|
| 371 |
+
</script>
|
| 372 |
+
</body>
|
| 373 |
+
</html>
|