For alarms to work even when the browser is in the background, please enable notifications.
+ +Alarm Clock
-Time to write your notes.
diff --git a/assets/js/main.js b/assets/js/main.js index 2b7ce8a..70599c1 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,102 +1,176 @@ document.addEventListener('DOMContentLoaded', function () { - const alarmForm = document.getElementById('alarm-form'); - const alarmsList = document.getElementById('alarms-list'); - const alarmModal = new bootstrap.Modal(document.getElementById('alarm-modal')); - const alarmSound = document.getElementById('alarm-sound'); - const dismissAlarmBtn = document.getElementById('dismiss-alarm'); + const alarmForm = document.getElementById('createAlarmForm'); + const alarmsList = document.getElementById('alarmList'); + const alarmModal = new bootstrap.Modal(document.getElementById('alarmModal')); + const alarmSound = document.getElementById('alarmSound'); + const dismissAlarmBtn = document.getElementById('dismissAlarmBtn'); const enableNotificationsBtn = document.getElementById('enable-notifications'); + const notificationPermissionCard = document.getElementById('notification-permission-card'); - let notificationPermission = false; + // --- Notification Permission Handling --- - // Request notification permission + function handleNotificationPermission(permission) { + if (permission === 'granted') { + if (notificationPermissionCard) { + notificationPermissionCard.style.display = 'none'; + } + } else if (permission === 'denied') { + if (notificationPermissionCard) { + notificationPermissionCard.innerHTML = '
For alarms to work even when the browser is in the background, please enable notifications.
+ +Time to write your notes.