-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (26 loc) · 1.25 KB
/
Copy pathscript.js
File metadata and controls
29 lines (26 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const esc = s => String(s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
document.getElementById('generate-button').addEventListener('click', (e) => {
e.preventDefault();
const genre = document.getElementById('genre').value;
const title = document.getElementById('title').value;
const author = document.getElementById('author').value;
const character = document.getElementById('character').value;
const storyline = document.getElementById('storyline').value;
const message = document.getElementById('message').value;
const date = document.getElementById('date').value;
if (!genre || !title || !author || !character || !storyline || !message || !date) {
alert("Please fill in all fields before generating the story.");
return;
}
const result = `
<h2>Generated Story</h2>
<p><strong>Genre:</strong> ${esc(genre)}</p>
<p><strong>Title:</strong> ${esc(title)}</p>
<p><strong>Author:</strong> ${esc(author)}</p>
<p><strong>Character:</strong> ${esc(character)}</p>
<p><strong>Storyline:</strong> ${esc(storyline)}</p>
<p><strong>Message:</strong> ${esc(message)}</p>
<p><strong>Date:</strong> ${esc(date)}</p>
`;
document.getElementById('result').innerHTML = result;
});