Download index.html from managerbhingong/crimsoncount-simple-red-timer: direct link, hf CLI and curl.
- Browser
- Download file 17.6 kB
-
https://huggingface.co/spaces/managerbhingong/crimsoncount-simple-red-timer/resolve/main/index.html
- Command line
-
hf download hf://spaces/managerbhingong/crimsoncount-simple-red-timer/index.html
-
curl -L -o index.html https://huggingface.co/spaces/managerbhingong/crimsoncount-simple-red-timer/resolve/main/index.html
17.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>CrimsonCount - Simple Timer</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: '#ef4444', | |
| secondary: '#6b7280' | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap'); | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%); | |
| } | |
| .timer-display { | |
| text-shadow: 0 0 20px rgba(239, 68, 68, 0.3); | |
| } | |
| .glow { | |
| box-shadow: 0 0 30px rgba(239, 68, 68, 0.2); | |
| } | |
| .pulse-animation { | |
| animation: pulse 2s infinite; | |
| } | |
| @keyframes pulse { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.05); } | |
| 100% { transform: scale(1); } | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen flex items-center justify-center text-white"> | |
| <div class="container mx-auto px-4 max-w-md"> | |
| <!-- Timer Display --> | |
| <div class="text-center mb-8"> | |
| <h1 class="text-3xl font-bold mb-2 text-primary">CrimsonCount</h1> | |
| <p class="text-secondary mb-6">Simple & Elegant Timer</p> | |
| <div class="timer-display bg-black/30 rounded-2xl p-8 border border-red-900/50 glow"> | |
| <div id="timer" class="text-7xl font-bold mb-4 text-primary font-mono">25:00</div> | |
| <div class="text-secondary text-sm">Minutes : Seconds</div> | |
| </div> | |
| </div> | |
| <!-- Control Buttons --> | |
| <div class="flex justify-center space-x-4 mb-8"> | |
| <button id="resetBtn" class="bg-primary hover:bg-red-600 text-white px-6 py-3 rounded-xl font-semibold transition-all duration-300 transform hover:scale-105 flex items-center space-x-2"> | |
| <i data-feather="refresh-cw"></i> | |
| <span>Reset</span> | |
| </button> | |
| <button id="settingsBtn" class="bg-secondary hover:bg-gray-600 text-white px-6 py-3 rounded-xl font-semibold transition-all duration-300 transform hover:scale-105 flex items-center space-x-2"> | |
| <i data-feather="settings"></i> | |
| <span>Settings</span> | |
| </button> | |
| </div> | |
| <!-- Status & Live Info --> | |
| <div class="space-y-2 mb-6"> | |
| <div id="status" class="text-center text-secondary text-sm"> | |
| Timer Ready - Click Reset to Start | |
| </div> | |
| <div id="viewers" class="text-center text-secondary text-xs"> | |
| <i data-feather="users" class="w-3 h-3 inline mr-1"></i> | |
| <span>Loading viewers...</span> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Settings Modal --> | |
| <div id="settingsModal" class="fixed inset-0 bg-black/80 flex items-center justify-center hidden z-50"> | |
| <div class="bg-gray-900 rounded-2xl p-6 max-w-md w-full mx-4 border border-red-900/50"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h3 class="text-xl font-bold text-primary">Timer Settings</h3> | |
| <button id="closeModal" class="text-secondary hover:text-white"> | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-secondary mb-2">Timer Duration (minutes)</label> | |
| <input type="number" id="durationInput" min="1" max="120" value="25" | |
| class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-secondary mb-2">Alarm Sound</label> | |
| <select id="alarmSelect" class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none"> | |
| <option value="beep">Beep</option> | |
| <option value="bell">Bell</option> | |
| <option value="chime">Chime</option> | |
| <option value="none">No Sound</option> | |
| </select> | |
| </div> | |
| <div class="flex items-center space-x-2"> | |
| <input type="checkbox" id="autoRestart" class="rounded bg-gray-800 border-gray-700 text-primary focus:ring-primary"> | |
| <label class="text-sm text-secondary">Auto-restart timer</label> | |
| </div> | |
| </div> | |
| <div class="flex justify-end space-x-3 mt-6"> | |
| <button id="cancelSettings" class="px-4 py-2 text-secondary hover:text-white transition-colors"> | |
| Cancel | |
| </button> | |
| <button id="saveSettings" class="bg-primary hover:bg-red-600 text-white px-6 py-2 rounded-lg font-semibold transition-colors"> | |
| Save Settings | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Audio Elements --> | |
| <audio id="beepAlarm" preload="auto"> | |
| <source src="https://assets.mixkit.co/active_storage/sfx/257/257-preview.mp3" type="audio/mpeg"> | |
| </audio> | |
| <audio id="bellAlarm" preload="auto"> | |
| <source src="https://assets.mixkit.co/active_storage/sfx/250/250-preview.mp3" type="audio/mpeg"> | |
| </audio> | |
| <audio id="chimeAlarm" preload="auto"> | |
| <source src="https://assets.mixkit.co/active_storage/sfx/255/255-preview.mp3" type="audio/mpeg"> | |
| </audio> | |
| <script> | |
| class Timer { | |
| constructor() { | |
| this.duration = 25 * 60; // 25 minutes in seconds | |
| this.remainingTime = this.duration; | |
| this.isRunning = false; | |
| this.interval = null; | |
| this.alarmType = 'beep'; | |
| this.autoRestart = false; | |
| this.viewers = 1; | |
| this.lastUpdateTime = Date.now(); | |
| this.viewerId = Math.random().toString(36).substr(2, 9); | |
| this.initializeElements(); | |
| this.attachEventListeners(); | |
| this.initializeRealTimeSync(); | |
| this.updateDisplay(); | |
| } | |
| initializeElements() { | |
| this.timerDisplay = document.getElementById('timer'); | |
| this.statusDisplay = document.getElementById('status'); | |
| this.resetBtn = document.getElementById('resetBtn'); | |
| this.settingsBtn = document.getElementById('settingsBtn'); | |
| this.settingsModal = document.getElementById('settingsModal'); | |
| this.closeModal = document.getElementById('closeModal'); | |
| this.cancelSettings = document.getElementById('cancelSettings'); | |
| this.saveSettings = document.getElementById('saveSettings'); | |
| this.durationInput = document.getElementById('durationInput'); | |
| this.alarmSelect = document.getElementById('alarmSelect'); | |
| this.autoRestartCheckbox = document.getElementById('autoRestart'); | |
| } | |
| attachEventListeners() { | |
| this.resetBtn.addEventListener('click', () => this.reset()); | |
| this.settingsBtn.addEventListener('click', () => this.openSettings()); | |
| this.closeModal.addEventListener('click', () => this.closeSettings()); | |
| this.cancelSettings.addEventListener('click', () => this.closeSettings()); | |
| this.saveSettings.addEventListener('click', () => this.saveSettingsHandler()); | |
| // Keyboard shortcuts | |
| document.addEventListener('keydown', (e) => { | |
| if (e.code === 'Space') { | |
| e.preventDefault(); | |
| this.reset(); | |
| } else if (e.code === 'Escape') { | |
| this.closeSettings(); | |
| } | |
| }); | |
| } | |
| start() { | |
| if (this.isRunning) return; | |
| this.isRunning = true; | |
| this.lastUpdateTime = Date.now(); | |
| this.statusDisplay.textContent = 'Live Timer Running...'; | |
| this.resetBtn.classList.add('pulse-animation'); | |
| this.interval = setInterval(() => { | |
| this.remainingTime--; | |
| this.updateDisplay(); | |
| if (this.remainingTime <= 0) { | |
| this.complete(); | |
| } | |
| }, 1000); | |
| } | |
| stop() { | |
| this.isRunning = false; | |
| clearInterval(this.interval); | |
| this.resetBtn.classList.remove('pulse-animation'); | |
| this.statusDisplay.textContent = 'Timer Paused'; | |
| } | |
| reset() { | |
| this.stop(); | |
| this.remainingTime = this.duration; | |
| this.updateDisplay(); | |
| this.start(); | |
| this.statusDisplay.textContent = 'Live Timer Started!'; | |
| } | |
| complete() { | |
| this.stop(); | |
| this.remainingTime = 0; | |
| this.updateDisplay(); | |
| this.triggerAlarm(); | |
| this.statusDisplay.textContent = 'Live Timer Complete! 🎉'; | |
| if (this.autoRestart) { | |
| setTimeout(() => { | |
| this.reset(); | |
| this.statusDisplay.textContent = 'Live Auto-restarted Timer'; | |
| }, 2000); | |
| } | |
| } | |
| triggerAlarm() { | |
| if (this.alarmType === 'none') return; | |
| const alarm = document.getElementById(`${this.alarmType}Alarm`); | |
| if (alarm) { | |
| alarm.currentTime = 0; | |
| alarm.play().catch(e => console.log('Audio play failed:', e)); | |
| } | |
| } | |
| initializeRealTimeSync() { | |
| // Sync timer state across multiple browser instances | |
| this.syncInterval = setInterval(() => { | |
| this.syncWithOtherInstances(); | |
| }, 1000); | |
| // Listen for storage events (other tabs) | |
| window.addEventListener('storage', (e) => { | |
| if (e.key === 'timerState') { | |
| const state = JSON.parse(e.newValue); | |
| this.syncTimerState(state); | |
| } | |
| }); | |
| // Listen for page visibility changes | |
| document.addEventListener('visibilitychange', () => { | |
| if (!document.hidden) { | |
| this.syncWithOtherInstances(); | |
| } | |
| }); | |
| } | |
| syncWithOtherInstances() { | |
| const currentTime = Date.now(); | |
| // Update viewer count | |
| const activeViewers = JSON.parse(localStorage.getItem('activeViewers') || '{}'); | |
| // Remove inactive viewers (more than 5 seconds old) | |
| Object.keys(activeViewers).forEach(key => { | |
| if (currentTime - activeViewers[key] > 5000) { | |
| delete activeViewers[key]; | |
| } | |
| }); | |
| // Add/update current viewer | |
| activeViewers[this.viewerId] = currentTime; | |
| localStorage.setItem('activeViewers', JSON.stringify(activeViewers)); | |
| this.viewers = Object.keys(activeViewers).length; | |
| this.updateViewersDisplay(); | |
| // Broadcast current timer state | |
| if (this.isRunning) { | |
| const elapsed = Math.floor((currentTime - this.lastUpdateTime) / 1000); | |
| const newRemaining = Math.max(0, this.remainingTime - elapsed); | |
| if (newRemaining !== this.remainingTime) { | |
| this.remainingTime = newRemaining; | |
| this.lastUpdateTime = currentTime; | |
| this.updateDisplay(); | |
| if (this.remainingTime <= 0) { | |
| this.complete(); | |
| } | |
| } | |
| } | |
| // Save current state to localStorage for other instances | |
| const state = { | |
| remainingTime: this.remainingTime, | |
| isRunning: this.isRunning, | |
| duration: this.duration, | |
| lastUpdate: currentTime | |
| }; | |
| localStorage.setItem('timerState', JSON.stringify(state)); | |
| } | |
| syncTimerState(state) { | |
| if (!state || !state.lastUpdate) return; | |
| const currentTime = Date.now(); | |
| const timeDiff = Math.floor((currentTime - state.lastUpdate) / 1000); | |
| if (state.isRunning && this.isRunning !== state.isRunning) { | |
| // Another instance is controlling the timer | |
| this.remainingTime = Math.max(0, state.remainingTime - timeDiff); | |
| this.isRunning = state.isRunning; | |
| this.duration = state.duration; | |
| this.lastUpdateTime = state.lastUpdate; | |
| if (this.remainingTime <= 0) { | |
| this.complete(); | |
| } else if (this.isRunning) { | |
| this.statusDisplay.textContent = 'Live Timer Running...'; | |
| this.resetBtn.classList.add('pulse-animation'); | |
| } | |
| this.updateDisplay(); | |
| } | |
| } | |
| updateViewersDisplay() { | |
| const viewersElement = document.getElementById('viewers'); | |
| if (viewersElement) { | |
| const viewerText = this.viewers === 1 ? '1 person viewing' : `${this.viewers} people viewing`; | |
| viewersElement.innerHTML = `<i data-feather="users" class="w-3 h-3 inline mr-1"></i><span>${viewerText}</span>`; | |
| feather.replace(); | |
| } | |
| } | |
| updateDisplay() { | |
| const minutes = Math.floor(this.remainingTime / 60); | |
| const seconds = this.remainingTime % 60; | |
| this.timerDisplay.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; | |
| // Add visual feedback when time is running low | |
| if (this.remainingTime <= 60 && this.remainingTime > 0) { | |
| this.timerDisplay.classList.add('text-red-400'); | |
| } else { | |
| this.timerDisplay.classList.remove('text-red-400'); | |
| } | |
| } | |
| openSettings() { | |
| this.stop(); | |
| this.durationInput.value = Math.floor(this.duration / 60); | |
| this.alarmSelect.value = this.alarmType; | |
| this.autoRestartCheckbox.checked = this.autoRestart; | |
| this.settingsModal.classList.remove('hidden'); | |
| } | |
| closeSettings() { | |
| this.settingsModal.classList.add('hidden'); | |
| } | |
| saveSettingsHandler() { | |
| const newDuration = parseInt(this.durationInput.value) * 60; | |
| if (newDuration > 0 && newDuration <= 7200) { // Max 2 hours | |
| this.duration = newDuration; | |
| this.remainingTime = this.duration; | |
| } | |
| this.alarmType = this.alarmSelect.value; | |
| this.autoRestart = this.autoRestartCheckbox.checked; | |
| this.updateDisplay(); | |
| this.closeSettings(); | |
| this.statusDisplay.textContent = 'Settings Saved!'; | |
| } | |
| } | |
| // Initialize timer when page loads | |
| document.addEventListener('DOMContentLoaded', () => { | |
| feather.replace(); | |
| new Timer(); | |
| }); | |
| // Cleanup inactive viewers on page unload | |
| window.addEventListener('beforeunload', () => { | |
| const activeViewers = JSON.parse(localStorage.getItem('activeViewers') || '{}'); | |
| const currentTime = Date.now(); | |
| // Remove viewers older than 10 seconds | |
| Object.keys(activeViewers).forEach(key => { | |
| if (currentTime - activeViewers[key] > 10000) { | |
| delete activeViewers[key]; | |
| } | |
| }); | |
| // Remove current viewer | |
| delete activeViewers[this.viewerId]; | |
| localStorage.setItem('activeViewers', JSON.stringify(activeViewers)); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |