International Public Holiday Checker

International Public Holiday Checker

Select Location & Year

Public Holidays

Select a country and year to see the list of public holidays.

Customize Holiday Data

Add New Holiday

No holiday data found for the selected country and year.

'; } } window.renderConfigTable = function() { const country = configCountrySelect.value; const year = parseInt(configYearSelect.value, 10); const filteredHolidays = holidayData.filter(h => h.country === country && h.year === year); let tableHTML = ` `; if (filteredHolidays.length > 0) { filteredHolidays.sort((a, b) => new Date(a.date) - new Date(b.date)); filteredHolidays.forEach(h => { tableHTML += ``; }); } tableHTML += '
DateHoliday NameAction
${h.date} ${h.name}
'; configTableContainer.innerHTML = tableHTML; } window.addHoliday = function() { const country = configCountrySelect.value; const dateInput = document.getElementById('new-holiday-date'); const nameInput = document.getElementById('new-holiday-name'); if (!dateInput.value || !nameInput.value) { alert("Please provide both a date and a name."); return; } const year = new Date(dateInput.value + 'T00:00:00').getFullYear(); const newHoliday = { id: Date.now(), country: country, year: year, date: dateInput.value, name: nameInput.value }; holidayData.push(newHoliday); // Refresh all views populateSelectors(); displayHolidays(); renderConfigTable(); // Reset inputs dateInput.value = ''; nameInput.value = ''; } window.removeHoliday = function(id) { holidayData = holidayData.filter(h => h.id !== id); // Refresh all views populateSelectors(); displayHolidays(); renderConfigTable(); } // --- TAB & NAVIGATION --- window.openTab = function(evt, tabName) { const tabContents = document.getElementsByClassName("tab-content"); Array.from(tabContents).forEach(tab => tab.style.display = "none"); const tabButtons = document.getElementsByClassName("tab-btn"); Array.from(tabButtons).forEach(btn => btn.classList.remove("active")); document.getElementById(tabName).style.display = "block"; if (evt) { evt.currentTarget.classList.add("active"); } else { const btnToActivate = Array.from(tabButtons).find(btn => btn.getAttribute('onclick').includes(`'${tabName}'`)); if (btnToActivate) btnToActivate.classList.add("active"); } updateNavButtons(); } window.navigateTabs = function(direction) { const tabs = Array.from(document.querySelectorAll('.tab-btn')); const activeTabIndex = tabs.findIndex(tab => tab.classList.contains('active')); let newIndex = (direction === 'next') ? (activeTabIndex + 1) % tabs.length : (activeTabIndex - 1 + tabs.length) % tabs.length; tabs[newIndex].click(); } function updateNavButtons() { const tabs = Array.from(document.querySelectorAll('.tab-btn')); const activeTabIndex = tabs.findIndex(tab => tab.classList.contains('active')); document.getElementById('prev-btn').style.visibility = activeTabIndex === 0 ? 'hidden' : 'visible'; document.getElementById('next-btn').style.visibility = activeTabIndex === tabs.length - 1 ? 'hidden' : 'visible'; } // --- PDF DOWNLOAD --- if(downloadPdfBtn) { downloadPdfBtn.addEventListener('click', function() { const { jsPDF } = window.jspdf; const contentToDownload = document.getElementById('results-to-download'); if (!contentToDownload) { console.warn("Content for PDF not found."); return; } const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating...'; downloadPdfBtn.disabled = true; html2canvas(contentToDownload, { scale: 2, useCORS: true }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth - 20, imgHeight > 0 ? imgHeight - 20 : 0); pdf.save(`${countrySelect.value}-${yearSelect.value}-Holidays.pdf`); }).catch(err => { console.error("Error generating PDF:", err); }).finally(() => { downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; }); }); } // --- INITIALIZATION --- function initializeTool() { populateSelectors(); displayHolidays(); renderConfigTable(); updateNavButtons(); } initializeTool(); });
Scroll to Top