Add 3 files
Browse files- README.md +6 -4
- index.html +525 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: e
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: pink
|
| 5 |
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,525 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Alarm Clock App</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
/* Custom scrollbar */
|
| 11 |
+
.alarm-list::-webkit-scrollbar {
|
| 12 |
+
width: 6px;
|
| 13 |
+
}
|
| 14 |
+
.alarm-list::-webkit-scrollbar-track {
|
| 15 |
+
background: #f1f1f1;
|
| 16 |
+
border-radius: 10px;
|
| 17 |
+
}
|
| 18 |
+
.alarm-list::-webkit-scrollbar-thumb {
|
| 19 |
+
background: #888;
|
| 20 |
+
border-radius: 10px;
|
| 21 |
+
}
|
| 22 |
+
.alarm-list::-webkit-scrollbar-thumb:hover {
|
| 23 |
+
background: #555;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/* Animation for active alarm */
|
| 27 |
+
@keyframes pulse {
|
| 28 |
+
0% { transform: scale(1); }
|
| 29 |
+
50% { transform: scale(1.05); }
|
| 30 |
+
100% { transform: scale(1); }
|
| 31 |
+
}
|
| 32 |
+
.active-alarm {
|
| 33 |
+
animation: pulse 1.5s infinite;
|
| 34 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/* Modal transition */
|
| 38 |
+
.modal {
|
| 39 |
+
transition: opacity 0.3s ease, transform 0.3s ease;
|
| 40 |
+
}
|
| 41 |
+
.modal-enter {
|
| 42 |
+
opacity: 0;
|
| 43 |
+
transform: scale(0.9);
|
| 44 |
+
}
|
| 45 |
+
.modal-enter-active {
|
| 46 |
+
opacity: 1;
|
| 47 |
+
transform: scale(1);
|
| 48 |
+
}
|
| 49 |
+
</style>
|
| 50 |
+
</head>
|
| 51 |
+
<body class="bg-gray-100 min-h-screen font-sans">
|
| 52 |
+
<div class="max-w-md mx-auto bg-white min-h-screen shadow-lg relative overflow-hidden">
|
| 53 |
+
<!-- Header -->
|
| 54 |
+
<header class="bg-blue-500 text-white p-6 shadow-md">
|
| 55 |
+
<div class="flex justify-between items-center">
|
| 56 |
+
<h1 class="text-2xl font-bold">Alarm Clock</h1>
|
| 57 |
+
<div class="flex space-x-4">
|
| 58 |
+
<button id="settings-btn" class="text-white">
|
| 59 |
+
<i class="fas fa-cog"></i>
|
| 60 |
+
</button>
|
| 61 |
+
</div>
|
| 62 |
+
</div>
|
| 63 |
+
<div class="mt-6 text-center">
|
| 64 |
+
<div class="text-5xl font-light" id="current-time">00:00</div>
|
| 65 |
+
<div class="text-lg mt-2" id="current-date">Monday, January 1</div>
|
| 66 |
+
</div>
|
| 67 |
+
</header>
|
| 68 |
+
|
| 69 |
+
<!-- Alarm List -->
|
| 70 |
+
<div class="p-4">
|
| 71 |
+
<div class="flex justify-between items-center mb-4">
|
| 72 |
+
<h2 class="text-xl font-semibold text-gray-700">Your Alarms</h2>
|
| 73 |
+
<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">
|
| 74 |
+
<i class="fas fa-plus"></i>
|
| 75 |
+
</button>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
<div id="alarm-list" class="alarm-list space-y-3 max-h-96 overflow-y-auto">
|
| 79 |
+
<!-- Alarms will be added here dynamically -->
|
| 80 |
+
<div class="text-center py-10 text-gray-500" id="no-alarms-message">
|
| 81 |
+
<i class="fas fa-bell-slash text-4xl mb-2"></i>
|
| 82 |
+
<p>No alarms set</p>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<!-- Add/Edit Alarm Modal -->
|
| 88 |
+
<div id="alarm-modal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden">
|
| 89 |
+
<div class="bg-white rounded-xl shadow-xl w-full max-w-sm p-6">
|
| 90 |
+
<div class="flex justify-between items-center mb-4">
|
| 91 |
+
<h3 class="text-xl font-semibold" id="modal-title">Add New Alarm</h3>
|
| 92 |
+
<button id="close-modal" class="text-gray-500 hover:text-gray-700">
|
| 93 |
+
<i class="fas fa-times"></i>
|
| 94 |
+
</button>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<div class="mb-6">
|
| 98 |
+
<label class="block text-gray-700 mb-2">Time</label>
|
| 99 |
+
<div class="flex justify-center">
|
| 100 |
+
<input type="time" id="alarm-time" class="border-2 border-gray-200 rounded-lg p-3 text-xl w-full text-center" required>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
|
| 104 |
+
<div class="mb-6">
|
| 105 |
+
<label class="block text-gray-700 mb-2">Label (optional)</label>
|
| 106 |
+
<input type="text" id="alarm-label" placeholder="Wake up, Medicine, etc." class="border-2 border-gray-200 rounded-lg p-3 w-full">
|
| 107 |
+
</div>
|
| 108 |
+
|
| 109 |
+
<div class="mb-6">
|
| 110 |
+
<label class="block text-gray-700 mb-2">Repeat</label>
|
| 111 |
+
<div class="grid grid-cols-7 gap-2">
|
| 112 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="0">S</button>
|
| 113 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="1">M</button>
|
| 114 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="2">T</button>
|
| 115 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="3">W</button>
|
| 116 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="4">T</button>
|
| 117 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="5">F</button>
|
| 118 |
+
<button class="day-btn py-2 rounded-full border border-gray-200" data-day="6">S</button>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="flex space-x-3">
|
| 123 |
+
<button id="delete-alarm" class="hidden bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg flex-1">
|
| 124 |
+
Delete
|
| 125 |
+
</button>
|
| 126 |
+
<button id="save-alarm" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg flex-1">
|
| 127 |
+
Save
|
| 128 |
+
</button>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<!-- Alarm Ringing Modal -->
|
| 134 |
+
<div id="alarm-ringing-modal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden">
|
| 135 |
+
<div class="bg-white rounded-xl shadow-xl w-full max-w-sm p-6 text-center">
|
| 136 |
+
<div class="mb-6">
|
| 137 |
+
<i class="fas fa-bell text-5xl text-yellow-500 mb-4"></i>
|
| 138 |
+
<h3 class="text-2xl font-semibold" id="ringing-alarm-time">08:00</h3>
|
| 139 |
+
<p class="text-gray-600" id="ringing-alarm-label">Wake up</p>
|
| 140 |
+
</div>
|
| 141 |
+
<button id="dismiss-alarm" class="bg-blue-500 hover:bg-blue-600 text-white py-3 px-6 rounded-lg w-full">
|
| 142 |
+
Dismiss
|
| 143 |
+
</button>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
|
| 148 |
+
<script>
|
| 149 |
+
// DOM Elements
|
| 150 |
+
const currentTimeEl = document.getElementById('current-time');
|
| 151 |
+
const currentDateEl = document.getElementById('current-date');
|
| 152 |
+
const alarmListEl = document.getElementById('alarm-list');
|
| 153 |
+
const noAlarmsMessage = document.getElementById('no-alarms-message');
|
| 154 |
+
const addAlarmBtn = document.getElementById('add-alarm-btn');
|
| 155 |
+
const alarmModal = document.getElementById('alarm-modal');
|
| 156 |
+
const closeModalBtn = document.getElementById('close-modal');
|
| 157 |
+
const alarmTimeInput = document.getElementById('alarm-time');
|
| 158 |
+
const alarmLabelInput = document.getElementById('alarm-label');
|
| 159 |
+
const saveAlarmBtn = document.getElementById('save-alarm');
|
| 160 |
+
const deleteAlarmBtn = document.getElementById('delete-alarm');
|
| 161 |
+
const dayButtons = document.querySelectorAll('.day-btn');
|
| 162 |
+
const alarmRingingModal = document.getElementById('alarm-ringing-modal');
|
| 163 |
+
const dismissAlarmBtn = document.getElementById('dismiss-alarm');
|
| 164 |
+
const ringingAlarmTime = document.getElementById('ringing-alarm-time');
|
| 165 |
+
const ringingAlarmLabel = document.getElementById('ringing-alarm-label');
|
| 166 |
+
const modalTitle = document.getElementById('modal-title');
|
| 167 |
+
|
| 168 |
+
// State
|
| 169 |
+
let alarms = JSON.parse(localStorage.getItem('alarms')) || [];
|
| 170 |
+
let editingAlarmId = null;
|
| 171 |
+
let selectedDays = [];
|
| 172 |
+
let audioContext;
|
| 173 |
+
let alarmSound;
|
| 174 |
+
let activeAlarmId = null;
|
| 175 |
+
|
| 176 |
+
// Initialize
|
| 177 |
+
function init() {
|
| 178 |
+
updateClock();
|
| 179 |
+
setInterval(updateClock, 1000);
|
| 180 |
+
renderAlarms();
|
| 181 |
+
checkAlarms();
|
| 182 |
+
setInterval(checkAlarms, 1000);
|
| 183 |
+
|
| 184 |
+
// Initialize Web Audio API
|
| 185 |
+
try {
|
| 186 |
+
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 187 |
+
} catch (e) {
|
| 188 |
+
console.error('Web Audio API not supported');
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// Update current time and date
|
| 193 |
+
function updateClock() {
|
| 194 |
+
const now = new Date();
|
| 195 |
+
const time = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 196 |
+
const date = now.toLocaleDateString([], { weekday: 'long', month: 'long', day: 'numeric' });
|
| 197 |
+
|
| 198 |
+
currentTimeEl.textContent = time;
|
| 199 |
+
currentDateEl.textContent = date;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
// Render alarms list
|
| 203 |
+
function renderAlarms() {
|
| 204 |
+
if (alarms.length === 0) {
|
| 205 |
+
noAlarmsMessage.classList.remove('hidden');
|
| 206 |
+
alarmListEl.innerHTML = '';
|
| 207 |
+
alarmListEl.appendChild(noAlarmsMessage);
|
| 208 |
+
return;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
noAlarmsMessage.classList.add('hidden');
|
| 212 |
+
alarmListEl.innerHTML = '';
|
| 213 |
+
|
| 214 |
+
// Sort alarms by time
|
| 215 |
+
alarms.sort((a, b) => {
|
| 216 |
+
const timeA = a.time.split(':').map(Number);
|
| 217 |
+
const timeB = b.time.split(':').map(Number);
|
| 218 |
+
return timeA[0] - timeB[0] || timeA[1] - timeB[1];
|
| 219 |
+
});
|
| 220 |
+
|
| 221 |
+
alarms.forEach(alarm => {
|
| 222 |
+
const alarmEl = document.createElement('div');
|
| 223 |
+
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' : ''}`;
|
| 224 |
+
alarmEl.dataset.id = alarm.id;
|
| 225 |
+
|
| 226 |
+
const timeParts = alarm.time.split(':');
|
| 227 |
+
const hours = parseInt(timeParts[0]);
|
| 228 |
+
const minutes = timeParts[1];
|
| 229 |
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
| 230 |
+
const displayHours = hours % 12 || 12;
|
| 231 |
+
const displayTime = `${displayHours}:${minutes} ${ampm}`;
|
| 232 |
+
|
| 233 |
+
alarmEl.innerHTML = `
|
| 234 |
+
<div class="flex items-center">
|
| 235 |
+
<div class="mr-4">
|
| 236 |
+
<div class="text-2xl font-semibold">${displayTime}</div>
|
| 237 |
+
<div class="text-sm text-gray-500">${alarm.label || 'Alarm'}</div>
|
| 238 |
+
${alarm.days && alarm.days.length > 0 ?
|
| 239 |
+
`<div class="text-xs text-gray-400 mt-1">${getDaysText(alarm.days)}</div>` : ''}
|
| 240 |
+
</div>
|
| 241 |
+
</div>
|
| 242 |
+
<label class="relative inline-flex items-center cursor-pointer">
|
| 243 |
+
<input type="checkbox" class="sr-only peer" ${alarm.active ? 'checked' : ''}>
|
| 244 |
+
<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>
|
| 245 |
+
</label>
|
| 246 |
+
`;
|
| 247 |
+
|
| 248 |
+
const toggle = alarmEl.querySelector('input[type="checkbox"]');
|
| 249 |
+
toggle.addEventListener('change', () => toggleAlarm(alarm.id));
|
| 250 |
+
|
| 251 |
+
alarmEl.addEventListener('click', (e) => {
|
| 252 |
+
if (!e.target.closest('label')) {
|
| 253 |
+
editAlarm(alarm.id);
|
| 254 |
+
}
|
| 255 |
+
});
|
| 256 |
+
|
| 257 |
+
alarmListEl.appendChild(alarmEl);
|
| 258 |
+
});
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// Get days text for display
|
| 262 |
+
function getDaysText(days) {
|
| 263 |
+
if (days.length === 7) return 'Every day';
|
| 264 |
+
if (days.length === 5 && !days.includes(0) && !days.includes(6)) return 'Weekdays';
|
| 265 |
+
if (days.length === 2 && days.includes(0) && days.includes(6)) return 'Weekends';
|
| 266 |
+
|
| 267 |
+
const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
| 268 |
+
return days.map(day => dayNames[day]).join(', ');
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
// Toggle alarm active state
|
| 272 |
+
function toggleAlarm(id) {
|
| 273 |
+
alarms = alarms.map(alarm => {
|
| 274 |
+
if (alarm.id === id) {
|
| 275 |
+
return { ...alarm, active: !alarm.active };
|
| 276 |
+
}
|
| 277 |
+
return alarm;
|
| 278 |
+
});
|
| 279 |
+
saveAlarms();
|
| 280 |
+
renderAlarms();
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// Open modal to add new alarm
|
| 284 |
+
addAlarmBtn.addEventListener('click', () => {
|
| 285 |
+
editingAlarmId = null;
|
| 286 |
+
modalTitle.textContent = 'Add New Alarm';
|
| 287 |
+
alarmTimeInput.value = '';
|
| 288 |
+
alarmLabelInput.value = '';
|
| 289 |
+
selectedDays = [];
|
| 290 |
+
resetDayButtons();
|
| 291 |
+
deleteAlarmBtn.classList.add('hidden');
|
| 292 |
+
alarmModal.classList.remove('hidden');
|
| 293 |
+
});
|
| 294 |
+
|
| 295 |
+
// Edit existing alarm
|
| 296 |
+
function editAlarm(id) {
|
| 297 |
+
const alarm = alarms.find(a => a.id === id);
|
| 298 |
+
if (!alarm) return;
|
| 299 |
+
|
| 300 |
+
editingAlarmId = id;
|
| 301 |
+
modalTitle.textContent = 'Edit Alarm';
|
| 302 |
+
alarmTimeInput.value = alarm.time;
|
| 303 |
+
alarmLabelInput.value = alarm.label || '';
|
| 304 |
+
selectedDays = alarm.days || [];
|
| 305 |
+
|
| 306 |
+
// Highlight selected days
|
| 307 |
+
resetDayButtons();
|
| 308 |
+
selectedDays.forEach(day => {
|
| 309 |
+
const btn = document.querySelector(`.day-btn[data-day="${day}"]`);
|
| 310 |
+
if (btn) {
|
| 311 |
+
btn.classList.add('bg-blue-500', 'text-white', 'border-blue-500');
|
| 312 |
+
}
|
| 313 |
+
});
|
| 314 |
+
|
| 315 |
+
deleteAlarmBtn.classList.remove('hidden');
|
| 316 |
+
alarmModal.classList.remove('hidden');
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// Close modal
|
| 320 |
+
closeModalBtn.addEventListener('click', () => {
|
| 321 |
+
alarmModal.classList.add('hidden');
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
// Day selection
|
| 325 |
+
dayButtons.forEach(btn => {
|
| 326 |
+
btn.addEventListener('click', () => {
|
| 327 |
+
const day = parseInt(btn.dataset.day);
|
| 328 |
+
const index = selectedDays.indexOf(day);
|
| 329 |
+
|
| 330 |
+
if (index === -1) {
|
| 331 |
+
selectedDays.push(day);
|
| 332 |
+
btn.classList.add('bg-blue-500', 'text-white', 'border-blue-500');
|
| 333 |
+
} else {
|
| 334 |
+
selectedDays.splice(index, 1);
|
| 335 |
+
btn.classList.remove('bg-blue-500', 'text-white', 'border-blue-500');
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
// Sort days for consistency
|
| 339 |
+
selectedDays.sort((a, b) => a - b);
|
| 340 |
+
});
|
| 341 |
+
});
|
| 342 |
+
|
| 343 |
+
// Reset day buttons
|
| 344 |
+
function resetDayButtons() {
|
| 345 |
+
dayButtons.forEach(btn => {
|
| 346 |
+
btn.classList.remove('bg-blue-500', 'text-white', 'border-blue-500');
|
| 347 |
+
});
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
// Save alarm
|
| 351 |
+
saveAlarmBtn.addEventListener('click', () => {
|
| 352 |
+
const time = alarmTimeInput.value;
|
| 353 |
+
const label = alarmLabelInput.value.trim();
|
| 354 |
+
|
| 355 |
+
if (!time) {
|
| 356 |
+
alert('Please set a time for the alarm');
|
| 357 |
+
return;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
if (editingAlarmId) {
|
| 361 |
+
// Update existing alarm
|
| 362 |
+
alarms = alarms.map(alarm => {
|
| 363 |
+
if (alarm.id === editingAlarmId) {
|
| 364 |
+
return {
|
| 365 |
+
...alarm,
|
| 366 |
+
time,
|
| 367 |
+
label: label || null,
|
| 368 |
+
days: selectedDays.length > 0 ? selectedDays : null
|
| 369 |
+
};
|
| 370 |
+
}
|
| 371 |
+
return alarm;
|
| 372 |
+
});
|
| 373 |
+
} else {
|
| 374 |
+
// Add new alarm
|
| 375 |
+
const newAlarm = {
|
| 376 |
+
id: Date.now().toString(),
|
| 377 |
+
time,
|
| 378 |
+
label: label || null,
|
| 379 |
+
days: selectedDays.length > 0 ? selectedDays : null,
|
| 380 |
+
active: true
|
| 381 |
+
};
|
| 382 |
+
alarms.push(newAlarm);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
saveAlarms();
|
| 386 |
+
renderAlarms();
|
| 387 |
+
alarmModal.classList.add('hidden');
|
| 388 |
+
});
|
| 389 |
+
|
| 390 |
+
// Delete alarm
|
| 391 |
+
deleteAlarmBtn.addEventListener('click', () => {
|
| 392 |
+
if (editingAlarmId) {
|
| 393 |
+
alarms = alarms.filter(alarm => alarm.id !== editingAlarmId);
|
| 394 |
+
saveAlarms();
|
| 395 |
+
renderAlarms();
|
| 396 |
+
alarmModal.classList.add('hidden');
|
| 397 |
+
}
|
| 398 |
+
});
|
| 399 |
+
|
| 400 |
+
// Save alarms to localStorage
|
| 401 |
+
function saveAlarms() {
|
| 402 |
+
localStorage.setItem('alarms', JSON.stringify(alarms));
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
// Check if any alarms should trigger
|
| 406 |
+
function checkAlarms() {
|
| 407 |
+
const now = new Date();
|
| 408 |
+
const currentHours = now.getHours();
|
| 409 |
+
const currentMinutes = now.getMinutes();
|
| 410 |
+
const currentDay = now.getDay(); // 0 (Sun) to 6 (Sat)
|
| 411 |
+
|
| 412 |
+
alarms.forEach(alarm => {
|
| 413 |
+
if (!alarm.active) return;
|
| 414 |
+
|
| 415 |
+
const [alarmHours, alarmMinutes] = alarm.time.split(':').map(Number);
|
| 416 |
+
|
| 417 |
+
// Check if time matches
|
| 418 |
+
if (currentHours === alarmHours && currentMinutes === alarmMinutes) {
|
| 419 |
+
// Check if this is a repeating alarm and today is one of the selected days
|
| 420 |
+
if (alarm.days && alarm.days.length > 0) {
|
| 421 |
+
if (alarm.days.includes(currentDay)) {
|
| 422 |
+
triggerAlarm(alarm.id);
|
| 423 |
+
}
|
| 424 |
+
} else {
|
| 425 |
+
// One-time alarm - check if it hasn't been triggered today
|
| 426 |
+
const lastTriggered = alarm.lastTriggered ? new Date(alarm.lastTriggered) : null;
|
| 427 |
+
if (!lastTriggered || lastTriggered.getDate() !== now.getDate()) {
|
| 428 |
+
triggerAlarm(alarm.id);
|
| 429 |
+
|
| 430 |
+
// Update last triggered time
|
| 431 |
+
alarms = alarms.map(a => {
|
| 432 |
+
if (a.id === alarm.id) {
|
| 433 |
+
return { ...a, lastTriggered: now.toISOString() };
|
| 434 |
+
}
|
| 435 |
+
return a;
|
| 436 |
+
});
|
| 437 |
+
saveAlarms();
|
| 438 |
+
}
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
});
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
// Trigger alarm
|
| 445 |
+
function triggerAlarm(id) {
|
| 446 |
+
// Don't trigger if already ringing
|
| 447 |
+
if (activeAlarmId === id) return;
|
| 448 |
+
|
| 449 |
+
const alarm = alarms.find(a => a.id === id);
|
| 450 |
+
if (!alarm) return;
|
| 451 |
+
|
| 452 |
+
activeAlarmId = id;
|
| 453 |
+
ringingAlarmTime.textContent = alarm.time;
|
| 454 |
+
ringingAlarmLabel.textContent = alarm.label || 'Alarm';
|
| 455 |
+
alarmRingingModal.classList.remove('hidden');
|
| 456 |
+
|
| 457 |
+
// Play alarm sound
|
| 458 |
+
playAlarmSound();
|
| 459 |
+
|
| 460 |
+
// Update UI
|
| 461 |
+
renderAlarms();
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
// Play alarm sound
|
| 465 |
+
function playAlarmSound() {
|
| 466 |
+
if (!audioContext) return;
|
| 467 |
+
|
| 468 |
+
// Stop any existing sound
|
| 469 |
+
if (alarmSound) {
|
| 470 |
+
alarmSound.stop();
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
// Create oscillator
|
| 474 |
+
const oscillator = audioContext.createOscillator();
|
| 475 |
+
const gainNode = audioContext.createGain();
|
| 476 |
+
|
| 477 |
+
oscillator.type = 'sine';
|
| 478 |
+
oscillator.frequency.value = 800;
|
| 479 |
+
gainNode.gain.value = 0.3;
|
| 480 |
+
|
| 481 |
+
oscillator.connect(gainNode);
|
| 482 |
+
gainNode.connect(audioContext.destination);
|
| 483 |
+
|
| 484 |
+
// Create pulsing effect
|
| 485 |
+
let pulseCount = 0;
|
| 486 |
+
const pulseInterval = setInterval(() => {
|
| 487 |
+
pulseCount++;
|
| 488 |
+
if (pulseCount % 2 === 0) {
|
| 489 |
+
oscillator.frequency.value = 1000;
|
| 490 |
+
} else {
|
| 491 |
+
oscillator.frequency.value = 800;
|
| 492 |
+
}
|
| 493 |
+
}, 500);
|
| 494 |
+
|
| 495 |
+
oscillator.start();
|
| 496 |
+
alarmSound = {
|
| 497 |
+
oscillator,
|
| 498 |
+
gainNode,
|
| 499 |
+
stop: () => {
|
| 500 |
+
clearInterval(pulseInterval);
|
| 501 |
+
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.5);
|
| 502 |
+
setTimeout(() => {
|
| 503 |
+
oscillator.stop();
|
| 504 |
+
}, 500);
|
| 505 |
+
}
|
| 506 |
+
};
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
// Dismiss alarm
|
| 510 |
+
dismissAlarmBtn.addEventListener('click', () => {
|
| 511 |
+
if (alarmSound) {
|
| 512 |
+
alarmSound.stop();
|
| 513 |
+
alarmSound = null;
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
activeAlarmId = null;
|
| 517 |
+
alarmRingingModal.classList.add('hidden');
|
| 518 |
+
renderAlarms();
|
| 519 |
+
});
|
| 520 |
+
|
| 521 |
+
// Initialize the app
|
| 522 |
+
init();
|
| 523 |
+
</script>
|
| 524 |
+
<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>
|
| 525 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
A mobile alarm app with the ability to add alarms
|