diff --git a/index.php b/index.php index 4aa8440..926160f 100644 --- a/index.php +++ b/index.php @@ -1813,6 +1813,16 @@ $twitter_link = "https://twitter.com/";

Panel Admin Real-Time

+ + +
+

Anunciar "Al Aire"

+

Envía un mensaje a tus contactos de WhatsApp para invitarlos a la emisora.

+ +
+ @@ -2352,16 +2362,44 @@ $twitter_link = "https://twitter.com/"; } function saveUserInfo() { - const name = document.getElementById('user-name').value.trim(); - const phone = document.getElementById('user-phone').value.trim(); + const nameInput = document.getElementById('user-name'); + const phoneInput = document.getElementById('user-phone'); + const name = nameInput.value.trim(); + const phone = phoneInput.value.trim(); if (!name && !phone) return; + const isNewUser = !localStorage.getItem('userName') && name.length >= 3; + + localStorage.setItem('userName', name); + localStorage.setItem('userPhone', phone); + fetch('api/save_user_info.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: name, phone: phone }) }); + + if (isNewUser) { + // Special welcome for first-time identification + showWelcomeToast(name); + + // Send a welcome message to the chat automatically + setTimeout(() => { + sendChatMessage(`¡Hola a todos! Acabo de conectarme a Lili Records Radio. 👋📻`, 'text'); + + // Radio Station welcome response + setTimeout(() => { + sendChatMessage(`¡Bienvenido ${name} a la familia de Lili Records! 🎉 Disfruta de la mejor programación.`, 'text', 'Lili Records Radio'); + }, 1500); + }, 1000); + + confetti({ + particleCount: 150, + spread: 100, + origin: { y: 0.7 } + }); + } } function getUserColor(str) { @@ -2648,27 +2686,27 @@ $twitter_link = "https://twitter.com/"; } } - async function sendChatMessage(msgContent = null, type = 'text') { + async function sendChatMessage(msgContent = null, type = 'text', customUser = null) { const userNameInput = document.getElementById('user-name'); const userPhoneInput = document.getElementById('user-phone'); - const user = userNameInput.value.trim(); + const user = customUser || userNameInput.value.trim(); const phone = userPhoneInput.value.trim(); const message = msgContent || chatMsg.value.trim(); const phoneRegex = /^\+?[0-9]{7,15}$/; - if (user.length < 3) { + if (!customUser && user.length < 3) { alert('Por favor, ingresa un nombre válido arriba (mínimo 3 caracteres).'); userNameInput.style.borderColor = '#ff4444'; return; } - if (!phone) { + if (!customUser && !phone) { alert('Por favor, regístrate con tu móvil arriba para poder chatear.'); userPhoneInput.style.borderColor = '#ff4444'; return; } - if (!phoneRegex.test(phone.replace(/\s/g, ''))) { + if (!customUser && !phoneRegex.test(phone.replace(/\s/g, ''))) { alert('Por favor, ingresa un número de móvil válido arriba.'); userPhoneInput.style.borderColor = '#ff4444'; return; @@ -3528,8 +3566,50 @@ $twitter_link = "https://twitter.com/"; themeBtn.classList.remove('bi-moon-fill'); themeBtn.classList.add('bi-sun-fill'); } + + // Welcome logic for new users + setTimeout(() => { + const welcomeName = localStorage.getItem('userName'); + if (welcomeName) { + showWelcomeToast(welcomeName); + } + }, 2000); })(); + function showWelcomeToast(name) { + const welcomeSound = document.getElementById('welcome-sound'); + if (welcomeSound) { + welcomeSound.volume = 0.5; + welcomeSound.play().catch(e => console.log('Welcome sound blocked:', e)); + } + + const toast = document.createElement('div'); + toast.className = 'copy-toast'; + toast.style.background = 'linear-gradient(135deg, var(--primary-color), var(--accent-color))'; + toast.style.bottom = 'auto'; + toast.style.top = '30px'; + toast.innerHTML = ` ¡Bienvenido de nuevo, ${name}! Disfruta de la mejor música.`; + document.body.appendChild(toast); + + confetti({ + particleCount: 100, + spread: 70, + origin: { y: 0.3 }, + colors: ['#38bdf8', '#00c853', '#ffffff'] + }); + + setTimeout(() => toast.remove(), 4000); + } + + function announceOnAir() { + const currentSong = document.getElementById('track-title').innerText.trim(); + const shareUrl = window.location.origin + window.location.pathname; + const text = `🔴 *¡ESTAMOS AL AIRE!* 🎙️📻\n\nSintoniza ahora *Lili Records Radio* para escuchar la mejor música en vivo.\n\n🎵 *Sonando:* ${currentSong}\n\n👉 *Escúchanos aquí:* ${shareUrl}\n\n¡Te esperamos! 💃🕺`; + + const url = `https://wa.me/?text=${encodeURIComponent(text)}`; + window.open(url, '_blank'); + } + // Handle possible audio interruptions audio.addEventListener('error', function(e) { console.error('Audio error:', e);