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, '.

')}

`; // Replace . followed by space with line breaks for paragraphs downloadBtn.style.display = 'block'; // Show download button }); document.getElementById('clearBtn').addEventListener('click', () => { document.getElementById('protagonistType').value = 'any'; document.getElementById('hauntingType').value = 'any'; document.getElementById('houseEra').value = 'any'; document.getElementById('triggerEvent').value = 'any'; document.getElementById('storyLength').value = 'short'; document.getElementById('storyKeyword').value = ''; document.getElementById('storyResults').innerHTML = '

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:

  1. Customizable Inputs: Users can input location, ghost type, and mysterious event to generate unique haunted house stories.

  2. AI-Generated Stories: The tool creates vivid and imaginative stories based on user inputs.

  3. Centered Design: The tool is perfectly centered on the page, ensuring a clean and professional look.

  4. PDF Download: Users can download the generated story as a PDF, complete with the same color scheme for consistency.

  5. Responsive Design: The tool is fully responsive and works seamlessly on all devices.

    Benefits for End Users:

    1. Creative Fun: Users can generate unique and spooky haunted house stories for entertainment or personal projects.

    2. Customizable Outputs: The tool allows users to tailor the generated stories based on specific traits.

    3. Educational Tool: Great for students and educators to explore creativity and storytelling concepts.

    4. Portable Results: The PDF download feature allows users to save and share their generated stories easily.

    5. User-Friendly Interface: The simple and intuitive design ensures that users of all ages and technical skill levels can use the tool effortlessly.

Scroll to Top