Haunted House Story Creator
Generate a short, spooky story about a haunted house based on your choices!
Your haunted house story will appear here!
Generating story...
'; downloadBtn.style.display = 'none'; const generatedStory = generateHauntedHouseStory(protagonistType, hauntingType, houseEra, triggerEvent, storyLength, keyword); resultsDiv.innerHTML = `${generatedStory.replace(/\.\s/g, '.
')}
Your haunted house story will appear here!
'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide download button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('storyResults'); const storyText = resultsDiv.textContent.trim(); if (!storyText || storyText.includes('Your haunted house story will appear here!') || storyText.includes('Generating story...')) { alert("No story 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("A Haunted House Story", margin, y); y += 15; // Space after title doc.setFontSize(12); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Add the story text, handling wrapping and pagination const storyLines = doc.splitTextToSize(storyText, maxLineWidth); storyLines.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("A Haunted House Story (cont.)", margin, y); y += 15; doc.setFontSize(12); doc.setTextColor(52, 58, 64); } doc.text(line, margin, y); y += 7; // Estimate line height }); doc.save('haunted_house_story.pdf'); });Key Features:
Customizable Inputs: Users can input location, ghost type, and mysterious event to generate unique haunted house stories.
AI-Generated Stories: The tool creates vivid and imaginative stories based on user inputs.
Centered Design: The tool is perfectly centered on the page, ensuring a clean and professional look.
PDF Download: Users can download the generated story as a PDF, complete with the same color scheme for consistency.
Responsive Design: The tool is fully responsive and works seamlessly on all devices.
Benefits for End Users:
Creative Fun: Users can generate unique and spooky haunted house stories for entertainment or personal projects.
Customizable Outputs: The tool allows users to tailor the generated stories based on specific traits.
Educational Tool: Great for students and educators to explore creativity and storytelling concepts.
Portable Results: The PDF download feature allows users to save and share their generated stories easily.
User-Friendly Interface: The simple and intuitive design ensures that users of all ages and technical skill levels can use the tool effortlessly.
