Acupressure & Reflexology Points Finder
Find pressure points to help alleviate common ailments.
Body Points
Hand Points
Foot Points
Point Descriptions
Descriptions will appear here.
${point.name}
Location: ${point.location}
Technique: ${point.technique}
`; descriptionList.appendChild(descDiv); // Add interactivity dot.addEventListener('mouseenter', () => highlightPoint(point.id)); dot.addEventListener('mouseleave', () => unhighlightPoint(point.id)); descDiv.addEventListener('mouseenter', () => highlightPoint(point.id)); descDiv.addEventListener('mouseleave', () => unhighlightPoint(point.id)); }); resultsSection.style.display = 'block'; } function highlightPoint(id) { document.getElementById(`dot-${id}`)?.classList.add('active'); document.getElementById(`desc-${id}`)?.classList.add('active'); } function unhighlightPoint(id) { document.getElementById(`dot-${id}`)?.classList.remove('active'); document.getElementById(`desc-${id}`)?.classList.remove('active'); } // --- PDF Generation --- async function generatePDF() { const ailmentKey = ailmentSelect.value; if (!ailmentKey) return; // Clone the results section into the hidden PDF container const pdfContentContainer = document.getElementById('pdf-content'); const resultsClone = resultsSection.cloneNode(true); resultsClone.style.display = 'block'; // Remove the download button from the clone resultsClone.querySelector('#download-pdf-btn').parentElement.remove(); pdfContentContainer.innerHTML = ''; pdfContentContainer.appendChild(resultsClone); // Generate PDF from the hidden container const { jsPDF } = window.jspdf; const originalButtonText = downloadPdfBtn.textContent; downloadPdfBtn.textContent = 'Generating...'; downloadPdfBtn.disabled = true; try { const canvas = await html2canvas(pdfContentContainer, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgWidth / imgHeight; let finalImgWidth = pdfWidth; let finalImgHeight = pdfWidth / ratio; if (finalImgHeight > pdfHeight) { finalImgHeight = pdfHeight; finalImgWidth = pdfHeight * ratio; } pdf.addImage(imgData, 'PNG', 0, 0, finalImgWidth, finalImgHeight); pdf.save('Acupressure-Report.pdf'); } catch (error) { console.error("PDF Generation Error:", error); } finally { downloadPdfBtn.textContent = 'Download as PDF'; downloadPdfBtn.disabled = false; pdfContentContainer.innerHTML = ''; // Clean up } } // --- Event Listeners --- ailmentSelect.addEventListener('change', (e) => renderPoints(e.target.value)); downloadPdfBtn.addEventListener('click', generatePDF); });