From 2ff79faccb62b63493a16649358ba544ce3f2744 Mon Sep 17 00:00:00 2001 From: develcookingtest Date: Thu, 21 Mar 2024 16:07:00 +0100 Subject: [PATCH] now with delete button --- du.html | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/du.html b/du.html index 23f8f88..7320602 100644 --- a/du.html +++ b/du.html @@ -9,7 +9,7 @@ border: 1px solid #ccc; margin-bottom: 10px; padding: 10px; - position: relative; /* Um Positionierung für den edit-button zu ermöglichen */ + position: relative; /* Um Positionierung für die Buttons zu ermöglichen */ } .weekday-btn-container { display: flex; @@ -70,20 +70,28 @@ text-align: center; } - .edit-button { - position: absolute; - bottom: 5px; - right: 5px; - background-color: #2196F3; - color: white; - border: none; - border-radius: 50%; - width: 30px; - height: 30px; + .edit-button, .delete-button { + position: absolute; /* Änderung von fixed auf absolute */ cursor: pointer; + width: 1.75em; + height: 1.75em; display: flex; justify-content: center; align-items: center; + border-radius: 50%; + font-size: 20px; + } + .edit-button { + background-color: #2196F3; + color: white; + bottom: 0.35em; + right: 2.65em; + } + .delete-button { + background-color: #FF0000; + color: white; + bottom: 0.35em; + right: 0.35em; /* Anpassung der Positionierung */ } @@ -151,13 +159,27 @@ const editButton = document.createElement('div'); // Jetzt innerhalb der Schleife erstellt editButton.classList.add('edit-button'); editButton.innerHTML = '✎'; + editButton.setAttribute('id', `${item.NameValue.name}-edit-button`); // Add click event for edit button editButton.addEventListener('click', function() { - console.log('Edit button clicked'); + console.log('Edit button clicked for', item.NameValue.name); }); jsonElement.appendChild(editButton); // Hinzufügen des edit-buttons zum JSON-Element + + const deleteButton = document.createElement('div'); // Jetzt innerhalb der Schleife erstellt + deleteButton.classList.add('delete-button'); + deleteButton.innerHTML = '🗑'; + deleteButton.setAttribute('id', `${item.NameValue.name}-delete-button`); + + // Add click event for delete button + deleteButton.addEventListener('click', function() { + console.log('Delete button clicked for', item.NameValue.name); + }); + + jsonElement.appendChild(deleteButton); // Hinzufügen des delete-buttons zum JSON-Element + jsonContainer.appendChild(jsonElement); }); })