From efcde372a88b34f835696147dcd9cd94778f0921 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 15 Feb 2026 18:31:36 +0000 Subject: [PATCH] Auto commit: 2026-02-15T18:31:36.897Z --- index.php | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index fa05b68..a01fcc6 100644 --- a/index.php +++ b/index.php @@ -872,8 +872,19 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; } function savePhone(phone) { + const phoneInput = document.getElementById('user-phone'); + const phoneRegex = /^\+?[0-9]{7,15}$/; + const cleanPhone = phone.replace(/\s/g, ''); + + if (cleanPhone && !phoneRegex.test(cleanPhone)) { + phoneInput.style.borderColor = '#ff4444'; + return; + } + + phoneInput.style.borderColor = 'rgba(255, 255, 255, 0.2)'; + const formData = new FormData(); - formData.append('phone', phone); + formData.append('phone', cleanPhone); fetch('api/save_phone.php', { method: 'POST', body: formData @@ -881,7 +892,24 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; } function sendToWhatsApp() { - window.open('', '_blank'); + const name = document.getElementById('user-name').value.trim(); + const phone = document.getElementById('user-phone').value.trim(); + const message = document.getElementById('user-message').value.trim(); + const phoneRegex = /^\+?[0-9]{7,15}$/; + + if (!name || !phone) { + alert('Por favor, ingresa tu nombre y número de móvil para continuar.'); + return; + } + + if (!phoneRegex.test(phone.replace(/\s/g, ''))) { + alert('Por favor, ingresa un número de móvil válido (ej: +5359177041).'); + return; + } + + const text = `Hola, soy ${name} (${phone}). Quiero escuchar: ${message}`; + const url = `https://wa.me/?text=${encodeURIComponent(text)}`; + window.open(url, '_blank'); } // --- Chat Functionality --- @@ -922,8 +950,22 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; async function sendChatMessage() { const userNameInput = document.getElementById('user-name'); - const user = userNameInput.value.trim() || 'Anónimo'; + const userPhoneInput = document.getElementById('user-phone'); + const user = userNameInput.value.trim(); + const phone = userPhoneInput.value.trim(); const message = chatMsg.value.trim(); + const phoneRegex = /^\+?[0-9]{7,15}$/; + + if (!user || !phone) { + alert('Por favor, regístrate con tu nombre y móvil arriba para poder chatear.'); + return; + } + + if (!phoneRegex.test(phone.replace(/\s/g, ''))) { + alert('Por favor, ingresa un número de móvil válido arriba.'); + return; + } + if (!message) return; try {