Auto commit: 2026-02-19T00:19:24.386Z
This commit is contained in:
parent
dcabcfb010
commit
3ce02134e3
48
index.php
48
index.php
@ -1803,9 +1803,9 @@ $twitter_link = "https://twitter.com/";
|
||||
<textarea id="user-message" placeholder="¿Qué quieres escuchar?"></textarea>
|
||||
</div>
|
||||
|
||||
<a href="<?= $whatsapp_link ?>" target="_blank" class="send-whatsapp-btn" style="text-decoration: none;">
|
||||
<i class="bi bi-whatsapp"></i> WHATSAPP
|
||||
</a>
|
||||
<button onclick="sendToWhatsApp()" class="send-whatsapp-btn" style="width: 100%; border: none; text-decoration: none;">
|
||||
<i class="bi bi-whatsapp"></i> PEDIR POR WHATSAPP
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Fan of the Month Section -->
|
||||
@ -1942,9 +1942,14 @@ $twitter_link = "https://twitter.com/";
|
||||
<input type="text" id="req-song" placeholder="Ej: Tití Me Preguntó">
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="submitSongRequest()" id="submit-req-btn" style="margin-top: 0.8rem; background: var(--primary-color); color: white; border: none; padding: 0.8rem; border-radius: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; transition: all 0.3s;">
|
||||
<i class="bi bi-plus-circle-fill"></i> PEDIR CANCIÓN
|
||||
</button>
|
||||
<div style="display: flex; gap: 0.8rem; margin-top: 0.8rem;">
|
||||
<button onclick="submitSongRequest()" id="submit-req-btn" style="flex: 1; background: var(--primary-color); color: white; border: none; padding: 0.8rem; border-radius: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: all 0.3s;">
|
||||
<i class="bi bi-plus-circle-fill"></i> PEDIR CANCIÓN
|
||||
</button>
|
||||
<button onclick="sendToWhatsApp()" style="flex: 1; background: #25D366; color: white; border: none; padding: 0.8rem; border-radius: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: all 0.3s;">
|
||||
<i class="bi bi-whatsapp"></i> POR WHATSAPP
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="song-requests-list" class="request-list">
|
||||
<div style="opacity: 0.5; font-size: 0.85rem; text-align: center; padding: 2rem;">No hay peticiones recientes.</div>
|
||||
@ -2556,10 +2561,14 @@ $twitter_link = "https://twitter.com/";
|
||||
});
|
||||
}
|
||||
|
||||
function sendToWhatsApp() {
|
||||
async function sendToWhatsApp() {
|
||||
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 reqArtist = document.getElementById('req-artist').value.trim();
|
||||
const reqSong = document.getElementById('req-song').value.trim();
|
||||
|
||||
const phoneRegex = /^\+?[0-9]{7,15}$/;
|
||||
|
||||
if (name.length < 3) {
|
||||
@ -2585,13 +2594,38 @@ $twitter_link = "https://twitter.com/";
|
||||
const refId = Math.floor(1000 + Math.random() * 9000);
|
||||
const currentSong = document.getElementById('track-title').innerText.replace(/\s{2,}/g, ' ').trim();
|
||||
|
||||
let requestDetails = "";
|
||||
if (reqArtist && reqSong) {
|
||||
requestDetails = `*Petición:* ${reqArtist} - ${reqSong}\n`;
|
||||
}
|
||||
|
||||
const text = `*PETICIÓN RADIO* (Ref: #${refId})\n\n` +
|
||||
`*Nombre:* ${name}\n` +
|
||||
`*Móvil:* ${phone}\n` +
|
||||
`*Fecha:* ${dateTime}\n` +
|
||||
requestDetails +
|
||||
`*Sonando ahora:* ${currentSong}\n\n` +
|
||||
`*Mensaje:* ${message || 'Sin mensaje específico'}`;
|
||||
|
||||
// Register in database
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('artist', reqArtist || 'WhatsApp');
|
||||
formData.append('song', reqSong || message || 'Petición Directa');
|
||||
formData.append('requester', name);
|
||||
formData.append('source', 'whatsapp');
|
||||
|
||||
await fetch('api/song_requests.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (typeof fetchSongRequests === 'function') fetchSongRequests();
|
||||
if (typeof fetchLeaderboard === 'function') fetchLeaderboard();
|
||||
} catch (e) {
|
||||
console.error("Error registering WhatsApp request:", e);
|
||||
}
|
||||
|
||||
const url = `https://wa.me/<?= str_replace('+', '', $whatsapp_number) ?>?text=${encodeURIComponent(text)}`;
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user