-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (44 loc) · 1.61 KB
/
index.js
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
import './style.css';
const addTask = document.querySelector('#add_task');
const toDoList = document.querySelector('#to_do_list');
const inProgressList = document.querySelector('#in_progress_list');
const doneList = document.querySelector('#done_list');
const moveTaskProg = document.querySelector('#move_task_progress');
const moveTaskDone = document.querySelector('#move_task_done');
let selectedTask;
addTask.addEventListener('submit', (event) => {
event.preventDefault();
const title = event.target.title.value;
const description = event.target.description.value;
const task = {
title: title,
description: description,
};
const taskElement = document.createElement('div');
taskElement.innerHTML = `<h3>${task.title}</h3><p>${task.description}</p>`;
taskElement.classList.add('task', 'spacing');
toDoList.appendChild(taskElement);
taskElement.addEventListener('click', () => {
if (selectedTask) selectedTask.classList.remove('selected');
selectedTask = taskElement;
moveTaskProg.disabled = false;
moveTaskDone.disabled = false;
taskElement.classList.add('selected');
});
event.target.title.value = '';
event.target.description.value = '';
});
moveTaskProg.addEventListener('click', () => {
if (!selectedTask) return;
inProgressList.appendChild(selectedTask);
selectedTask.classList.remove('selected');
moveTaskProg.disabled = true;
selectedTask = null;
});
moveTaskDone.addEventListener('click', () => {
if (!selectedTask) return;
doneList.appendChild(selectedTask);
selectedTask.classList.remove('selected');
moveTaskDone.disabled = true;
selectedTask = null;
});