-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.js
45 lines (34 loc) · 1.39 KB
/
todo.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
function renderTodos(filteredTodos = todos) {
const tbody = document.querySelector("#todoTable tbody");
tbody.textContent = "";
filteredTodos.forEach((todo) => {
const tr = document.createElement("tr");
const idTd = document.createElement("td");
idTd.textContent = `${todo.id.substr(0, 3)}...`;
tr.appendChild(idTd);
const textTd = document.createElement("td");
textTd.textContent = todo.text;
if (todo.isDone) {
textTd.classList.add("done");
}
tr.appendChild(textTd);
const statusTd = document.createElement("td");
statusTd.textContent = todo.isDone ? "הושלם" : "לא הושלם";
tr.appendChild(statusTd);
const actionsTd = document.createElement("td");
const toggleButton = document.createElement("button");
toggleButton.textContent = todo.isDone ? "בטל סיום" : "סמן כהושלם";
toggleButton.onclick = () => toggleDone(todo.id);
actionsTd.appendChild(toggleButton);
const editButton = document.createElement("button");
editButton.textContent = "ערוך";
editButton.onclick = () => editTodo(todo.id);
actionsTd.appendChild(editButton);
const deleteButton = document.createElement("button");
deleteButton.textContent = "מחק";
deleteButton.onclick = () => deleteTodo(todo.id);
actionsTd.appendChild(deleteButton);
tr.appendChild(actionsTd);
tbody.appendChild(tr);
});
}