Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ const themeToggle = document.getElementById('theme-toggle');
+ const body = document.body;
+
+ themeToggle.addEventListener('change', function() {
+ if (this.checked) {
+ body.setAttribute('data-theme', 'dark');
+ } else {
+ body.removeAttribute('data-theme');
+ }
+ });
+
+ const tasks = document.querySelectorAll('.task');
+ const columns = document.querySelectorAll('.kanban-column');
+
+ tasks.forEach(task => {
+ task.addEventListener('dragstart', dragStart);
+ task.addEventListener('dragend', dragEnd);
+ });
+
+ columns.forEach(column => {
+ column.addEventListener('dragover', dragOver);
+ column.addEventListener('drop', drop);
+ });
+
+ function dragStart(e) {
+ e.dataTransfer.setData('text/plain', e.target.textContent);
+ setTimeout(() => {
+ e.target.classList.add('hide');
+ }, 0);
+ }
+
+ function dragEnd(e) {
+ e.target.classList.remove('hide');
+ }
+
+ function dragOver(e) {
+ e.preventDefault();
+ }
+
+ function drop(e) {
+ e.preventDefault();
+ const taskContent = e.dataTransfer.getData('text/plain');
+ const newTask = document.createElement('div');
+ newTask.classList.add('task');
+ newTask.textContent = taskContent;
+ newTask.setAttribute('draggable', true);
+ newTask.addEventListener('dragstart', dragStart);
+ newTask.addEventListener('dragend', dragEnd);
+ e.target.querySelector('.tasks').appendChild(newTask);
+ }
+
+ const addTaskButtons = document.querySelectorAll('.add-task');
+ addTaskButtons.forEach(button => {
+ button.addEventListener('click', function() {
+ const taskContent = prompt('Enter task content:');
+ if (taskContent) {
+ const newTask = document.createElement('div');
+ newTask.classList.add('task');
+ newTask.textContent = taskContent;
+ newTask.setAttribute('draggable', true);
+ newTask.addEventListener('dragstart', dragStart);
+ newTask.addEventListener('dragend', dragEnd);
+ this.previousElementSibling.appendChild(newTask);
+ }
+ });
+ });
+ });