Walking Step Counter
Log Daily Steps
Your Step History
Daily Steps Progress
Steps Log
| Date | Steps |
|---|
AI Coach Analysis
Your AI coach is analyzing your activity...
No steps logged yet. Start logging to see your progress!
Sorry, the AI coach is unavailable right now. Please try again later.
'; } finally { loadingEl.classList.add('hidden'); containerEl.classList.remove('hidden'); } } elements.analyzeStepsBtn.addEventListener('click', analyzeStepsWithGemini); // --- PDF DOWNLOAD FUNCTIONALITY --- async function downloadPDF() { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const contentArea = elements.pdfContentAreaSteps; if (!contentArea) { console.error("PDF content area not found!"); return; } document.body.classList.add('pdf-export-mode'); try { const canvas = await html2canvas(contentArea, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const imgProps = pdf.getImageProperties(imgData); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = pdfHeight; let position = 0; const pageHeight = pdf.internal.pageSize.getHeight(); pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, pdfHeight); heightLeft -= pageHeight; while (heightLeft > 0) { position = heightLeft - pdfHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, pdfHeight); heightLeft -= pageHeight; } pdf.save('Daily_Steps_Progress_Report.pdf'); } catch (error) { console.error("Error generating PDF:", error); alert("An error occurred while generating the PDF. Please try again."); } finally { document.body.classList.remove('pdf-export-mode'); } } elements.downloadStepsPdfBtn.addEventListener('click', downloadPDF); // --- INITIALIZATION --- function initializeTool() { elements.stepsDate.valueAsDate = new Date(); updateStepTrackerView(); } initializeTool(); });