Exam Countdown Timer
Set your exam details to start the countdown.
0
Days
0
Hours
0
Minutes
0
Seconds
Good luck on your exam!
No topics listed.
'} `; pdfContentArea.style.display = 'block'; pdfContentArea.style.position = 'absolute'; pdfContentArea.style.left = '-9999px'; pdfContentArea.style.width = '800px'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgHeight = canvas.height * pdfWidth / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight); pdf.save(`Exam-Countdown-${examDetails.name.replace(/[^a-z0-9]/gi, '-')}.pdf`); } catch (error) { console.error("Failed to generate PDF:", error); alert("Sorry, there was an error creating the PDF file."); } finally { pdfContentArea.style.display = 'none'; } } // --- Event Listeners --- startCountdownBtn.addEventListener('click', startCountdown); resetBtn.addEventListener('click', resetCountdown); downloadPdfBtn.addEventListener('click', generatePdf); // --- Initial State --- function setInitialDateTime() { const now = new Date(); // Set default to one week from now now.setDate(now.getDate() + 7); const year = now.getFullYear(); const month = String(now.getMonth() + 1).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0'); examDateInput.value = `${year}-${month}-${day}`; examTimeInput.value = '09:00'; } setInitialDateTime(); switchView('setup'); });