Download index.html from seannyboy/____: direct link, hf CLI and curl.
- Browser
- Download file 40.2 kB
-
https://huggingface.co/spaces/seannyboy/____/resolve/main/index.html
- Command line
-
hf download hf://spaces/seannyboy/____/index.html
-
curl -L -o index.html https://huggingface.co/spaces/seannyboy/____/resolve/main/index.html
40.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Advanced Calendar App</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/lhttps://huggingface.co/spaces/calendar-pribs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| /* Custom scrollbar */ | |
| ::-webkit-scrollbar { | |
| width: 8px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: #f1f1f1; | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: #888; | |
| border-radius: 4px; | |
| } | |
| ::-webkit-scrollbar-thumb:hover { | |
| background: #555; | |
| } | |
| /* Animation for notifications */ | |
| @keyframes slideIn { | |
| from { transform: translateX(100%); } | |
| to { transform: translateX(0); } | |
| } | |
| @keyframes fadeOut { | |
| from { opacity: 1; } | |
| to { opacity: 0; } | |
| } | |
| .notification { | |
| animation: slideIn 0.3s ease-out, fadeOut 0.5s ease-out 4.5s forwards; | |
| } | |
| /* Custom checkbox */ | |
| .custom-checkbox { | |
| appearance: none; | |
| -webkit-appearance: none; | |
| width: 20px; | |
| height: 20px; | |
| border: 2px solid #3b82f6; | |
| border-radius: 4px; | |
| outline: none; | |
| cursor: pointer; | |
| position: relative; | |
| } | |
| .custom-checkbox:checked { | |
| background-color: #3b82f6; | |
| } | |
| .custom-checkbox:checked::after { | |
| content: '\2713'; | |
| position: absolute; | |
| color: white; | |
| font-size: 14px; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| } | |
| /* Event dot indicator */ | |
| .event-dot { | |
| width: 8px; | |
| height: 8px; | |
| border-radius: 50%; | |
| display: inline-block; | |
| margin-right: 2px; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="flex flex-col md:flex-row justify-between items-center mb-8"> | |
| <h1 class="text-3xl font-bold text-indigo-700 mb-4 md:mb-0">Calendar Pro+</h1> | |
| <div class="flex items-center space-x-4"> | |
| <button id="today-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition"> | |
| Today | |
| </button> | |
| <div class="flex items-center"> | |
| <button id="prev-month" class="p-2 rounded-full hover:bg-gray-200 transition"> | |
| <i class="fas fa-chevron-left text-gray-700"></i> | |
| </button> | |
| <h2 id="current-month-year" class="mx-4 text-xl font-semibold text-gray-800">June 2023</h2> | |
| <button id="next-month" class="p-2 rounded-full hover:bg-gray-200 transition"> | |
| <i class="fas fa-chevron-right text-gray-700"></i> | |
| </button> | |
| </div> | |
| <div class="relative"> | |
| <select id="year-select" class="appearance-none bg-white border border-gray-300 rounded-lg px-4 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-indigo-500"> | |
| <!-- Years will be populated by JavaScript --> | |
| </select> | |
| <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"> | |
| <i class="fas fa-chevron-down"></i> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <div class="flex flex-col lg:flex-row gap-6"> | |
| <!-- Calendar View --> | |
| <div class="bg-white rounded-xl shadow-lg p-6 flex-1"> | |
| <!-- Weekday Headers --> | |
| <div class="grid grid-cols-7 gap-1 mb-4"> | |
| <div class="text-center font-medium text-gray-500 py-2">Sun</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Mon</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Tue</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Wed</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Thu</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Fri</div> | |
| <div class="text-center font-medium text-gray-500 py-2">Sat</div> | |
| </div> | |
| <!-- Calendar Grid --> | |
| <div id="calendar-grid" class="grid grid-cols-7 gap-1"> | |
| <!-- Days will be populated by JavaScript --> | |
| </div> | |
| </div> | |
| <!-- Sidebar - Events and Add Form --> | |
| <div class="w-full lg:w-80 flex flex-col gap-6"> | |
| <!-- Upcoming Events --> | |
| <div class="bg-white rounded-xl shadow-lg p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center"> | |
| <i class="fas fa-calendar-day text-indigo-600 mr-2"></i> | |
| Upcoming Events | |
| </h3> | |
| <div id="upcoming-events" class="space-y-3 max-h-64 overflow-y-auto"> | |
| <!-- Events will be populated by JavaScript --> | |
| </div> | |
| </div> | |
| <!-- Add Event Form --> | |
| <div class="bg-white rounded-xl shadow-lg p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center"> | |
| <i class="fas fa-plus-circle text-indigo-600 mr-2"></i> | |
| Add Event/Reminder | |
| </h3> | |
| <form id="event-form" class="space-y-4"> | |
| <div> | |
| <label for="event-title" class="block text-sm font-medium text-gray-700 mb-1">Title</label> | |
| <input type="text" id="event-title" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" required> | |
| </div> | |
| <div> | |
| <label for="event-date" class="block text-sm font-medium text-gray-700 mb-1">Date</label> | |
| <input type="date" id="event-date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" required> | |
| </div> | |
| <div class="flex gap-4"> | |
| <div class="flex-1"> | |
| <label for="event-start-time" class="block text-sm font-medium text-gray-700 mb-1">Start Time</label> | |
| <input type="time" id="event-start-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| <div class="flex-1"> | |
| <label for="event-end-time" class="block text-sm font-medium text-gray-700 mb-1">End Time</label> | |
| <input type="time" id="event-end-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="event-color" class="block text-sm font-medium text-gray-700 mb-1">Color</label> | |
| <select id="event-color" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> | |
| <option value="bg-blue-500">Blue</option> | |
| <option value="bg-red-500">Red</option> | |
| <option value="bg-green-500">Green</option> | |
| <option value="bg-yellow-500">Yellow</option> | |
| <option value="bg-purple-500">Purple</option> | |
| <option value="bg-pink-500">Pink</option> | |
| </select> | |
| </div> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="event-reminder" class="custom-checkbox"> | |
| <label for="event-reminder" class="ml-2 text-sm font-medium text-gray-700">Set Reminder</label> | |
| </div> | |
| <div id="reminder-options" class="hidden pl-6 space-y-2"> | |
| <div> | |
| <label for="reminder-time" class="block text-sm font-medium text-gray-700 mb-1">Remind Before</label> | |
| <select id="reminder-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> | |
| <option value="5">5 minutes</option> | |
| <option value="15">15 minutes</option> | |
| <option value="30">30 minutes</option> | |
| <option value="60">1 hour</option> | |
| <option value="1440">1 day</option> | |
| </select> | |
| </div> | |
| </div> | |
| <button type="submit" class="w-full py-2 px-4 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 transition flex items-center justify-center"> | |
| <i class="fas fa-save mr-2"></i> Save Event | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Notification Container --> | |
| <div id="notification-container" class="fixed bottom-4 right-4 space-y-2 z-50"></div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Current date | |
| let currentDate = new Date(); | |
| let currentMonth = currentDate.getMonth(); | |
| let currentYear = currentDate.getFullYear(); | |
| // DOM Elements | |
| const calendarGrid = document.getElementById('calendar-grid'); | |
| const currentMonthYear = document.getElementById('current-month-year'); | |
| const prevMonthBtn = document.getElementById('prev-month'); | |
| const nextMonthBtn = document.getElementById('next-month'); | |
| const todayBtn = document.getElementById('today-btn'); | |
| const yearSelect = document.getElementById('year-select'); | |
| const upcomingEvents = document.getElementById('upcoming-events'); | |
| const eventForm = document.getElementById('event-form'); | |
| const eventDateInput = document.getElementById('event-date'); | |
| const reminderCheckbox = document.getElementById('event-reminder'); | |
| const reminderOptions = document.getElementById('reminder-options'); | |
| const notificationContainer = document.getElementById('notification-container'); | |
| // Events storage | |
| let events = JSON.parse(localStorage.getItem('calendarEvents')) || []; | |
| // Initialize calendar | |
| function initCalendar() { | |
| populateYearDropdown(); | |
| renderCalendar(currentMonth, currentYear); | |
| renderUpcomingEvents(); | |
| setFormDate(); | |
| // Check for reminders every minute | |
| setInterval(checkReminders, 60000); | |
| } | |
| // Populate year dropdown | |
| function populateYearDropdown() { | |
| yearSelect.innerHTML = ''; | |
| const startYear = currentYear - 10; | |
| const endYear = currentYear + 20; | |
| for (let year = startYear; year <= endYear; year++) { | |
| const option = document.createElement('option'); | |
| option.value = year; | |
| option.textContent = year; | |
| if (year === currentYear) { | |
| option.selected = true; | |
| } | |
| yearSelect.appendChild(option); | |
| } | |
| } | |
| // Render calendar | |
| function renderCalendar(month, year) { | |
| // Update month/year display | |
| const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | |
| currentMonthYear.textContent = `${monthNames[month]} ${year}`; | |
| // Clear previous calendar | |
| calendarGrid.innerHTML = ''; | |
| // Get first day of month and total days in month | |
| const firstDay = new Date(year, month, 1).getDay(); | |
| const daysInMonth = new Date(year, month + 1, 0).getDate(); | |
| // Get days from previous month | |
| const prevMonthDays = new Date(year, month, 0).getDate(); | |
| // Add days from previous month | |
| for (let i = 0; i < firstDay; i++) { | |
| const dayElement = createDayElement(prevMonthDays - firstDay + i + 1, true); | |
| calendarGrid.appendChild(dayElement); | |
| } | |
| // Add days from current month | |
| for (let i = 1; i <= daysInMonth; i++) { | |
| const dayElement = createDayElement(i, false, month, year); | |
| calendarGrid.appendChild(dayElement); | |
| } | |
| // Calculate remaining cells to fill the grid | |
| const totalCells = firstDay + daysInMonth; | |
| const remainingCells = totalCells % 7 === 0 ? 0 : 7 - (totalCells % 7); | |
| // Add days from next month | |
| for (let i = 1; i <= remainingCells; i++) { | |
| const dayElement = createDayElement(i, true); | |
| calendarGrid.appendChild(dayElement); | |
| } | |
| } | |
| // Create day element | |
| function createDayElement(day, isOtherMonth, month = currentMonth, year = currentYear) { | |
| const dayElement = document.createElement('div'); | |
| dayElement.className = 'p-2 h-24 border border-gray-100 overflow-hidden'; | |
| if (isOtherMonth) { | |
| dayElement.classList.add('bg-gray-50', 'text-gray-400'); | |
| } else { | |
| dayElement.classList.add('hover:bg-gray-50'); | |
| // Check if it's today | |
| const today = new Date(); | |
| if (day === today.getDate() && month === today.getMonth() && year === today.getFullYear()) { | |
| dayElement.classList.add('bg-indigo-100', 'font-semibold'); | |
| } | |
| // Check for events on this day | |
| const dateStr = formatDate(new Date(year, month, day)); | |
| const dayEvents = events.filter(event => event.date === dateStr); | |
| if (dayEvents.length > 0) { | |
| const eventIndicator = document.createElement('div'); | |
| eventIndicator.className = 'flex flex-wrap mb-1'; | |
| dayEvents.forEach(event => { | |
| const dot = document.createElement('span'); | |
| dot.className = `event-dot ${event.color}`; | |
| eventIndicator.appendChild(dot); | |
| }); | |
| dayElement.appendChild(eventIndicator); | |
| } | |
| } | |
| const dayNumber = document.createElement('div'); | |
| dayNumber.className = 'text-right font-medium'; | |
| dayNumber.textContent = day; | |
| dayElement.appendChild(dayNumber); | |
| // Add click event to show events for this day | |
| if (!isOtherMonth) { | |
| dayElement.addEventListener('click', () => { | |
| showDayEvents(day, month, year); | |
| }); | |
| } | |
| return dayElement; | |
| } | |
| // Show events for a specific day | |
| function showDayEvents(day, month, year) { | |
| const date = new Date(year, month, day); | |
| const dateStr = formatDate(date); | |
| const dayEvents = events.filter(event => event.date === dateStr); | |
| if (dayEvents.length === 0) { | |
| showNotification('No events for this day', 'bg-blue-500'); | |
| return; | |
| } | |
| let message = `Events for ${date.toDateString()}:\n\n`; | |
| dayEvents.forEach(event => { | |
| message += `• ${event.title}`; | |
| if (event.startTime) { | |
| message += ` at ${event.startTime}`; | |
| if (event.endTime) { | |
| message += ` - ${event.endTime}`; | |
| } | |
| } | |
| message += '\n'; | |
| }); | |
| alert(message); | |
| } | |
| // Render upcoming events | |
| function renderUpcomingEvents() { | |
| upcomingEvents.innerHTML = ''; | |
| if (events.length === 0) { | |
| upcomingEvents.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>'; | |
| return; | |
| } | |
| // Sort events by date | |
| const sortedEvents = [...events].sort((a, b) => { | |
| return new Date(a.date) - new Date(b.date); | |
| }); | |
| // Filter events that are today or in the future | |
| const today = new Date(); | |
| today.setHours(0, 0, 0, 0); | |
| const upcoming = sortedEvents.filter(event => { | |
| const eventDate = new Date(event.date); | |
| return eventDate >= today; | |
| }); | |
| if (upcoming.length === 0) { | |
| upcomingEvents.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>'; | |
| return; | |
| } | |
| // Display next 5 events | |
| const displayEvents = upcoming.slice(0, 5); | |
| displayEvents.forEach(event => { | |
| const eventElement = document.createElement('div'); | |
| eventElement.className = 'p-3 rounded-lg border border-gray-200 hover:bg-gray-50 transition cursor-pointer'; | |
| const eventDate = new Date(event.date); | |
| const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' }); | |
| let timeStr = ''; | |
| if (event.startTime) { | |
| timeStr = ` at ${event.startTime}`; | |
| if (event.endTime) { | |
| timeStr += ` - ${event.endTime}`; | |
| } | |
| } | |
| eventElement.innerHTML = ` | |
| <div class="flex items-start"> | |
| <div class="w-2 h-10 rounded-full ${event.color} mr-3"></div> | |
| <div class="flex-1"> | |
| <h4 class="font-medium text-gray-800">${event.title}</h4> | |
| <p class="text-sm text-gray-600">${dateStr}${timeStr}</p> | |
| ${event.reminder ? '<span class="inline-block mt-1 px-2 py-1 text-xs bg-yellow-100 text-yellow-800 rounded-full">Reminder Set</span>' : ''} | |
| </div> | |
| <button class="delete-event text-gray-400 hover:text-red-500" data-id="${event.id}"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| </div> | |
| `; | |
| eventElement.querySelector('.delete-event').addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| deleteEvent(event.id); | |
| }); | |
| eventElement.addEventListener('click', () => { | |
| showEventDetails(event); | |
| }); | |
| upcomingEvents.appendChild(eventElement); | |
| }); | |
| if (upcoming.length > 5) { | |
| const moreEvents = document.createElement('div'); | |
| moreEvents.className = 'text-center text-indigo-600 font-medium mt-2 cursor-pointer hover:underline'; | |
| moreEvents.textContent = `+ ${upcoming.length - 5} more events`; | |
| moreEvents.addEventListener('click', () => { | |
| showAllUpcomingEvents(upcoming); | |
| }); | |
| upcomingEvents.appendChild(moreEvents); | |
| } | |
| } | |
| // Show all upcoming events | |
| function showAllUpcomingEvents(events) { | |
| const modal = document.createElement('div'); | |
| modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4'; | |
| const modalContent = document.createElement('div'); | |
| modalContent.className = 'bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[80vh] overflow-y-auto'; | |
| const modalHeader = document.createElement('div'); | |
| modalHeader.className = 'border-b border-gray-200 p-4 flex justify-between items-center'; | |
| modalHeader.innerHTML = ` | |
| <h3 class="text-xl font-semibold text-gray-800">All Upcoming Events</h3> | |
| <button class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| `; | |
| const modalBody = document.createElement('div'); | |
| modalBody.className = 'p-4'; | |
| if (events.length === 0) { | |
| modalBody.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>'; | |
| } else { | |
| events.forEach(event => { | |
| const eventElement = document.createElement('div'); | |
| eventElement.className = 'p-3 rounded-lg border border-gray-200 hover:bg-gray-50 transition cursor-pointer mb-2'; | |
| const eventDate = new Date(event.date); | |
| const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' }); | |
| let timeStr = ''; | |
| if (event.startTime) { | |
| timeStr = ` at ${event.startTime}`; | |
| if (event.endTime) { | |
| timeStr += ` - ${event.endTime}`; | |
| } | |
| } | |
| eventElement.innerHTML = ` | |
| <div class="flex items-start"> | |
| <div class="w-2 h-10 rounded-full ${event.color} mr-3"></div> | |
| <div class="flex-1"> | |
| <h4 class="font-medium text-gray-800">${event.title}</h4> | |
| <p class="text-sm text-gray-600">${dateStr}${timeStr}</p> | |
| ${event.reminder ? '<span class="inline-block mt-1 px-2 py-1 text-xs bg-yellow-100 text-yellow-800 rounded-full">Reminder Set</span>' : ''} | |
| </div> | |
| <button class="delete-event text-gray-400 hover:text-red-500" data-id="${event.id}"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| </div> | |
| `; | |
| eventElement.querySelector('.delete-event').addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| deleteEvent(event.id); | |
| modal.remove(); | |
| }); | |
| eventElement.addEventListener('click', () => { | |
| showEventDetails(event); | |
| modal.remove(); | |
| }); | |
| modalBody.appendChild(eventElement); | |
| }); | |
| } | |
| modalContent.appendChild(modalHeader); | |
| modalContent.appendChild(modalBody); | |
| modal.appendChild(modalContent); | |
| document.body.appendChild(modal); | |
| modal.querySelector('button').addEventListener('click', () => { | |
| modal.remove(); | |
| }); | |
| } | |
| // Show event details | |
| function showEventDetails(event) { | |
| const modal = document.createElement('div'); | |
| modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4'; | |
| const modalContent = document.createElement('div'); | |
| modalContent.className = 'bg-white rounded-xl shadow-xl w-full max-w-md'; | |
| const eventDate = new Date(event.date); | |
| const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }); | |
| let timeStr = 'All day'; | |
| if (event.startTime) { | |
| timeStr = event.startTime; | |
| if (event.endTime) { | |
| timeStr += ` - ${event.endTime}`; | |
| } | |
| } | |
| modalContent.innerHTML = ` | |
| <div class="border-b border-gray-200 p-4 flex justify-between items-center"> | |
| <h3 class="text-xl font-semibold text-gray-800">Event Details</h3> | |
| <button class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="p-6"> | |
| <div class="flex items-start mb-6"> | |
| <div class="w-3 h-12 rounded-full ${event.color} mr-4"></div> | |
| <div> | |
| <h4 class="text-2xl font-bold text-gray-800 mb-1">${event.title}</h4> | |
| <p class="text-gray-600">${dateStr}</p> | |
| <p class="text-gray-600">${timeStr}</p> | |
| </div> | |
| </div> | |
| ${event.reminder ? ` | |
| <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6"> | |
| <div class="flex"> | |
| <div class="flex-shrink-0"> | |
| <i class="fas fa-bell text-yellow-400"></i> | |
| </div> | |
| <div class="ml-3"> | |
| <p class="text-sm text-yellow-700"> | |
| Reminder set for ${event.reminderTime} minutes before event | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| ` : ''} | |
| <div class="flex justify-end space-x-3"> | |
| <button class="edit-event px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition" data-id="${event.id}"> | |
| <i class="fas fa-edit mr-2"></i> Edit | |
| </button> | |
| <button class="delete-event px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition" data-id="${event.id}"> | |
| <i class="fas fa-trash-alt mr-2"></i> Delete | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| modal.appendChild(modalContent); | |
| document.body.appendChild(modal); | |
| modal.querySelector('button').addEventListener('click', () => { | |
| modal.remove(); | |
| }); | |
| modal.querySelector('.delete-event').addEventListener('click', () => { | |
| deleteEvent(event.id); | |
| modal.remove(); | |
| }); | |
| modal.querySelector('.edit-event').addEventListener('click', () => { | |
| editEvent(event); | |
| modal.remove(); | |
| }); | |
| } | |
| // Edit event | |
| function editEvent(event) { | |
| // Set form values | |
| document.getElementById('event-title').value = event.title; | |
| document.getElementById('event-date').value = event.date; | |
| document.getElementById('event-start-time').value = event.startTime || ''; | |
| document.getElementById('event-end-time').value = event.endTime || ''; | |
| document.getElementById('event-color').value = event.color; | |
| if (event.reminder) { | |
| document.getElementById('event-reminder').checked = true; | |
| reminderOptions.classList.remove('hidden'); | |
| document.getElementById('reminder-time').value = event.reminderTime; | |
| } else { | |
| document.getElementById('event-reminder').checked = false; | |
| reminderOptions.classList.add('hidden'); | |
| } | |
| // Change form to edit mode | |
| eventForm.dataset.mode = 'edit'; | |
| eventForm.dataset.id = event.id; | |
| // Change button text | |
| eventForm.querySelector('button').innerHTML = '<i class="fas fa-save mr-2"></i> Update Event'; | |
| // Scroll to form | |
| eventForm.scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| // Delete event | |
| function deleteEvent(id) { | |
| if (confirm('Are you sure you want to delete this event?')) { | |
| events = events.filter(event => event.id !== id); | |
| saveEvents(); | |
| renderCalendar(currentMonth, currentYear); | |
| renderUpcomingEvents(); | |
| showNotification('Event deleted', 'bg-green-500'); | |
| } | |
| } | |
| // Save events to localStorage | |
| function saveEvents() { | |
| localStorage.setItem('calendarEvents', JSON.stringify(events)); | |
| } | |
| // Format date as YYYY-MM-DD | |
| function formatDate(date) { | |
| const d = new Date(date); | |
| let month = '' + (d.getMonth() + 1); | |
| let day = '' + d.getDate(); | |
| const year = d.getFullYear(); | |
| if (month.length < 2) month = '0' + month; | |
| if (day.length < 2) day = '0' + day; | |
| return [year, month, day].join('-'); | |
| } | |
| // Set form date to today | |
| function setFormDate() { | |
| eventDateInput.value = formatDate(currentDate); | |
| } | |
| // Show notification | |
| function showNotification(message, bgColor = 'bg-indigo-600') { | |
| const notification = document.createElement('div'); | |
| notification.className = `notification ${bgColor} text-white px-6 py-3 rounded-lg shadow-lg flex items-center`; | |
| notification.innerHTML = ` | |
| <i class="fas fa-info-circle mr-2"></i> | |
| <span>${message}</span> | |
| `; | |
| notificationContainer.appendChild(notification); | |
| // Remove notification after 5 seconds | |
| setTimeout(() => { | |
| notification.remove(); | |
| }, 5000); | |
| } | |
| // Check for reminders | |
| function checkReminders() { | |
| const now = new Date(); | |
| events.forEach(event => { | |
| if (event.reminder && !event.reminderShown) { | |
| const eventDate = new Date(`${event.date}T${event.startTime || '00:00'}:00`); | |
| const reminderTime = parseInt(event.reminderTime); | |
| // Calculate reminder time (in minutes) | |
| const reminderDate = new Date(eventDate.getTime() - reminderTime * 60000); | |
| if (now >= reminderDate && now < eventDate) { | |
| // Show notification | |
| showNotification(`Reminder: ${event.title} is coming up soon!`, 'bg-yellow-500'); | |
| // Mark reminder as shown | |
| event.reminderShown = true; | |
| saveEvents(); | |
| } | |
| } | |
| }); | |
| } | |
| // Event Listeners | |
| prevMonthBtn.addEventListener('click', () => { | |
| currentMonth--; | |
| if (currentMonth < 0) { | |
| currentMonth = 11; | |
| currentYear--; | |
| } | |
| renderCalendar(currentMonth, currentYear); | |
| }); | |
| nextMonthBtn.addEventListener('click', () => { | |
| currentMonth++; | |
| if (currentMonth > 11) { | |
| currentMonth = 0; | |
| currentYear++; | |
| } | |
| renderCalendar(currentMonth, currentYear); | |
| }); | |
| todayBtn.addEventListener('click', () => { | |
| currentDate = new Date(); | |
| currentMonth = currentDate.getMonth(); | |
| currentYear = currentDate.getFullYear(); | |
| yearSelect.value = currentYear; | |
| renderCalendar(currentMonth, currentYear); | |
| }); | |
| yearSelect.addEventListener('change', () => { | |
| currentYear = parseInt(yearSelect.value); | |
| renderCalendar(currentMonth, currentYear); | |
| }); | |
| reminderCheckbox.addEventListener('change', () => { | |
| if (reminderCheckbox.checked) { | |
| reminderOptions.classList.remove('hidden'); | |
| } else { | |
| reminderOptions.classList.add('hidden'); | |
| } | |
| }); | |
| eventForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const title = document.getElementById('event-title').value.trim(); | |
| const date = document.getElementById('event-date').value; | |
| const startTime = document.getElementById('event-start-time').value; | |
| const endTime = document.getElementById('event-end-time').value; | |
| const color = document.getElementById('event-color').value; | |
| const hasReminder = document.getElementById('event-reminder').checked; | |
| const reminderTime = hasReminder ? document.getElementById('reminder-time').value : null; | |
| if (eventForm.dataset.mode === 'edit') { | |
| // Update existing event | |
| const id = eventForm.dataset.id; | |
| const eventIndex = events.findIndex(event => event.id === id); | |
| if (eventIndex !== -1) { | |
| events[eventIndex] = { | |
| id, | |
| title, | |
| date, | |
| startTime, | |
| endTime, | |
| color, | |
| reminder: hasReminder, | |
| reminderTime, | |
| reminderShown: false | |
| }; | |
| saveEvents(); | |
| renderCalendar(currentMonth, currentYear); | |
| renderUpcomingEvents(); | |
| showNotification('Event updated', 'bg-green-500'); | |
| } | |
| } else { | |
| // Add new event | |
| const newEvent = { | |
| id: Date.now().toString(), | |
| title, | |
| date, | |
| startTime, | |
| endTime, | |
| color, | |
| reminder: hasReminder, | |
| reminderTime, | |
| reminderShown: false | |
| }; | |
| events.push(newEvent); | |
| saveEvents(); | |
| renderCalendar(currentMonth, currentYear); | |
| renderUpcomingEvents(); | |
| showNotification('Event added', 'bg-green-500'); | |
| } | |
| // Reset form | |
| eventForm.reset(); | |
| setFormDate(); | |
| reminderOptions.classList.add('hidden'); | |
| delete eventForm.dataset.mode; | |
| delete eventForm.dataset.id; | |
| eventForm.querySelector('button').innerHTML = '<i class="fas fa-save mr-2"></i> Save Event'; | |
| }); | |
| // Initialize the calendar | |
| initCalendar(); | |
| }); | |
| </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=seannyboy/calendar-pro" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |