${tech.suitabilityNotes}
`;
suggestionsContainer.appendChild(card);
});
}
rst_showPhase('suggestion');
}
function rst_downloadPDF() {
if (rst_currentSuggestions.length === 0 && !document.querySelector('.rst-no-suggestions')) { // If no suggestions were generated and it wasn't because of "no match"
alert("Please generate some suggestions first."); return;
}
const doc = new jsPDF();
const primaryColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim();
const textColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim();
const whiteColorPDF = '#FFFFFF';
doc.setFontSize(18); doc.setTextColor(primaryColorPDF);
doc.text("Personalized Relaxation Suggestions", 14, 20);
doc.setFontSize(10); doc.setTextColor(textColorPDF);
doc.text(`Generated On: ${RST_GENERATED_ON_STRING}`, 14, 26);
let currentY = 36;
doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF);
doc.text("Your Preferences:", 14, currentY); currentY += 7;
doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(textColorPDF);
doc.text(`Time Available: ${document.getElementById('rst_timeAvailable').value}`, 16, currentY); currentY += 5;
if(document.getElementById('rst_stressLevel').value) { doc.text(`Stress Level: ${document.getElementById('rst_stressLevel').value}`, 16, currentY); currentY += 5; }
const preferredTypes = Array.from(document.querySelectorAll('#rst_relaxationTypesChecklist input:checked')).map(cb => cb.value);
if(preferredTypes.length > 0) { doc.text(`Preferred Types: ${preferredTypes.join(', ')}`, 16, currentY); currentY += 5; }
if(document.getElementById('rst_currentSetting').value) { doc.text(`Setting: ${document.getElementById('rst_currentSetting').value}`, 16, currentY); currentY += 5; }
currentY += 5;
doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF);
if (currentY > 250) { doc.addPage(); currentY = 20; }
doc.text("Suggested Activities:", 14, currentY); currentY += 7;
if (rst_currentSuggestions.length > 0) {
const tableCols = ["Activity Name", "Description", "Est. Duration", "Suitability Notes"];
const tableRows = rst_currentSuggestions.map(tech => {
let durationText = tech.durationCategory.includes(document.getElementById('rst_timeAvailable').value) ? document.getElementById('rst_timeAvailable').value : tech.durationCategory[0];
// map duration category to actual time ranges
if (durationText === "Quick") durationText = "1-5 min";
else if (durationText === "Short") durationText = "5-15 min";
else if (durationText === "Medium") durationText = "15-30 min";
else if (durationText === "Long") durationText = "30+ min";
return [tech.name, tech.description, durationText, tech.suitabilityNotes];
});
doc.autoTable({
head: [tableCols], body: tableRows, startY: currentY, theme: 'grid',
headStyles: {fillColor: primaryColorPDF, textColor: whiteColorPDF, fontSize:9},
styles:{fontSize:8, cellPadding:2, overflow:'linebreak'},
columnStyles: { 0:{cellWidth:40}, 1:{cellWidth:70}, 2:{cellWidth:25}, 3:{cellWidth:'auto'} }
});
} else {
doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(textColorPDF);
doc.text("No specific suggestions matched all your criteria for this set.", 16, currentY);
}
doc.save(`Relaxation_Suggestions_${RST_CONTEXT_DATE_STR}.pdf`);
}