Skip to content

Commit 0e45eae

Browse files
committed
📝🤔Todo
1 parent a0959ab commit 0e45eae

1 file changed

Lines changed: 10 additions & 23 deletions

File tree

‎Todo/app.js‎

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-app.js";
2-
import { getDocs, collection, addDoc, getFirestore, deleteDoc, doc } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-firestore.js";
2+
import { getDocs, collection, addDoc, getFirestore, deleteDoc, doc , updateDoc} from "https://www.gstatic.com/firebasejs/11.10.0/firebase-firestore.js";
33

44
const firebaseConfig = {
55
apiKey: "AIzaSyCmUHMVGUXGvNG1WBSyyqEbLMnw3VOjbYE",
@@ -18,7 +18,6 @@ const todoHandler = document.getElementById('addTodoBtn');
1818
const todoInput = document.getElementById('todoInput');
1919
const main = document.getElementById('main');
2020
const ul = document.createElement('ul')
21-
// const li = document.createElement('li')
2221
ul.className = "todo-list"
2322
ul.id = "todoList"
2423

@@ -66,39 +65,27 @@ function append(setId, todo) {
6665
<button id="${setId}" class="btn-delete">Delete</button>
6766
</li>
6867
`
69-
// console.log(ul);
70-
68+
7169
main.appendChild(ul)
7270
}
7371

7472

7573
ul.addEventListener('click', (e) => {
7674
let btn = e.target.classList.contains("btn-edit")
75+
const input = e.target.previousElementSibling;
7776

7877
if (btn) {
79-
const getElement = ul.children
80-
81-
for (var i = 0; i < getElement.length; i++) {
82-
let getInp = getElement[i].children[0];
83-
let getEditBtn = getElement[i].children[1]
84-
// const moreGet = ul.children
85-
// console.log(moreGet);
86-
87-
if (getInp.id === getEditBtn.id) {
88-
if (moreGet.hasAttribute('readonly')) {
89-
moreGet.removeAttribute('readonly')
90-
moreGet.style.border = "1px solid blue"
91-
} else {
92-
moreGet.setAttribute('readonly', true)
93-
moreGet.style.border = ""
94-
}
95-
}
96-
78+
if (input.hasAttribute('readonly')) {
79+
input.removeAttribute('readonly')
80+
input.style.border = "1px solid #ccc"
81+
} else {
82+
input.setAttribute('readonly', true)
83+
input.style.border = ""
9784
}
98-
9985
}
10086

10187

88+
10289
})
10390

10491
window.addEventListener("DOMContentLoaded", fetching)

0 commit comments

Comments
 (0)