// Function to add an event to localStorage
eventForm.onsubmit = (e) => {
e.preventDefault();
const title = document.getElementById('eventTitle').value;
const author = document.getElementById('eventAuthor').value;
const desc = document.getElementById('eventDesc').value;
const date = document.getElementById('eventDate').value;
const showLink = document.getElementById('showLink').checked;
const eventLink = showLink ? `event_detail.html?title=${encodeURIComponent(title)}&author=${encodeURIComponent(author)}&desc=${encodeURIComponent(desc)}&date=${encodeURIComponent(date)}` : '';
const events = JSON.parse(localStorage.getItem('events')) || [];
events.push({ title, author, desc, date, cancelled: false, showLink, eventLink });
localStorage.setItem('events', JSON.stringify(events));
eventForm.reset();
toggleLinkInput(); // Reset the link input visibility
updateEvents();
};