-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
161 lines (127 loc) · 4.89 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
let arr_of_obj = new Set();
let value_id;
let card_item;
let flag = false;
let subtask = new Map;
function modal(){
document.getElementById("modaldiv").style.display = "block";
document.getElementById("modaldiv").style.backdropFilter = "blur(5px)";
};
function addCard(){
let card_title = document.getElementById("inputM-box").value;
createObj(card_title);
closeModal();
}
function closeModal(){
document.getElementById("modaldiv").style.display = "none";
}
function createObj(title){
document.getElementById("emptyList").style.display = "none";
let card_of_obj ={
title: title,
id: Date.now(),
subtask
};
arr_of_obj.add(card_of_obj);
createCard(card_of_obj.id);
}
function addList(){
let List_of_item = document.querySelector(".this-list-element").cloneNode(true);
let card_of_item = document.getElementById("inputM-box-card").value;
console.log(value_id);
List_of_item.innerText = card_of_item ;
List_of_item.style.display = "block";
List_of_item.setAttribute('id',`${Date.now()}`);
List_of_item.setAttribute('value',`${Date.now()}`);
List_of_item.setAttribute('style',"margin-left: 10px;");
let done_button = document.createElement('button');
done_button.setAttribute('id',`check-done-${Date.now()}`);
done_button.setAttribute('class','completed');
done_button.setAttribute('value',`${Date.now()}`);
done_button.setAttribute('onclick','completedTask(this.value)');
done_button.innerText = 'Mark as Done';
done_button.setAttribute('style','font-size:15px; cursor:pointer; height:18px; border-radius:10px;');
List_of_item.appendChild(done_button);
List_of_item.setAttribute('onclick',"completedTask(this.value)");
for(obj of arr_of_obj){
for(prop in obj){
if(obj.id == value_id){
obj.subtask.set(`${card_item}`,`${Date.now()}`);
break;
}
}
}
document.getElementById(`${value_id}`).getElementsByClassName('add-list')[0].appendChild(List_of_item).appendChild(done_button);
closeCardModal();
}
function closeCardModal(){
document.getElementById('modalDiv_card').style.display = "none";
}
function addSubtask(val) {
document.getElementById("modalDiv_card").style.display = "block";
value_id = val;
};
function deleteCard(val){
var delete_div = document.getElementById(`${val}`);
for(obj of arr_of_obj){
for(prop in obj){
if (obj.id==val)
arr_of_obj.delete(obj);
break;
}
}
delete_div.parentNode.removeChild(delete_div);
if(arr_of_obj.size==0){
document.getElementById('emptyList').style.display = 'block';
}
};
function createCard(){
let first_card = document.querySelector('.card').cloneNode(true);
display(first_card);
};
function completedTask(value){
document.getElementById(`${value}`).style.textDecoration = 'line-through';
document.getElementById(`${value}`).style.color = 'gray';
document.getElementById(`check-done-${value}`).remove();
}
function display(card){
document.getElementById('emptyList').style.display = 'none'
arr_of_obj.forEach(element => {
card.id = element.id;
card.querySelector(".card-head").innerHTML = element.title;
card.querySelector(".card-head").setAttribute('value',`${element.id}`);
card.setAttribute("value",`${element.id}`);
card.setAttribute("display","block");
card.setAttribute("min-height","300px");
card.querySelector(".delete-button-in-card").setAttribute("value",`${element.id}`);
card.querySelector(".delete-button-in-card").setAttribute("onclick","deleteCard(this.value)");
card.querySelector(".add-button-in-card").setAttribute("value",`${element.id}`);
card.querySelector(".add-button-in-card").setAttribute("onclick","addSubtask(this.value)");
});
if(flag)
card.style.display = 'none';
else
card.style.display = "block";
document.getElementById("outer_container").appendChild(card);
}
function headerFunc(val){
for(let ele of arr_of_obj){
for(let id in ele){
if(ele[id]==val){
card_header = ele.title;
break;
};
};
};
document.querySelector(".back-button").style.display = 'inline';
document.querySelector("#name_of_head").style.display = 'none';
document.querySelector("#button_text").style.display = 'none';
for(let ele of arr_of_obj){
if(ele.id==val){
document.getElementById(`${ele.id}`).style.display = 'block';
}
else {
document.getElementById(`${ele.id}`).style.display = 'none';
}
};
};