Файловый менеджер - Редактировать - /home/gqdcvggs/.trash/index.php.2
Назад
index.php <?php $data = json_decode(file_get_contents('stock.json'), true); $trains = $data['trains'] ?? []; ?> <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Départs des Trains</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="bg-black text-white"> <!-- En-tête avec horloge --> <div class="container mx-auto p-4"> <header class="flex justify-between items-center mb-8"> <div> <h1 class="text-2xl font-light">Départs</h1> <p id="last-update" class="text-gray-500 text-sm mt-1"></p> </div> <div class="text-right"> <div id="clock" class="text-4xl font-light"></div> <div id="date" class="text-gray-500 text-sm mt-1"></div> </div> </header> <!-- Liste des trains --> <div id="trains" class="space-y-3"></div> </div> <!-- Zone d'annonce --> <div id="announcement" class="fixed bottom-0 left-0 w-full transform translate-y-full transition-transform duration-500"> <div class="bg-blue-600/10 backdrop-blur-sm"> <div class="container mx-auto py-6 px-4"> <p id="announcement-text" class="text-xl font-light"></p> </div> </div> </div> <!-- Audio --> <audio id="jingle-pre" src="sounds/jingles/pre.mp3" preload="auto"></audio> <audio id="jingle-arrival" src="sounds/jingles/arrival.mp3" preload="auto"></audio> <audio id="bell" src="sounds/jingles/bell.mp3" preload="auto"></audio> <script> // Gestion du temps function updateDateTime() { const now = new Date(); const timeOptions = { hour: '2-digit', minute: '2-digit' }; const dateOptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; document.getElementById('clock').textContent = now.toLocaleTimeString('fr-FR', timeOptions); document.getElementById('date').textContent = now.toLocaleDateString('fr-FR', dateOptions); } // Classe pour gérer les annonces sonores class SoundManager { constructor() { this.jinglePre = document.getElementById('jingle-pre'); this.jingleArrival = document.getElementById('jingle-arrival'); this.bell = document.getElementById('bell'); this.isPlaying = false; this.queue = []; } async playAnnouncement(text, type = 'pre') { if (this.isPlaying) { this.queue.push({ text, type }); return; } this.isPlaying = true; const announcement = document.getElementById('announcement'); const announcementText = document.getElementById('announcement-text'); try { // Jouer le bon jingle selon le type const jingle = type === 'pre' ? this.jinglePre : this.jingleArrival; await this.playSound(jingle); // Afficher et lire l'annonce announcementText.textContent = text; announcement.classList.remove('translate-y-full'); // Créer et configurer l'utterance const utterance = new SpeechSynthesisUtterance(text); utterance.lang = 'fr-FR'; utterance.rate = 0.85; utterance.pitch = 0.95; // Lire l'annonce await new Promise(resolve => { utterance.onend = resolve; speechSynthesis.speak(utterance); }); // Attendre un peu puis cacher l'annonce await new Promise(resolve => setTimeout(resolve, 2000)); announcement.classList.add('translate-y-full'); await new Promise(resolve => setTimeout(resolve, 500)); } finally { this.isPlaying = false; if (this.queue.length > 0) { const next = this.queue.shift(); this.playAnnouncement(next.text, next.type); } } } async playSound(audio) { audio.currentTime = 0; try { await audio.play(); await new Promise(resolve => { audio.onended = resolve; }); } catch (e) { console.error('Erreur de lecture audio:', e); } } } const soundManager = new SoundManager(); // Mise à jour des trains function updateTrains() { fetch('stock.json?' + new Date().getTime()) .then(response => response.json()) .then(data => { const trainsDiv = document.getElementById('trains'); const now = new Date(); document.getElementById('last-update').textContent = 'Mise à jour : ' + now.toLocaleTimeString('fr-FR'); trainsDiv.innerHTML = ''; (data.trains || []).forEach(train => { const arrival = new Date(train.arrival); const timeLeft = (arrival - now) / 1000; // Ne pas afficher les trains partis depuis plus de 20 secondes if (timeLeft < -20) return; // Gestion des annonces if (timeLeft <= 60 && timeLeft > 59) { const preAnnounce = `Votre attention s'il vous plaît. Le ${train.type} ${train.line} à destination de ${train.destination} arrivera voie ${train.platform} dans quelques instants.`; soundManager.playAnnouncement(preAnnounce, 'pre'); } if (timeLeft <= 0 && timeLeft > -1) { const arrivalAnnounce = `Le ${train.type} ${train.line} à destination de ${train.destination} entre en gare voie ${train.platform}.`; soundManager.playAnnouncement(arrivalAnnounce, 'arrival'); } // Affichage du train const div = document.createElement('div'); div.className = `bg-gray-900 p-4 rounded-lg flex items-center justify-between ${timeLeft <= 60 ? 'border-l-4 border-yellow-500' : ''} ${timeLeft <= 0 ? 'border-l-4 border-green-500' : ''} ${timeLeft < -10 ? 'opacity-50' : ''}`; const timeDisplay = formatTimeLeft(timeLeft); div.innerHTML = ` <div class="flex items-center gap-8"> <div class="w-24"> <div class="text-2xl font-light">${arrival.toLocaleTimeString('fr-FR', {hour: '2-digit', minute: '2-digit'})}</div> <div class="text-sm text-gray-500">${timeDisplay}</div> </div> <div> <div class="flex items-center gap-3 mb-1"> <div class="px-3 py-1 bg-blue-900 rounded text-sm">${train.type} ${train.line}</div> <div class="font-light">${train.destination}</div> </div> <div class="text-sm text-gray-500"> Voie ${train.platform} ${train.info ? ` • ${train.info}` : ''} </div> </div> </div> <div class="flex items-center gap-2"> <div class="w-2 h-2 rounded-full ${train.status === 'on-time' ? 'bg-green-500' : 'bg-yellow-500'}"></div> <span class="text-sm text-gray-500">${train.status === 'on-time' ? 'À l\'heure' : 'Retardé'}</span> </div> `; trainsDiv.appendChild(div); }); }); } function formatTimeLeft(seconds) { if (seconds < 0) return "À quai"; if (seconds < 60) return Math.ceil(seconds) + "s"; if (seconds < 3600) return Math.ceil(seconds / 60) + " min"; const hours = Math.floor(seconds / 3600); const mins = Math.ceil((seconds % 3600) / 60); return `${hours}h${mins.toString().padStart(2, '0')}`; } // Initialisation updateDateTime(); updateTrains(); setInterval(updateDateTime, 1000); setInterval(updateTrains, 1000); // Activer l'audio au premier clic document.addEventListener('click', () => { const audios = [ document.getElementById('jingle-pre'), document.getElementById('jingle-arrival'), document.getElementById('bell') ]; audios.forEach(audio => audio.play().catch(() => {})); speechSynthesis.speak(new SpeechSynthesisUtterance('')); }); </script> </body> </html>
| ver. 1.6 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка