Spaces:
Running
Running
File size: 7,575 Bytes
790fe48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chronomètre Élégant</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.glow-text {
text-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}
.btn-hover:hover {
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
.btn-active:active {
transform: translateY(1px);
}
.timer-container {
perspective: 1000px;
}
.timer-display {
transform-style: preserve-3d;
transition: transform 0.5s;
}
</style>
</head>
<body class="bg-gradient-to-br from-gray-900 to-gray-800 min-h-screen flex items-center justify-center p-4">
<div class="timer-container text-center">
<h1 class="text-4xl md:text-5xl font-bold text-white mb-8 glow-text">Chronomètre</h1>
<div class="timer-display bg-gray-800 rounded-xl p-8 mb-10 shadow-2xl border border-gray-700">
<div class="text-6xl md:text-8xl font-mono font-bold text-blue-400">
<span id="hours">00</span>:<span id="minutes">00</span>:<span id="seconds">00</span>
<span class="text-4xl md:text-6xl" id="milliseconds">.00</span>
</div>
</div>
<div class="flex justify-center space-x-4 md:space-x-6">
<button id="startBtn" class="bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-full text-lg font-semibold transition-all duration-300 btn-hover btn-active shadow-lg flex items-center">
<i class="fas fa-play mr-2"></i> Démarrer
</button>
<button id="stopBtn" class="bg-red-600 hover:bg-red-700 text-white px-6 py-3 rounded-full text-lg font-semibold transition-all duration-300 btn-hover btn-active shadow-lg flex items-center" disabled>
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button id="resetBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-full text-lg font-semibold transition-all duration-300 btn-hover btn-active shadow-lg flex items-center">
<i class="fas fa-redo mr-2"></i> Réinitialiser
</button>
</div>
<div class="mt-12 text-gray-400">
<p class="text-sm">Appuyez sur Démarrer pour commencer le chronomètre</p>
</div>
</div>
<script>
let startTime;
let elapsedTime = 0;
let timerInterval;
let isRunning = false;
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const resetBtn = document.getElementById('resetBtn');
const hoursDisplay = document.getElementById('hours');
const minutesDisplay = document.getElementById('minutes');
const secondsDisplay = document.getElementById('seconds');
const millisecondsDisplay = document.getElementById('milliseconds');
function startTimer() {
if (!isRunning) {
startTime = Date.now() - elapsedTime;
timerInterval = setInterval(updateTimer, 10);
isRunning = true;
toggleButtons();
// Animation
document.querySelector('.timer-display').style.transform = 'rotateX(5deg)';
}
}
function stopTimer() {
if (isRunning) {
clearInterval(timerInterval);
elapsedTime = Date.now() - startTime;
isRunning = false;
toggleButtons();
// Animation
document.querySelector('.timer-display').style.transform = 'rotateX(0)';
}
}
function resetTimer() {
clearInterval(timerInterval);
elapsedTime = 0;
isRunning = false;
updateDisplay();
toggleButtons();
// Animation
document.querySelector('.timer-display').style.transform = 'rotateX(-5deg)';
setTimeout(() => {
document.querySelector('.timer-display').style.transform = 'rotateX(0)';
}, 300);
}
function updateTimer() {
const currentTime = Date.now();
elapsedTime = currentTime - startTime;
updateDisplay();
}
function updateDisplay() {
let totalMilliseconds = elapsedTime;
let totalSeconds = Math.floor(totalMilliseconds / 1000);
let totalMinutes = Math.floor(totalSeconds / 60);
let totalHours = Math.floor(totalMinutes / 60);
let milliseconds = Math.floor((totalMilliseconds % 1000) / 10);
let seconds = totalSeconds % 60;
let minutes = totalMinutes % 60;
let hours = totalHours % 24;
millisecondsDisplay.textContent = `.${milliseconds.toString().padStart(2, '0')}`;
secondsDisplay.textContent = seconds.toString().padStart(2, '0');
minutesDisplay.textContent = minutes.toString().padStart(2, '0');
hoursDisplay.textContent = hours.toString().padStart(2, '0');
}
function toggleButtons() {
startBtn.disabled = isRunning;
stopBtn.disabled = !isRunning;
if (isRunning) {
startBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
startBtn.classList.add('bg-gray-500', 'cursor-not-allowed');
stopBtn.classList.remove('bg-gray-500', 'cursor-not-allowed');
stopBtn.classList.add('bg-red-600', 'hover:bg-red-700');
} else {
startBtn.classList.remove('bg-gray-500', 'cursor-not-allowed');
startBtn.classList.add('bg-green-600', 'hover:bg-green-700');
stopBtn.classList.remove('bg-red-600', 'hover:bg-red-700');
stopBtn.classList.add('bg-gray-500', 'cursor-not-allowed');
}
}
// Event listeners
startBtn.addEventListener('click', startTimer);
stopBtn.addEventListener('click', stopTimer);
resetBtn.addEventListener('click', resetTimer);
// Keyboard controls
document.addEventListener('keydown', (e) => {
if (e.code === 'Space') {
e.preventDefault();
if (isRunning) stopTimer();
else startTimer();
} else if (e.code === 'KeyR') {
resetTimer();
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=djaborolouai/timer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |