be my developer. create a simple todo task manager app.
- User
be my developer.
create a simple todo task manager app.
Assistant
I'll create a simple todo task manager app for you using HTML, CSS, and JavaScript. Here's a complete, functional app:
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Todo Task Manager</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Todo Task Manager</h1> <div class="input-section"> <input type="text" id="taskInput" placeholder="Enter a new task..." maxlength="100"> <button id="addBtn">Add Task</button> </div> <div class="filter-section"> <button class="filter-btn active" data-filter="all">All</button> <button class="filter-btn" data-filter="pending">Pending</button> <button class="filter-btn" data-filter="completed">Completed</button> </div> <ul id="taskList" class="task-list"></ul> <div class="stats"> <span id="taskCount">0 tasks remaining</span> <button id="clearCompleted">Clear Completed</button> </div> </div> <script src="script.js"></script> </body> </html>style.css
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 20px; } .container { max-width: 600px; margin: 0 auto; background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); overflow: hidden; } h1 { text-align: center; padding: 30px 20px; background: #4a90e2; color: white; font-weight: 300; font-size: 2rem; } .input-section { padding: 20px; display: flex; gap: 10px; } #taskInput { flex: 1; padding: 12px 16px; border: 2px solid #e1e8ed; border-radius: 6px; font-size: 16px; outline: none; transition: border-color 0.3s; } #taskInput:focus { border-color: #4a90e2; } #addBtn { padding: 12px 24px; background: #4a90e2; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 16px; transition: background 0.3s; } #addBtn:hover { background: #357abd; } .filter-section { padding: 0 20px; display: flex; gap: 10px; margin-bottom: 20px; } .filter-btn { padding: 8px 16px; border: 1px solid #ddd; background: white; border-radius: 20px; cursor: pointer; transition: all 0.3s; } .filter-btn.active { background: #4a90e2; color: white; border-color: #4a90e2; } .task-list { list-style: none; padding: 0 20px; max-height: 400px; overflow-y: auto; } .task-item { display: flex; align-items: center; padding: 15px 0; border-bottom: 1px solid #f0f0f0; animation: slideIn 0.3s ease; } @keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .task-item.completed { opacity: 0.6; } .task-item.completed .task-text { text-decoration: line-through; color: #888; } .task-checkbox { margin-right: 12px; width: 18px; height: 18px; cursor: pointer; } .task-text { flex: 1; font-size: 16px; word-wrap: break-word; } .delete-btn { background: #ff6b6b; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; transition: background 0.3s; } .delete-btn:hover { background: #ff5252; } .stats { padding: 20px; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; font-size: 14px; color: #666; } #clearCompleted { background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; transition: background 0.3s; } #clearCompleted:hover { background: #5a6268; } .hidden { display: none !important; }script.js
class TodoApp { constructor() { this.tasks = JSON.parse(localStorage.getItem('tasks')) || []; this.currentFilter = 'all'; this.initializeElements(); this.attachEventListeners(); this.render(); } initializeElements() { this.taskInput = document.getElementById('taskInput'); this.addBtn = document.getElementById('addBtn'); this.taskList = document.getElementById('taskList'); this.taskCount = document.getElementById('taskCount'); this.clearCompleted = document.getElementById('clearCompleted'); this.filterBtns = document.querySelectorAll('.filter-btn'); } attachEventListeners() { this.addBtn.addEventListener('click', () => this.addTask()); this.taskInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') this.addTask(); }); this.clearCompleted.addEventListener('click', () => this.clearCompletedTasks()); this.filterBtns.forEach(btn => { btn.addEventListener('click', (e) => { this.currentFilter = e.target.dataset.filter; this.updateFilterButtons(); this.render(); }); }); } addTask() { const text = this.taskInput.value.trim(); if (text === '') return; const task = { id: Date.now(), text: text, completed: false, createdAt: new Date().toISOString() }; this.tasks.unshift(task); this.taskInput.value = ''; this.saveToLocalStorage(); this.render(); } deleteTask(id) { this.tasks = this.tasks.filter(task => task.id !== id); this.saveToLocalStorage(); this.render(); } toggleTask(id) { const task = this.tasks.find(task => task.id === id); if (task) { task.completed = !task.completed; this.saveToLocalStorage(); this.render(); } } clearCompletedTasks() { this.tasks = this.tasks.filter(task => !task.completed); this.saveToLocalStorage(); this.render(); } updateFilterButtons() { this.filterBtns.forEach(btn => { btn.classList.remove('active'); if (btn.dataset.filter === this.currentFilter) { btn.classList.add('active'); } }); } getFilteredTasks() { switch (this.currentFilter) { case 'pending': return this.tasks.filter(task => !task.completed); case 'completed': return this.tasks.filter(task => task.completed); default: return this.tasks; } } render() { const filteredTasks = this.getFilteredTasks(); this.taskList.innerHTML = ''; if (filteredTasks.length === 0) { const emptyMessage = document.createElement('li'); emptyMessage.style.textAlign = 'center'; emptyMessage.style.color = '#666'; emptyMessage.style.fontStyle = 'italic'; emptyMessage.style.padding = '40px 0'; emptyMessage.textContent = this.getEmptyMessage(); this.taskList.appendChild(emptyMessage); } else { filteredTasks.forEach(task => { const taskElement = this.createTaskElement(task); this.taskList.appendChild(taskElement); }); } this.updateStats(); } getEmptyMessage() { switch (this.currentFilter) { case 'pending': return 'No pending tasks! 🎉'; case 'completed': return 'No completed tasks yet.'; default: return 'No tasks yet. Add one above!'; } } createTaskElement(task) { const li = document.createElement('li'); li.className = `task-item ${task.completed ? 'completed' : ''}`; li.innerHTML = ` <input type="checkbox" class="task-checkbox" ${task.completed ? 'checked' : ''}> <span class="task-text">${this.escapeHtml(task.text)}</span> <button class="delete-btn">Delete</button> `; const checkbox = li.querySelector('.task-checkbox'); const deleteBtn = li.querySelector('.delete-btn'); checkbox.addEventListener('change', () => this.toggleTask(task.id)); deleteBtn.addEventListener('click', () => this.deleteTask(task.id)); return li; } updateStats() { const pendingTasks = this.tasks.filter(task => !task.completed).length; this.taskCount.textContent = `${pendingTasks} task${pendingTasks !== 1 ? 's' : ''} remaining`; const hasCompleted = this.tasks.some(task => task.completed); this.clearCompleted.style.display = hasCompleted ? 'block' : 'none'; } escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } saveToLocalStorage() { localStorage.setItem('tasks', JSON.stringify(this.tasks)); } } // Initialize the app when the page loads document.addEventListener('DOMContentLoaded', () => { new TodoApp(); });This todo app includes:
Features:
- Add new tasks
- Mark tasks as complete/incomplete
- Delete individual tasks
- Filter tasks (All, Pending, Completed)
- Clear all completed tasks
- Task counter
- Local storage persistence
- Responsive design
How to use:
- Save all three files in the same folder
- Open
index.htmlin any web browser - Start adding and managing your tasks!
The app automatically saves your tasks to local storage, so they'll persist between browser sessions. The interface is clean and intuitive with smooth animations and a modern design.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.