Auto commit: 2026-02-15T18:31:36.897Z
This commit is contained in:
parent
27c2edbc0f
commit
efcde372a8
48
index.php
48
index.php
@ -872,8 +872,19 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
|
|||||||
}
|
}
|
||||||
|
|
||||||
function savePhone(phone) {
|
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();
|
const formData = new FormData();
|
||||||
formData.append('phone', phone);
|
formData.append('phone', cleanPhone);
|
||||||
fetch('api/save_phone.php', {
|
fetch('api/save_phone.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
@ -881,7 +892,24 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendToWhatsApp() {
|
function sendToWhatsApp() {
|
||||||
window.open('<?= $whatsapp_link ?>', '_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/<?= str_replace('+', '', $whatsapp_number) ?>?text=${encodeURIComponent(text)}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Chat Functionality ---
|
// --- Chat Functionality ---
|
||||||
@ -922,8 +950,22 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
|
|||||||
|
|
||||||
async function sendChatMessage() {
|
async function sendChatMessage() {
|
||||||
const userNameInput = document.getElementById('user-name');
|
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 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;
|
if (!message) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user