"What If?" Scenario Generator
Explore hypothetical situations and their potential consequences!
Your "What If?" scenario will appear here!
Potential Consequences: ${scenario.consequences}
`; downloadPdfBtn.style.display = 'block'; // Show download button only on success } }); document.getElementById('clearBtn').addEventListener('click', () => { document.getElementById('scenarioField').value = 'any'; document.getElementById('changeType').value = 'any'; document.getElementById('impactScale').value = 'personal'; document.getElementById('scenarioKeyword').value = ''; document.getElementById('scenarioResults').innerHTML = 'Your "What If?" scenario will appear here!
'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide PDF button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('scenarioResults'); // Check if results are error message before attempting to get text if (resultsDiv.textContent.includes("Error:") || resultsDiv.textContent.includes('Your "What If?" scenario will appear here!')) { alert("No scenario to download."); return; } const premiseText = resultsDiv.querySelector('p:nth-child(1)') ? resultsDiv.querySelector('p:nth-child(1)').textContent.replace('The Premise: ', '').trim() : ''; const consequencesText = resultsDiv.querySelector('p:nth-child(2)') ? resultsDiv.querySelector('p:nth-child(2)').textContent.replace('Potential Consequences: ', '').trim() : ''; if (!premiseText) { // Should not happen if check passed, but for safety alert("No scenario to download."); return; } // --- PDF Generation --- const doc = new jsPDF(); const margin = 15; let y = margin; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const maxLineWidth = pageWidth - 2 * margin; // Max width for text line doc.setFontSize(18); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 doc.text("\"What If?\" Scenario", margin, y); y += 15; // Space after title doc.setFontSize(12); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Add Premise doc.setFontSize(14); doc.text("The Premise:", margin, y); y += 8; doc.setFontSize(12); const premiseLines = doc.splitTextToSize(premiseText, maxLineWidth); doc.text(premiseLines, margin, y); y += (premiseLines.length * 7) + 10; // Add Consequences doc.setFontSize(14); doc.text("Potential Consequences:", margin, y); y += 8; doc.setFontSize(12); const consequenceLines = doc.splitTextToSize(consequencesText, maxLineWidth); // Check if consequences fit and add pages if necessary consequenceLines.forEach(line => { if (y + 7 > pageHeight - margin) { // Estimate line height + padding doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("\"What If?\" Scenario (cont.)", margin, y); y += 15; doc.setFontSize(14); doc.text("Potential Consequences (cont.):", margin, y); y += 8; doc.setFontSize(12); } doc.text(line, margin, y); y += 7; // Estimate line height }); doc.save('whatif_scenario.pdf'); });Key Features
Creative “What If?” Scenarios: Generates unique and imaginative “What If?” scenarios with detailed descriptions.
Header with Instructions: Includes a header with a title and brief instructions for ease of use.
PDF Download: Allows users to download the generated scenario as a PDF with a consistent color scheme.
Centered Layout: The tool is perfectly centered on the page for a clean and professional look.
Lightweight and Fast: Optimized for performance and works seamlessly in WordPress Elementor HTML blocks.
Benefits for End Users
Creative Exploration: Provides a fun and imaginative way to explore unique “What If?” scenarios.
User-Friendly: Simple and intuitive interface ensures ease of use for all users.
Portable Results: The PDF download feature allows users to save and share their scenarios effortlessly.
Engaging Design: The tool’s modern design and consistent color scheme enhance the user experience.
Privacy: No personal data is collected, ensuring complete privacy for users.
