File size: 4,483 Bytes
6a3df62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI TaskMaster Pro - To-Do List</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body class="bg-gray-50">
    <custom-navbar></custom-navbar>
    
    <main class="container mx-auto px-4 py-8">
        <div class="max-w-2xl mx-auto">
            <h1 class="text-3xl font-bold text-amber-500 mb-6">My Tasks</h1>
            
            <div class="bg-white rounded-lg shadow-md p-6 mb-6">
                <div class="flex items-center space-x-2">
                    <input type="text" id="newTaskInput" placeholder="Add a new task..." 
                           class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500">
                    <button id="addTaskBtn" class="bg-amber-500 hover:bg-amber-600 text-white px-4 py-2 rounded-lg transition">
                        <i data-feather="plus"></i>
                    </button>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow-md overflow-hidden">
                <div class="p-4 border-b border-gray-200 bg-amber-50">
                    <h2 class="text-xl font-semibold text-amber-800">Today's Tasks</h2>
                </div>
                <ul id="taskList" class="divide-y divide-gray-200">
                    <!-- Tasks will be added here dynamically -->
                </ul>
            </div>
        </div>
    </main>

    <custom-footer></custom-footer>

    <script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
        
        // To-Do List functionality
        document.addEventListener('DOMContentLoaded', function() {
            const taskInput = document.getElementById('newTaskInput');
            const addTaskBtn = document.getElementById('addTaskBtn');
            const taskList = document.getElementById('taskList');
            
            // Add task function
            function addTask(taskText) {
                if (taskText.trim() === '') return;
                
                const taskItem = document.createElement('li');
                taskItem.className = 'p-4 flex items-center justify-between';
                taskItem.innerHTML = `
                    <div class="flex items-center space-x-3">
                        <input type="checkbox" class="h-5 w-5 text-amber-500 rounded focus:ring-amber-500">
                        <span class="task-text">${taskText}</span>
                    </div>
                    <button class="delete-btn text-gray-400 hover:text-red-500 transition">
                        <i data-feather="trash-2"></i>
                    </button>
                `;
                
                taskList.appendChild(taskItem);
                feather.replace();
                
                // Add event listeners for the new task
                const checkbox = taskItem.querySelector('input[type="checkbox"]');
                const deleteBtn = taskItem.querySelector('.delete-btn');
                
                checkbox.addEventListener('change', function() {
                    const taskTextElement = taskItem.querySelector('.task-text');
                    if (this.checked) {
                        taskTextElement.classList.add('line-through', 'text-gray-400');
                    } else {
                        taskTextElement.classList.remove('line-through', 'text-gray-400');
                    }
                });
                
                deleteBtn.addEventListener('click', function() {
                    taskList.removeChild(taskItem);
                });
                
                taskInput.value = '';
            }
            
            // Add task on button click
            addTaskBtn.addEventListener('click', function() {
                addTask(taskInput.value);
            });
            
            // Add task on Enter key
            taskInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    addTask(taskInput.value);
                }
            });
        });
    </script>
</body>
</html>