-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditDetails.js
More file actions
53 lines (51 loc) · 1.85 KB
/
editDetails.js
File metadata and controls
53 lines (51 loc) · 1.85 KB
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
function cancelEdit(){
let popup = document.querySelector('.edit-popup');
popup.classList.remove("open-popup");
}
function openEditPopup(form){
let popup = document.querySelector('.edit-popup');
popup.classList.add("open-popup");
//
// const nameInput = document.getElementById('change-name');
// const valueInput = document.getElementById('change-value');
//
// const changeBtn = document.getElementById('change');
// changeBtn.addEventListener('click', function() {
// let currentName = form.querySelector('.text h3');
// let currentValue = form.querySelector('.text h4');
//
// Wallets.forEach(wallet => {
// if (wallet.name === currentName.textContent && wallet.value === currentValue.textContent.replace('$', '')) {
// wallet.name = nameInput.value;
// wallet.value = valueInput.value;
//
// currentName.textContent = nameInput.value;
// currentValue.textContent = '$' + valueInput.value;
// }
// });
//
// updateSumTotal();
// populateWallets();
// populateCategories();
// cancelEdit();
// });
const deleteBtn = document.getElementById('delete');
deleteBtn.addEventListener('click', function() {
let currenName = form.parentNode.querySelector('h3');
Wallets.forEach((wallet, index) => {
if (wallet.name === currenName.textContent) {
Wallets.splice(index, 1);
updateSumTotal();
populateWallets();
}
});
Categories.forEach((category, index) => {
if (category.name === currenName.textContent) {
Categories.splice(index, 1);
}
});
stringJSON();
form.parentNode.remove();
cancelEdit();
});
}