add contact details on frontend

This commit is contained in:
counterweight 2025-02-13 17:25:23 +01:00
parent 73a6565326
commit 2feb64e7e0
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 67 additions and 0 deletions

6
src/public/css/seca.css Normal file
View file

@ -0,0 +1,6 @@
.badge {
border: 2px solid black;
border-radius: 10px;
margin: 5px;
padding: 5px;
}

View file

@ -0,0 +1,28 @@
const contactDetails = [];
window.onload = () => {
const contactList = document.querySelector('.contact-list');
document.querySelectorAll('.contact-detail-add-button').forEach(button => {
button.addEventListener('click', function () {
const badge = this.parentElement;
const type = badge.getAttribute('data-type');
const input = badge.querySelector('input');
const value = input.value.trim();
if (value === '') return; // Ignore empty input
// Save new contact detail
contactDetails.push({ type, value });
// Create and display a non-editable badge
const newBadge = document.createElement('div');
newBadge.classList.add('contact-badge');
newBadge.innerText = `${type}: ${value}`;
contactList.appendChild(newBadge);
// Clear input field
input.value = '';
});
});
};