Detective Story Generator

Detective Story Generator

Piece together the clues to build your next mystery.

What's the Case?

The target was ${victim.toLowerCase()}.

Key Evidence

Investigators have only one lead: ${clue.toLowerCase()}.

Case Complication

The investigation is complicated by the fact that ${twist.toLowerCase()}.

`; document.getElementById('output-display').innerHTML = idea; formContainer.classList.add('hidden'); document.getElementById('tab-container').classList.add('hidden'); navButtons.classList.add('hidden'); outputSection.classList.remove('hidden'); } function downloadPDF() { const { jsPDF } = window.jspdf; const downloadButton = downloadBtn; if (!downloadButton) return; downloadButton.textContent = 'Filing Report...'; downloadButton.disabled = true; try { const crime = document.getElementById('crime').value; const victim = document.getElementById('victim').value; const clue = document.getElementById('clue').value; const twist = document.getElementById('twist').value; const caseNumber = `CASE-${Math.floor(Math.random() * 9000) + 1000}`; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); doc.setFont('courier', 'normal'); const margin = 20; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - margin * 2; let yPos = margin; // --- PDF Template: Case File --- doc.setFontSize(16); doc.setFont('courier', 'bold'); doc.text('CONFIDENTIAL CASE FILE', pageWidth / 2, yPos, { align: 'center' }); yPos += 8; doc.setLineWidth(0.5); doc.line(margin, yPos, pageWidth - margin, yPos); yPos += 10; doc.setFontSize(11); doc.text(`CASE #: ${caseNumber}`, margin, yPos); doc.text(`DATE: ${new Date().toLocaleDateString('en-US')}`, pageWidth - margin, yPos, { align: 'right'}); yPos += 15; const drawSection = (title, text) => { doc.setFont('courier', 'bold'); doc.text(title, margin, yPos); yPos += 5; doc.setLineWidth(0.2); doc.line(margin, yPos, pageWidth - margin, yPos); yPos += 7; doc.setFont('courier', 'normal'); const lines = doc.splitTextToSize(text, usableWidth); doc.text(lines, margin, yPos); yPos += (lines.length * 5) + 12; }; drawSection('INCIDENT REPORT:', `Case involves ${crime.toLowerCase()}.`); drawSection('VICTIM PROFILE:', `The primary person of interest or victim is ${victim.toLowerCase()}.`); drawSection('KEY EVIDENCE:', `The only significant piece of evidence recovered from the scene is ${clue.toLowerCase()}.`); drawSection('CASE COMPLICATION:', `The primary obstacle in this investigation is that ${twist.toLowerCase()}.`); // Add a "TOP SECRET" stamp doc.setFontSize(40); doc.setFont('courier', 'bold'); doc.setTextColor(255, 0, 0); doc.text('TOP SECRET', pageWidth / 2, yPos + 20, { align: 'center', angle: -15 }); doc.save(`CaseFile_${caseNumber}.pdf`); } catch (error) { console.error("Error generating PDF:", error); alert("An error occurred while generating the PDF. Please try again."); } finally { downloadButton.textContent = 'Download as Case File (PDF)'; downloadButton.disabled = false; } } showTab(currentTab); });
Scroll to Top