clockmeets / index.html
biggdadda's picture
Add 1 files
6eb0d1c verified
Raw History Blame Contribute Delete
13 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clock Hand Meetings Tracker</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.clock {
width: 300px;
height: 300px;
border-radius: 50%;
position: relative;
background: radial-gradient(circle, #f5f5f5 0%, #e0e0e0 100%);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), inset 0 0 10px rgba(0, 0, 0, 0.1);
}
.center-dot {
width: 12px;
height: 12px;
background-color: #333;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
.hour-hand {
width: 6px;
height: 70px;
background-color: #333;
position: absolute;
top: 50%;
left: 50%;
transform-origin: bottom center;
border-radius: 4px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.minute-hand {
width: 4px;
height: 100px;
background-color: #555;
position: absolute;
top: 50%;
left: 50%;
transform-origin: bottom center;
border-radius: 4px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.second-hand {
width: 2px;
height: 120px;
background-color: #e74c3c;
position: absolute;
top: 50%;
left: 50%;
transform-origin: bottom center;
border-radius: 4px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.number {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #333;
}
.number span {
display: inline-block;
position: absolute;
}
.tick {
position: absolute;
width: 100%;
height: 100%;
}
.tick::before {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 2px;
height: 10px;
background-color: #555;
transform: translateX(-50%);
}
.tick:nth-child(5n+1)::before {
height: 15px;
background-color: #333;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.meeting-animation {
animation: pulse 0.5s ease-in-out;
}
.counter-card {
transition: all 0.3s ease;
}
.counter-card.active {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
<div class="max-w-4xl w-full bg-white rounded-2xl shadow-xl overflow-hidden">
<div class="p-8">
<h1 class="text-3xl font-bold text-center text-gray-800 mb-2">Clock Hand Meetings Tracker</h1>
<p class="text-center text-gray-600 mb-8">Track how often the clock hands meet in real-time</p>
<div class="flex flex-col lg:flex-row items-center justify-between gap-8">
<!-- Clock -->
<div class="clock mx-auto lg:mx-0">
<div class="center-dot"></div>
<div class="hour-hand" id="hour-hand"></div>
<div class="minute-hand" id="minute-hand"></div>
<div class="second-hand" id="second-hand"></div>
<!-- Numbers -->
<div class="number">
<span style="transform: translate(-50%, 10px); top: 0; left: 50%;">12</span>
<span style="transform: translate(-100%, 50%); top: 50%; left: 85%;">3</span>
<span style="transform: translate(-50%, -100%); bottom: 0; left: 50%;">6</span>
<span style="transform: translate(0%, 50%); top: 50%; left: 15%;">9</span>
</div>
<!-- Ticks -->
<div class="tick" style="transform: rotate(30deg);"></div>
<div class="tick" style="transform: rotate(60deg);"></div>
<div class="tick" style="transform: rotate(90deg);"></div>
<div class="tick" style="transform: rotate(120deg);"></div>
<div class="tick" style="transform: rotate(150deg);"></div>
<div class="tick" style="transform: rotate(180deg);"></div>
<div class="tick" style="transform: rotate(210deg);"></div>
<div class="tick" style="transform: rotate(240deg);"></div>
<div class="tick" style="transform: rotate(270deg);"></div>
<div class="tick" style="transform: rotate(300deg);"></div>
<div class="tick" style="transform: rotate(330deg);"></div>
</div>
<!-- Counters -->
<div class="w-full lg:w-1/2 space-y-6">
<div class="counter-card bg-blue-50 rounded-xl p-6 border border-blue-100" id="hour-minute-counter">
<h3 class="text-xl font-semibold text-blue-800 mb-2">Hour & Minute Hands</h3>
<p class="text-4xl font-bold text-blue-600 mb-2" id="hour-minute-count">0</p>
<p class="text-sm text-blue-500">Meetings occur every ~1 hour and 5 minutes</p>
</div>
<div class="counter-card bg-green-50 rounded-xl p-6 border border-green-100" id="hour-second-counter">
<h3 class="text-xl font-semibold text-green-800 mb-2">Hour & Second Hands</h3>
<p class="text-4xl font-bold text-green-600 mb-2" id="hour-second-count">0</p>
<p class="text-sm text-green-500">Meetings occur every ~1 hour and 5 seconds</p>
</div>
<div class="counter-card bg-purple-50 rounded-xl p-6 border border-purple-100" id="minute-second-counter">
<h3 class="text-xl font-semibold text-purple-800 mb-2">Minute & Second Hands</h3>
<p class="text-4xl font-bold text-purple-600 mb-2" id="minute-second-count">0</p>
<p class="text-sm text-purple-500">Meetings occur every ~1 minute and 1 second</p>
</div>
</div>
</div>
<!-- Digital Clock -->
<div class="mt-8 bg-gray-800 rounded-lg p-4 max-w-xs mx-auto">
<p class="text-center text-white font-mono text-2xl" id="digital-clock">00:00:00</p>
</div>
<!-- Info -->
<div class="mt-8 text-center text-sm text-gray-500">
<p>The clock hands meet at different intervals. This application tracks those meetings in real-time.</p>
</div>
</div>
</div>
<script>
// Initialize counters
let hourMinuteCount = 0;
let hourSecondCount = 0;
let minuteSecondCount = 0;
// Previous angles to detect when hands meet
let prevHourAngle = 0;
let prevMinuteAngle = 0;
let prevSecondAngle = 0;
// Previous meeting times to avoid multiple counts for the same meeting
let lastHourMinuteMeeting = 0;
let lastHourSecondMeeting = 0;
let lastMinuteSecondMeeting = 0;
// Tolerance for considering hands to be meeting (in degrees)
const MEETING_TOLERANCE = 2;
function updateClock() {
const now = new Date();
const hours = now.getHours() % 12;
const minutes = now.getMinutes();
const seconds = now.getSeconds();
const milliseconds = now.getMilliseconds();
// Calculate angles for each hand
const hourAngle = (hours * 30) + (minutes * 0.5) + (seconds * 0.00833);
const minuteAngle = (minutes * 6) + (seconds * 0.1);
const secondAngle = (seconds * 6) + (milliseconds * 0.006);
// Update clock hands
document.getElementById('hour-hand').style.transform = `translate(-50%, -100%) rotate(${hourAngle}deg)`;
document.getElementById('minute-hand').style.transform = `translate(-50%, -100%) rotate(${minuteAngle}deg)`;
document.getElementById('second-hand').style.transform = `translate(-50%, -100%) rotate(${secondAngle}deg)`;
// Update digital clock
const formattedTime = now.toLocaleTimeString();
document.getElementById('digital-clock').textContent = formattedTime;
// Check for meetings between hands
checkMeetings(hourAngle, minuteAngle, secondAngle);
// Update previous angles
prevHourAngle = hourAngle;
prevMinuteAngle = minuteAngle;
prevSecondAngle = secondAngle;
// Call this function again on the next frame
requestAnimationFrame(updateClock);
}
function checkMeetings(hourAngle, minuteAngle, secondAngle) {
const now = Date.now();
// Check hour and minute hands meeting
if (Math.abs(hourAngle - minuteAngle) < MEETING_TOLERANCE &&
Math.abs(prevHourAngle - prevMinuteAngle) >= MEETING_TOLERANCE &&
now - lastHourMinuteMeeting > 1000) {
hourMinuteCount++;
document.getElementById('hour-minute-count').textContent = hourMinuteCount;
document.getElementById('hour-minute-counter').classList.add('active');
lastHourMinuteMeeting = now;
setTimeout(() => {
document.getElementById('hour-minute-counter').classList.remove('active');
}, 300);
}
// Check hour and second hands meeting
if (Math.abs(hourAngle - secondAngle) < MEETING_TOLERANCE &&
Math.abs(prevHourAngle - prevSecondAngle) >= MEETING_TOLERANCE &&
now - lastHourSecondMeeting > 1000) {
hourSecondCount++;
document.getElementById('hour-second-count').textContent = hourSecondCount;
document.getElementById('hour-second-counter').classList.add('active');
lastHourSecondMeeting = now;
setTimeout(() => {
document.getElementById('hour-second-counter').classList.remove('active');
}, 300);
}
// Check minute and second hands meeting
if (Math.abs(minuteAngle - secondAngle) < MEETING_TOLERANCE &&
Math.abs(prevMinuteAngle - prevSecondAngle) >= MEETING_TOLERANCE &&
now - lastMinuteSecondMeeting > 1000) {
minuteSecondCount++;
document.getElementById('minute-second-count').textContent = minuteSecondCount;
document.getElementById('minute-second-counter').classList.add('active');
lastMinuteSecondMeeting = now;
setTimeout(() => {
document.getElementById('minute-second-counter').classList.remove('active');
}, 300);
}
}
// Start the clock
updateClock();
</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=biggdadda/clockmeets" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>