From e31225594be204aebed34902b045cc46a748b4f5 Mon Sep 17 00:00:00 2001 From: counterweight Date: Sat, 22 Feb 2025 00:37:53 +0100 Subject: [PATCH] delete old stuff --- src/public/javascript/createProfile.js | 123 ------------------------- 1 file changed, 123 deletions(-) diff --git a/src/public/javascript/createProfile.js b/src/public/javascript/createProfile.js index bfb9ac5..f7af1f1 100644 --- a/src/public/javascript/createProfile.js +++ b/src/public/javascript/createProfile.js @@ -1,126 +1,3 @@ -/* class ContactDetails { - constructor(rootUiElement) { - this.rootUiElement = rootUiElement; - this.details = []; - } - - addDetails(type, value) { - this.details.push({ type, value }); - } - - removeDetails(type, value) { - this.details = this.details.filter( - (detail) => detail.type !== type || detail.value !== value - ); - } - - syncUi() { - requestAnimationFrame(() => { - this.rootUiElement.innerHTML = ''; - this.details.forEach((detail) => { - const addedDetailFragment = this.buildContactDetailBadge(detail); - this.rootUiElement.appendChild(addedDetailFragment); - }); - }); - } - - buildContactDetailBadge(detail) { - const fragment = document.createDocumentFragment(); - - const div = document.createElement('div'); - div.className = 'added-contact-detail badge'; - - const p = document.createElement('p'); - p.textContent = `${detail.type}: ${detail.value}`; - - const button = document.createElement('button'); - button.textContent = 'Eliminar'; - button.onclick = () => { - this.removeDetails(detail.type, detail.value); - this.syncUi(); - return false; - }; - - div.appendChild(p); - div.appendChild(button); - fragment.appendChild(div); - - return fragment; - } - - async getEncryptedContactDetails() { - const jsonString = JSON.stringify(this.details); - const encryptedContactDetails = await window.nostr.nip04.encrypt( - await window.nostr.getPublicKey(), - jsonString - ); - return encryptedContactDetails; - } -} - -let contactDetails; - -window.onload = () => { - contactDetails = new ContactDetails( - document.querySelector('#created-contact-details-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; - - contactDetails.addDetails(type, value); - contactDetails.syncUi(); - - input.value = ''; - }); - }); - - document - .querySelector('#submit-details-button') - .addEventListener('click', async () => { - const encryptedContactDetails = - await contactDetails.getEncryptedContactDetails(); - await fetch('/api/set-contact-details', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ encryptedContactDetails }), - }); - - const nym = document.querySelector('#nym-input').value; - await fetch('/api/set-nym', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ nym }), - }); - - setTimeout(() => { - window.location.href = '/home'; - }, 1000); - }); -}; - */ -/* - -Behaviours: - -- Validate inputs -- Only activate submit profile when nym and one contact method are alive -- Send the data and redirect on button click - - - -*/ - function debounce(func, wait) { let timeout; return function (...args) {