Download index.html from miwf/e: direct link, hf CLI and curl.
- Browser
- Download file 22.2 kB
-
https://huggingface.co/spaces/miwf/e/resolve/main/index.html
- Command line
-
hf download hf://spaces/miwf/e/index.html
-
curl -L -o index.html https://huggingface.co/spaces/miwf/e/resolve/main/index.html
22.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Alarm Clock App</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> | |
| /* Custom scrollbar */ | |
| .alarm-list::-webkit-scrollbar { | |
| width: 6px; | |
| } | |
| .alarm-list::-webkit-scrollbar-track { | |
| background: #f1f1f1; | |
| border-radius: 10px; | |
| } | |
| .alarm-list::-webkit-scrollbar-thumb { | |
| background: #888; | |
| border-radius: 10px; | |
| } | |
| .alarm-list::-webkit-scrollbar-thumb:hover { | |
| background: #555; | |
| } | |
| /* Animation for active alarm */ | |
| @keyframes pulse { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.05); } | |
| 100% { transform: scale(1); } | |
| } | |
| .active-alarm { | |
| animation: pulse 1.5s infinite; | |
| box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); | |
| } | |
| /* Modal transition */ | |
| .modal { | |
| transition: opacity 0.3s ease, transform 0.3s ease; | |
| } | |
| .modal-enter { | |
| opacity: 0; | |
| transform: scale(0.9); | |
| } | |
| .modal-enter-active { | |
| opacity: 1; | |
| transform: scale(1); | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen font-sans"> | |
| <div class="max-w-md mx-auto bg-white min-h-screen shadow-lg relative overflow-hidden"> | |
| <!-- Header --> | |
| <header class="bg-blue-500 text-white p-6 shadow-md"> | |
| <div class="flex justify-between items-center"> | |
| <h1 class="text-2xl font-bold">Alarm Clock</h1> | |
| <div class="flex space-x-4"> | |
| <button id="settings-btn" class="text-white"> | |
| <i class="fas fa-cog"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="mt-6 text-center"> | |
| <div class="text-5xl font-light" id="current-time">00:00</div> | |
| <div class="text-lg mt-2" id="current-date">Monday, January 1</div> | |
| </div> | |
| </header> | |
| <!-- Alarm List --> | |
| <div class="p-4"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-semibold text-gray-700">Your Alarms</h2> | |
| <button id="add-alarm-btn" class="bg-blue-500 hover:bg-blue-600 text-white rounded-full w-10 h-10 flex items-center justify-center shadow-md"> | |
| <i class="fas fa-plus"></i> | |
| </button> | |
| </div> | |
| <div id="alarm-list" class="alarm-list space-y-3 max-h-96 overflow-y-auto"> | |
| <!-- Alarms will be added here dynamically --> | |
| <div class="text-center py-10 text-gray-500" id="no-alarms-message"> | |
| <i class="fas fa-bell-slash text-4xl mb-2"></i> | |
| <p>No alarms set</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Add/Edit Alarm Modal --> | |
| <div id="alarm-modal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-sm p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold" id="modal-title">Add New Alarm</h3> | |
| <button id="close-modal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 mb-2">Time</label> | |
| <div class="flex justify-center"> | |
| <input type="time" id="alarm-time" class="border-2 border-gray-200 rounded-lg p-3 text-xl w-full text-center" required> | |
| </div> | |
| </div> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 mb-2">Label (optional)</label> | |
| <input type="text" id="alarm-label" placeholder="Wake up, Medicine, etc." class="border-2 border-gray-200 rounded-lg p-3 w-full"> | |
| </div> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 mb-2">Repeat</label> | |
| <div class="grid grid-cols-7 gap-2"> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="0">S</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="1">M</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="2">T</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="3">W</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="4">T</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="5">F</button> | |
| <button class="day-btn py-2 rounded-full border border-gray-200" data-day="6">S</button> | |
| </div> | |
| </div> | |
| <div class="flex space-x-3"> | |
| <button id="delete-alarm" class="hidden bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg flex-1"> | |
| Delete | |
| </button> | |
| <button id="save-alarm" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg flex-1"> | |
| Save | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Alarm Ringing Modal --> | |
| <div id="alarm-ringing-modal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-sm p-6 text-center"> | |
| <div class="mb-6"> | |
| <i class="fas fa-bell text-5xl text-yellow-500 mb-4"></i> | |
| <h3 class="text-2xl font-semibold" id="ringing-alarm-time">08:00</h3> | |
| <p class="text-gray-600" id="ringing-alarm-label">Wake up</p> | |
| </div> | |
| <button id="dismiss-alarm" class="bg-blue-500 hover:bg-blue-600 text-white py-3 px-6 rounded-lg w-full"> | |
| Dismiss | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // DOM Elements | |
| const currentTimeEl = document.getElementById('current-time'); | |
| const currentDateEl = document.getElementById('current-date'); | |
| const alarmListEl = document.getElementById('alarm-list'); | |
| const noAlarmsMessage = document.getElementById('no-alarms-message'); | |
| const addAlarmBtn = document.getElementById('add-alarm-btn'); | |
| const alarmModal = document.getElementById('alarm-modal'); | |
| const closeModalBtn = document.getElementById('close-modal'); | |
| const alarmTimeInput = document.getElementById('alarm-time'); | |
| const alarmLabelInput = document.getElementById('alarm-label'); | |
| const saveAlarmBtn = document.getElementById('save-alarm'); | |
| const deleteAlarmBtn = document.getElementById('delete-alarm'); | |
| const dayButtons = document.querySelectorAll('.day-btn'); | |
| const alarmRingingModal = document.getElementById('alarm-ringing-modal'); | |
| const dismissAlarmBtn = document.getElementById('dismiss-alarm'); | |
| const ringingAlarmTime = document.getElementById('ringing-alarm-time'); | |
| const ringingAlarmLabel = document.getElementById('ringing-alarm-label'); | |
| const modalTitle = document.getElementById('modal-title'); | |
| // State | |
| let alarms = JSON.parse(localStorage.getItem('alarms')) || []; | |
| let editingAlarmId = null; | |
| let selectedDays = []; | |
| let audioContext; | |
| let alarmSound; | |
| let activeAlarmId = null; | |
| // Initialize | |
| function init() { | |
| updateClock(); | |
| setInterval(updateClock, 1000); | |
| renderAlarms(); | |
| checkAlarms(); | |
| setInterval(checkAlarms, 1000); | |
| // Initialize Web Audio API | |
| try { | |
| audioContext = new (window.AudioContext || window.webkitAudioContext)(); | |
| } catch (e) { | |
| console.error('Web Audio API not supported'); | |
| } | |
| } | |
| // Update current time and date | |
| function updateClock() { | |
| const now = new Date(); | |
| const time = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| const date = now.toLocaleDateString([], { weekday: 'long', month: 'long', day: 'numeric' }); | |
| currentTimeEl.textContent = time; | |
| currentDateEl.textContent = date; | |
| } | |
| // Render alarms list | |
| function renderAlarms() { | |
| if (alarms.length === 0) { | |
| noAlarmsMessage.classList.remove('hidden'); | |
| alarmListEl.innerHTML = ''; | |
| alarmListEl.appendChild(noAlarmsMessage); | |
| return; | |
| } | |
| noAlarmsMessage.classList.add('hidden'); | |
| alarmListEl.innerHTML = ''; | |
| // Sort alarms by time | |
| alarms.sort((a, b) => { | |
| const timeA = a.time.split(':').map(Number); | |
| const timeB = b.time.split(':').map(Number); | |
| return timeA[0] - timeB[0] || timeA[1] - timeB[1]; | |
| }); | |
| alarms.forEach(alarm => { | |
| const alarmEl = document.createElement('div'); | |
| alarmEl.className = `bg-white p-4 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between ${alarm.id === activeAlarmId ? 'active-alarm border-blue-300' : ''}`; | |
| alarmEl.dataset.id = alarm.id; | |
| const timeParts = alarm.time.split(':'); | |
| const hours = parseInt(timeParts[0]); | |
| const minutes = timeParts[1]; | |
| const ampm = hours >= 12 ? 'PM' : 'AM'; | |
| const displayHours = hours % 12 || 12; | |
| const displayTime = `${displayHours}:${minutes} ${ampm}`; | |
| alarmEl.innerHTML = ` | |
| <div class="flex items-center"> | |
| <div class="mr-4"> | |
| <div class="text-2xl font-semibold">${displayTime}</div> | |
| <div class="text-sm text-gray-500">${alarm.label || 'Alarm'}</div> | |
| ${alarm.days && alarm.days.length > 0 ? | |
| `<div class="text-xs text-gray-400 mt-1">${getDaysText(alarm.days)}</div>` : ''} | |
| </div> | |
| </div> | |
| <label class="relative inline-flex items-center cursor-pointer"> | |
| <input type="checkbox" class="sr-only peer" ${alarm.active ? 'checked' : ''}> | |
| <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-500"></div> | |
| </label> | |
| `; | |
| const toggle = alarmEl.querySelector('input[type="checkbox"]'); | |
| toggle.addEventListener('change', () => toggleAlarm(alarm.id)); | |
| alarmEl.addEventListener('click', (e) => { | |
| if (!e.target.closest('label')) { | |
| editAlarm(alarm.id); | |
| } | |
| }); | |
| alarmListEl.appendChild(alarmEl); | |
| }); | |
| } | |
| // Get days text for display | |
| function getDaysText(days) { | |
| if (days.length === 7) return 'Every day'; | |
| if (days.length === 5 && !days.includes(0) && !days.includes(6)) return 'Weekdays'; | |
| if (days.length === 2 && days.includes(0) && days.includes(6)) return 'Weekends'; | |
| const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; | |
| return days.map(day => dayNames[day]).join(', '); | |
| } | |
| // Toggle alarm active state | |
| function toggleAlarm(id) { | |
| alarms = alarms.map(alarm => { | |
| if (alarm.id === id) { | |
| return { ...alarm, active: !alarm.active }; | |
| } | |
| return alarm; | |
| }); | |
| saveAlarms(); | |
| renderAlarms(); | |
| } | |
| // Open modal to add new alarm | |
| addAlarmBtn.addEventListener('click', () => { | |
| editingAlarmId = null; | |
| modalTitle.textContent = 'Add New Alarm'; | |
| alarmTimeInput.value = ''; | |
| alarmLabelInput.value = ''; | |
| selectedDays = []; | |
| resetDayButtons(); | |
| deleteAlarmBtn.classList.add('hidden'); | |
| alarmModal.classList.remove('hidden'); | |
| }); | |
| // Edit existing alarm | |
| function editAlarm(id) { | |
| const alarm = alarms.find(a => a.id === id); | |
| if (!alarm) return; | |
| editingAlarmId = id; | |
| modalTitle.textContent = 'Edit Alarm'; | |
| alarmTimeInput.value = alarm.time; | |
| alarmLabelInput.value = alarm.label || ''; | |
| selectedDays = alarm.days || []; | |
| // Highlight selected days | |
| resetDayButtons(); | |
| selectedDays.forEach(day => { | |
| const btn = document.querySelector(`.day-btn[data-day="${day}"]`); | |
| if (btn) { | |
| btn.classList.add('bg-blue-500', 'text-white', 'border-blue-500'); | |
| } | |
| }); | |
| deleteAlarmBtn.classList.remove('hidden'); | |
| alarmModal.classList.remove('hidden'); | |
| } | |
| // Close modal | |
| closeModalBtn.addEventListener('click', () => { | |
| alarmModal.classList.add('hidden'); | |
| }); | |
| // Day selection | |
| dayButtons.forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const day = parseInt(btn.dataset.day); | |
| const index = selectedDays.indexOf(day); | |
| if (index === -1) { | |
| selectedDays.push(day); | |
| btn.classList.add('bg-blue-500', 'text-white', 'border-blue-500'); | |
| } else { | |
| selectedDays.splice(index, 1); | |
| btn.classList.remove('bg-blue-500', 'text-white', 'border-blue-500'); | |
| } | |
| // Sort days for consistency | |
| selectedDays.sort((a, b) => a - b); | |
| }); | |
| }); | |
| // Reset day buttons | |
| function resetDayButtons() { | |
| dayButtons.forEach(btn => { | |
| btn.classList.remove('bg-blue-500', 'text-white', 'border-blue-500'); | |
| }); | |
| } | |
| // Save alarm | |
| saveAlarmBtn.addEventListener('click', () => { | |
| const time = alarmTimeInput.value; | |
| const label = alarmLabelInput.value.trim(); | |
| if (!time) { | |
| alert('Please set a time for the alarm'); | |
| return; | |
| } | |
| if (editingAlarmId) { | |
| // Update existing alarm | |
| alarms = alarms.map(alarm => { | |
| if (alarm.id === editingAlarmId) { | |
| return { | |
| ...alarm, | |
| time, | |
| label: label || null, | |
| days: selectedDays.length > 0 ? selectedDays : null | |
| }; | |
| } | |
| return alarm; | |
| }); | |
| } else { | |
| // Add new alarm | |
| const newAlarm = { | |
| id: Date.now().toString(), | |
| time, | |
| label: label || null, | |
| days: selectedDays.length > 0 ? selectedDays : null, | |
| active: true | |
| }; | |
| alarms.push(newAlarm); | |
| } | |
| saveAlarms(); | |
| renderAlarms(); | |
| alarmModal.classList.add('hidden'); | |
| }); | |
| // Delete alarm | |
| deleteAlarmBtn.addEventListener('click', () => { | |
| if (editingAlarmId) { | |
| alarms = alarms.filter(alarm => alarm.id !== editingAlarmId); | |
| saveAlarms(); | |
| renderAlarms(); | |
| alarmModal.classList.add('hidden'); | |
| } | |
| }); | |
| // Save alarms to localStorage | |
| function saveAlarms() { | |
| localStorage.setItem('alarms', JSON.stringify(alarms)); | |
| } | |
| // Check if any alarms should trigger | |
| function checkAlarms() { | |
| const now = new Date(); | |
| const currentHours = now.getHours(); | |
| const currentMinutes = now.getMinutes(); | |
| const currentDay = now.getDay(); // 0 (Sun) to 6 (Sat) | |
| alarms.forEach(alarm => { | |
| if (!alarm.active) return; | |
| const [alarmHours, alarmMinutes] = alarm.time.split(':').map(Number); | |
| // Check if time matches | |
| if (currentHours === alarmHours && currentMinutes === alarmMinutes) { | |
| // Check if this is a repeating alarm and today is one of the selected days | |
| if (alarm.days && alarm.days.length > 0) { | |
| if (alarm.days.includes(currentDay)) { | |
| triggerAlarm(alarm.id); | |
| } | |
| } else { | |
| // One-time alarm - check if it hasn't been triggered today | |
| const lastTriggered = alarm.lastTriggered ? new Date(alarm.lastTriggered) : null; | |
| if (!lastTriggered || lastTriggered.getDate() !== now.getDate()) { | |
| triggerAlarm(alarm.id); | |
| // Update last triggered time | |
| alarms = alarms.map(a => { | |
| if (a.id === alarm.id) { | |
| return { ...a, lastTriggered: now.toISOString() }; | |
| } | |
| return a; | |
| }); | |
| saveAlarms(); | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| // Trigger alarm | |
| function triggerAlarm(id) { | |
| // Don't trigger if already ringing | |
| if (activeAlarmId === id) return; | |
| const alarm = alarms.find(a => a.id === id); | |
| if (!alarm) return; | |
| activeAlarmId = id; | |
| ringingAlarmTime.textContent = alarm.time; | |
| ringingAlarmLabel.textContent = alarm.label || 'Alarm'; | |
| alarmRingingModal.classList.remove('hidden'); | |
| // Play alarm sound | |
| playAlarmSound(); | |
| // Update UI | |
| renderAlarms(); | |
| } | |
| // Play alarm sound | |
| function playAlarmSound() { | |
| if (!audioContext) return; | |
| // Stop any existing sound | |
| if (alarmSound) { | |
| alarmSound.stop(); | |
| } | |
| // Create oscillator | |
| const oscillator = audioContext.createOscillator(); | |
| const gainNode = audioContext.createGain(); | |
| oscillator.type = 'sine'; | |
| oscillator.frequency.value = 800; | |
| gainNode.gain.value = 0.3; | |
| oscillator.connect(gainNode); | |
| gainNode.connect(audioContext.destination); | |
| // Create pulsing effect | |
| let pulseCount = 0; | |
| const pulseInterval = setInterval(() => { | |
| pulseCount++; | |
| if (pulseCount % 2 === 0) { | |
| oscillator.frequency.value = 1000; | |
| } else { | |
| oscillator.frequency.value = 800; | |
| } | |
| }, 500); | |
| oscillator.start(); | |
| alarmSound = { | |
| oscillator, | |
| gainNode, | |
| stop: () => { | |
| clearInterval(pulseInterval); | |
| gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.5); | |
| setTimeout(() => { | |
| oscillator.stop(); | |
| }, 500); | |
| } | |
| }; | |
| } | |
| // Dismiss alarm | |
| dismissAlarmBtn.addEventListener('click', () => { | |
| if (alarmSound) { | |
| alarmSound.stop(); | |
| alarmSound = null; | |
| } | |
| activeAlarmId = null; | |
| alarmRingingModal.classList.add('hidden'); | |
| renderAlarms(); | |
| }); | |
| // Initialize the app | |
| init(); | |
| </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=miwf/e" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |