diff --git a/api/song_requests.php b/api/song_requests.php
index 50f8e3c..98d20a8 100644
--- a/api/song_requests.php
+++ b/api/song_requests.php
@@ -17,9 +17,35 @@ if ($method === 'POST') {
try {
if ($action === 'mark_played') {
+ $username = trim($_POST['username'] ?? '');
+
+ // Get request info before updating
+ $stmt = $db->prepare("SELECT is_priority, created_at, artist, song FROM song_requests WHERE id = ?");
+ $stmt->execute([$id]);
+ $req = $stmt->fetch();
+
$stmt = $db->prepare("UPDATE song_requests SET status = 'played' WHERE id = ?");
$stmt->execute([$id]);
- echo json_encode(['success' => true]);
+
+ $bonus = false;
+ if ($req && $req['is_priority'] == 1 && !empty($username)) {
+ $createdAt = strtotime($req['created_at']);
+ $now = time();
+ $diff = $now - $createdAt;
+
+ // Award bonus if handled in less than 5 minutes (300 seconds)
+ if ($diff <= 300) {
+ require_once __DIR__ . '/../includes/points_helper.php';
+ awardLoyaltyPoints($username, 100);
+
+ // Announce bonus
+ $chatMsg = "⚡ ¡BONO DE EFICIENCIA! El DJ **$username** ha atendido un Salto VIP en récord (" . floor($diff/60) . "m " . ($diff%60) . "s). ¡Ha ganado **+100 LP**! 🎧👑";
+ $db->prepare("INSERT INTO messages (username, message, type) VALUES ('Sistema', ?, 'dj_power')")->execute([$chatMsg]);
+ $bonus = true;
+ }
+ }
+
+ echo json_encode(['success' => true, 'bonus_awarded' => $bonus]);
} elseif ($action === 'delete') {
$stmt = $db->prepare("DELETE FROM song_requests WHERE id = ?");
$stmt->execute([$id]);
diff --git a/index.php b/index.php
index 4ab7c79..798aaab 100644
--- a/index.php
+++ b/index.php
@@ -3716,18 +3716,32 @@ $twitter_link = "https://twitter.com/";
return `
-
${isPriority ? '⭐ ' : ''}${req.artist}
+
+
${isPriority ? '⭐ ' : ''}${req.artist}
+ ${isPriority && isGuestDj ? `
+
+ --:--
+
+ ` : ''}
+
${new Date(req.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
${req.song}
${req.requester}
- ${isGuestDj && !isPriority ? `
-
- ` : ''}
- ${isPriority ? '
PRIORIDAD DJ' : ''}
+
+ ${isGuestDj ? `
+
+ ` : ''}
+ ${isGuestDj && !isPriority ? `
+
+ ` : ''}
+ ${isPriority ? ' PRIORIDAD DJ' : ''}
+
`;
@@ -3762,6 +3776,51 @@ $twitter_link = "https://twitter.com/";
}
}
+ async function djMarkPlayed(requestId) {
+ const username = document.getElementById('user-name').value.trim();
+ if (!username) return;
+
+ try {
+ const formData = new FormData();
+ formData.append('action', 'mark_played');
+ formData.append('id', requestId);
+ formData.append('username', username);
+
+ const response = await fetch('api/song_requests.php', {
+ method: 'POST',
+ body: formData
+ });
+ const result = await response.json();
+ if (result.success) {
+ if (result.bonus_awarded) {
+ confetti({
+ particleCount: 150,
+ spread: 70,
+ origin: { y: 0.6 },
+ colors: ['#22c55e', '#ffffff', '#facc15']
+ });
+ // Show quick toast if bonus
+ const toast = document.createElement('div');
+ toast.style = 'position: fixed; top: 20px; right: 20px; background: #22c55e; color: white; padding: 15px 25px; border-radius: 10px; z-index: 10000; font-weight: bold; animation: slideIn 0.3s ease-out;';
+ toast.innerHTML = '⚡ ¡BONO DE RAPIDEZ! +100 LP 🎧';
+ document.body.appendChild(toast);
+ setTimeout(() => {
+ toast.style.animation = 'fadeOut 0.5s ease-in';
+ setTimeout(() => toast.remove(), 500);
+ }, 4000);
+
+ fetchTopFans();
+ }
+ fetchSongRequests();
+ fetchMessages();
+ } else {
+ alert('Error: ' + result.error);
+ }
+ } catch (error) {
+ console.error('Error marking song as played:', error);
+ }
+ }
+
async function djPrioritizeSong(requestId) {
const username = document.getElementById('user-name').value.trim();
if (!username) return;
@@ -4564,6 +4623,41 @@ $twitter_link = "https://twitter.com/";
setInterval(fetchLeaderboard, 60000);
setInterval(fetchUpcomingTracks, 30000);
setInterval(fetchActivePerks, 30000);
+ setInterval(updateVipTimers, 1000);
+
+ function updateVipTimers() {
+ document.querySelectorAll('.vip-timer').forEach(timer => {
+ const startStr = timer.dataset.start;
+ if (!startStr) return;
+
+ const start = new Date(startStr.replace(' ', 'T')).getTime();
+ const now = new Date().getTime();
+ const diff = 300 - Math.floor((now - start) / 1000); // 300 seconds = 5 min
+
+ const valueSpan = timer.querySelector('.timer-value');
+ if (diff <= 0) {
+ timer.innerHTML = ' BONO EXPIRADO';
+ timer.style.color = '#94a3b8';
+ timer.style.background = 'rgba(0,0,0,0.5)';
+ } else {
+ const m = Math.floor(diff / 60);
+ const s = diff % 60;
+ valueSpan.innerText = `${m}:${s.toString().padStart(2, '0')}`;
+
+ // Color logic
+ if (diff < 60) {
+ timer.style.color = '#ff4444';
+ timer.classList.add('counter-alert');
+ } else if (diff < 180) {
+ timer.style.color = '#facc15';
+ timer.classList.remove('counter-alert');
+ } else {
+ timer.style.color = '#22c55e';
+ timer.classList.remove('counter-alert');
+ }
+ }
+ });
+ }
// Initial fetch
updateMetadata();