Changed around line 1
+ let currentTask = null;
+
+ function addTask() {
+ const taskInput = document.getElementById('new-task');
+ const taskText = taskInput.value.trim();
+
+ if (taskText) {
+ const task = {
+ id: Date.now(),
+ text: taskText,
+ description: '',
+ status: 'todo'
+ };
+
+ renderTask(task);
+ taskInput.value = '';
+ }
+ }
+
+ function renderTask(task) {
+ const taskElement = document.createElement('div');
+ taskElement.className = 'task';
+ taskElement.textContent = task.text;
+ taskElement.dataset.id = task.id;
+
+ taskElement.addEventListener('click', () => openTaskModal(task));
+
+ document.querySelector(`#${task.status} .tasks`).appendChild(taskElement);
+ }
+
+ function openTaskModal(task) {
+ currentTask = task;
+ const modal = document.getElementById('task-modal');
+ const description = document.getElementById('task-description');
+
+ description.value = task.description;
+ modal.style.display = 'block';
+
+ document.querySelector('.close').onclick = () => modal.style.display = 'none';
+ window.onclick = (event) => {
+ if (event.target === modal) {
+ modal.style.display = 'none';
+ }
+ };
+ }
+
+ function saveTask() {
+ const description = document.getElementById('task-description').value;
+ currentTask.description = description;
+
+ const taskElement = document.querySelector(`[data-id="${currentTask.id}"]`);
+ if (taskElement) {
+ taskElement.textContent = currentTask.text;
+ if (description) {
+ taskElement.textContent += ' - ' + description;
+ }
+ }
+
+ document.getElementById('task-modal').style.display = 'none';
+ }
+
+ function generateDescription() {
+ const description = document.getElementById('task-description');
+ // This is where you would call your AI API
+ // For now, we'll just add a placeholder text
+ description.value = "AI-generated description placeholder. This would be replaced with actual AI-generated content.";
+ }