Mystery Story Idea Generator

Mystery Story Idea Generator

Generate the perfect plot for your next thrilling tale.

Generated Case File

${scene.text}

The Central Clue

${clue.text}

The Twist

${twist.text}

`; casefileContent.innerHTML = generatedHtml; outputSection.classList.add('active'); // Store for PDF outputSection.dataset.victim = victim.text; outputSection.dataset.scene = scene.text; outputSection.dataset.clue = clue.text; outputSection.dataset.twist = twist.text; }; // --- PDF Generation --- const downloadPdf = () => { if (typeof window.jspdf === 'undefined') { console.error('jsPDF library not loaded'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const victim = outputSection.dataset.victim; const scene = outputSection.dataset.scene; const clue = outputSection.dataset.clue; const twist = outputSection.dataset.twist; const margin = 15, pageWidth = doc.internal.pageSize.getWidth(), usableWidth = pageWidth - margin * 2; let y = margin; // Header doc.setFont('Roboto Mono', 'bold'); doc.setFontSize(20); doc.text("MYSTERY PLOT - CASE FILE", pageWidth / 2, y, { align: 'center' }); y += 8; doc.setDrawColor(100, 100, 100); doc.setLineWidth(0.5); doc.line(margin, y, pageWidth - margin, y); y += 12; const addSection = (title, content) => { if (y > doc.internal.pageSize.getHeight() - 30) { doc.addPage(); y = margin; } doc.setFont('Roboto Mono', 'bold'); doc.setFontSize(10); doc.setTextColor(50, 50, 50); doc.setFillColor(243, 244, 246); doc.rect(margin, y, usableWidth, 8, 'F'); doc.text(title.toUpperCase(), margin + 3, y + 5.5); y += 8; doc.setFont('Inter', 'normal'); doc.setFontSize(11); doc.setTextColor(20, 20, 20); const textLines = doc.splitTextToSize(content, usableWidth - 6); doc.text(textLines, margin + 3, y + 5); y += (textLines.length * 5) + 10; }; addSection("Victim Profile", victim); addSection("Crime Scene Analysis", scene); addSection("Key Evidence", clue); addSection("Case-Breaking Twist", twist); // Footer const pageHeight = doc.internal.pageSize.getHeight(); doc.setFont('Roboto Mono', 'normal'); doc.setFontSize(8); doc.setTextColor(150); doc.text(`Generated on: ${new Date().toUTCString()}`, pageWidth / 2, pageHeight - 10, { align: 'center' }); doc.save('mystery-story-idea.pdf'); }; // --- Event Listeners --- generateBtn.addEventListener('click', generateIdea); downloadPdfBtn.addEventListener('click', downloadPdf); });
Scroll to Top