Astronomy Event Calendar Generator
Compile confirmed meteor showers, conjunctions, and eclipses for your location.
Search Parameters
Searching real-time astronomical databases...
Celestial Event Calendar
Location: N/A | Period: N/A
Please configure the start date, end date, and location to generate the calendar.
Error: Could not parse event data. Check inputs or try again later.
'; } } catch (error) { console.error("API Error:", error); outputDiv.innerHTML = 'API Connection Error. Please verify network access and try again.
'; } finally { loadingMsg.classList.add('hidden'); generateBtn.disabled = false; } } // --- Rendering and PDF --- function aecgRenderCalendar(events, location, start, end) { const outputDiv = document.getElementById('aecg-event-output'); const list = document.createElement('ul'); list.className = 'aecg-event-list'; // Update Header document.getElementById('disp-location').textContent = escapeHtml(location); document.getElementById('disp-period').textContent = `${escapeHtml(start)} to ${escapeHtml(end)}`; if (events.length === 0) { outputDiv.innerHTML = 'No major celestial events found for this period and location.
'; return; } // Sort by date ascending events.sort((a, b) => new Date(a.date) - new Date(b.date)); events.forEach(e => { const item = document.createElement('li'); item.className = 'aecg-event-item'; // Format date for display const eventDate = new Date(e.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); item.innerHTML = ` ${escapeHtml(e.event)} Date: ${eventDate} Visibility Notes: ${escapeHtml(e.detail)} `; list.appendChild(item); }); outputDiv.innerHTML = ''; outputDiv.appendChild(list); } window.aecgDownloadPDF = function() { const element = document.getElementById('aecg-output-area'); const locationName = document.getElementById('aecg-location').value.split(',')[0] || "Calendar"; document.body.classList.add('aecg-generating-pdf'); const opt = { margin: [0.75, 0.75], filename: `${locationName.replace(/\s+/g, '_')}_Astronomy_Calendar.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' } }; html2pdf().set(opt).from(element).save().then(() => { document.body.classList.remove('aecg-generating-pdf'); }); }; // Utility: HTML Escape function escapeHtml(text) { if (!text) return ''; return text.replace(/[&<>"']/g, function(m) { switch (m) { case '&': return '&'; case '<': return '<'; case '>': return '>'; case '"': return '"'; case "'": return '''; default: return m; } }); }