forked from lsvekis/JavaScript-Exercises-Book
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractive Story Creator
More file actions
34 lines (34 loc) · 1.13 KB
/
Interactive Story Creator
File metadata and controls
34 lines (34 loc) · 1.13 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
30
31
32
33
34
<!-- Objective: Develop an interactive story creator. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Interactive Story Creator</title>
</head>
<body>
<div id="storyEditor">
<textarea id="storyText" placeholder="Start writing your story..."></textarea>
<button id="addBranch">Add Choice</button>
</div>
<div id="storyChoices"></div>
<script>
const storyEditor = document.getElementById('storyEditor');
const storyChoices = document.getElementById('storyChoices');
let choiceCount = 0;
document.getElementById('addBranch').addEventListener('click', () => {
choiceCount++;
const choiceInput = document.createElement('input');
choiceInput.type = 'text';
choiceInput.placeholder = `Choice ${choiceCount} Text`;
const linkInput = document.createElement('input');
linkInput.type = 'text';
linkInput.placeholder = `Link to (ID)`;
const choiceDiv = document.createElement('div');
choiceDiv.appendChild(choiceInput);
choiceDiv.appendChild(linkInput);
storyChoices.appendChild(choiceDiv);
});
// Additional functionality to handle story creation, branching, and exporting would be added here.
</script>
</body>
</html>