-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.html
More file actions
310 lines (292 loc) · 11.4 KB
/
history.html
File metadata and controls
310 lines (292 loc) · 11.4 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="./favicon.png" sizes="any" type="image/png" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>History</title>
<link rel="stylesheet" href="styles.css" />
<meta name="theme-color" content="#000000" />
<meta
name="viewport"
content="width=device-width, initial-scale=1,
maximum-scale=1, user-scalable=no"
/>
<meta name="apple-mobile-web-app-standalone" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-fullscreen" content="yes" />
<link rel="apple-touch-icon" sizes="128x128" href="icon-128.png" />
<meta name="apple-mobile-web-app-title" content="AdventureAI" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body style="height: 120vh !important">
<audio id="audio" mute="true" ="src" ="" type="audio/mpeg"></audio>
<div id="historyBackground"></div>
<div style="z-index: 999; position: absolute; top: 2em">
<div id="controls">
<svg
id="previousButton"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-arrow-narrow-left"
width="40"
height="40"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#ffffff"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M5 12l14 0" />
<path d="M5 12l4 4" />
<path d="M5 12l4 -4" />
</svg>
<svg
id="mute"
style="position: static !important; margin-top: 5px"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-volume-off"
width="30"
height="30"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#ffffff"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path
d="M15 8a5 5 0 0 1 1.912 4.934m-1.377 2.602a5 5 0 0 1 -.535 .464"
/>
<path
d="M17.7 5a9 9 0 0 1 2.362 11.086m-1.676 2.299a9 9 0 0 1 -.686 .615"
/>
<path
d="M9.069 5.054l.431 -.554a.8 .8 0 0 1 1.5 .5v2m0 4v8a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l1.294 -1.664"
/>
<path d="M3 3l18 18" />
</svg>
<svg
id="unmute"
style="position: static !important; margin-top: 5px"
class="noDisplay"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-volume"
width="30"
height="30"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#ffffff"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M15 8a5 5 0 0 1 0 8" />
<path d="M17.7 5a9 9 0 0 1 0 14" />
<path
d="M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a.8 .8 0 0 1 1.5 .5v14a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"
/>
</svg>
<svg
id="home"
style="position: static !important; margin-top: 5px"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-home"
width="30"
height="30"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#ffffff"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M5 12l-2 0l9 -9l9 9l-2 0" />
<path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
<path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>
<svg
id="nextButton"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-arrow-narrow-right"
width="40"
height="40"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#ffffff"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M5 12l14 0" />
<path d="M15 16l4 -4" />
<path d="M15 8l4 4" />
</svg>
</div>
</div>
<div id="historyResponse">
<div class="playCircleRow">
<img id="character" class="playCircleImage" />
<img id="weapon" class="playCircleImage" />
<img id="sidekick" class="playCircleImage" />
</div>
<div id="storyDisplay"></div>
<div id="options">
<div class="option noDisplay" id="option1"></div>
<div class="option noDisplay" id="option2"></div>
<div class="option noDisplay" id="continue">Continue</div>
</div>
</div>
<div id="title"></div>
<script>
let storyIndex = 0;
async function fetchStoryData(index) {
try {
const response = await fetch(`fetch_story.php?index=${index}`);
console.log('Response status:', response.status);
if (!response.ok) {
throw new Error('Failed to fetch story data from the server.');
}
const jsonData = await response.json();
console.log('Response data:', jsonData); // Log the response data
return jsonData;
} catch (error) {
console.error('An error occurred while fetching story data:', error);
return null;
}
}
async function displayStoryData(index) {
const data = await fetchStoryData(index);
if (data) {
let characterCircle = document.getElementById('character');
let weaponCircle = document.getElementById('weapon');
let sidekickCircle = document.getElementById('sidekick');
let characterSelection = data.characters;
let weaponSelection = data.weapon;
let sidekickSelection = data.sidekick;
if (characterSelection == 'Wizard') {
characterCircle.src = './3212groupProjectAIImages/wizard.jpg';
} else if (characterSelection == 'Cowboy') {
characterCircle.src = './3212groupProjectAIImages/cowboy.jpg';
} else if (characterSelection == 'Tarzan') {
characterCircle.src = './3212groupProjectAIImages/tarzan.jpg';
}
//display weapon image
if (weaponSelection == 'Sword') {
weaponCircle.src = './3212groupProjectAIImages/sword.jpg';
} else if (weaponSelection == 'Revolver') {
weaponCircle.src = './3212groupProjectAIImages/revolver.jpg';
} else if (weaponSelection == 'Club') {
weaponCircle.src = './3212groupProjectAIImages/club.jpg';
}
//display sidekick image
if (sidekickSelection == 'Cowardly Giant') {
sidekickCircle.src = './3212groupProjectAIImages/cowardlyGiant.jpg';
} else if (sidekickSelection == 'Talking Dog') {
sidekickCircle.src = './3212groupProjectAIImages/talkingDog.jpg';
} else if (sidekickSelection == 'Dr. Williams') {
sidekickCircle.src = './3212groupProjectAIImages/drWilliams.jpg';
}
let setting = data.setting;
console.log(setting);
let backgroundImage = document.getElementById('historyBackground');
let audio = document.getElementById('audio');
let muteButton = document.getElementById('mute');
let unmuteButton = document.getElementById('unmute');
muteButton.addEventListener('click', function () {
console.log('play');
document.getElementById('audio').play();
muteButton.classList.add('noDisplay');
muteButton.classList.remove('yesDisplay');
unmuteButton.classList.remove('noDisplay');
unmuteButton.classList.add('yesDisplay');
});
unmuteButton.addEventListener('click', function () {
console.log('pause');
document.getElementById('audio').pause();
muteButton.classList.add('yesDisplay');
muteButton.classList.remove('noDisplay');
unmuteButton.classList.remove('yesDisplay');
unmuteButton.classList.add('noDisplay');
});
if (setting == 'Medieval City') {
audio.src = './music/Medieval.mp3';
backgroundImage.style.backgroundImage =
'url(./3212groupProjectAIImages/medievalCityLarge.jpg)';
//audio.play();
} else if (setting == 'Western Town') {
audio.src = './music/West.mp3';
backgroundImage.style.backgroundImage =
'url(./3212groupProjectAIImages/westernTownLarge.jpg)';
//audio.play();
} else if (setting == 'Jungle') {
audio.src = './music/Jungle.mp3';
backgroundImage.style.backgroundImage =
'url(./3212groupProjectAIImages/jungleLarge.jpg)';
//audio.play();
}
document.getElementById('storyDisplay').innerHTML = `
<p>Full Story: ${data.fullStory}</p>
`;
} else {
// Handle error or no data case
console.error('No data fetched or error occurred.');
storyIndex -= 1;
}
}
// Call the function initially
displayStoryData(0);
// Button event listeners
document
.getElementById('previousButton')
.addEventListener('click', () => {
if (storyIndex > 0) {
storyIndex -= 1;
console.log(storyIndex);
displayStoryData(storyIndex);
let unmuteButton = document.getElementById('unmute');
let muteButton = document.getElementById('mute');
console.log('pause');
document.getElementById('audio').pause();
muteButton.classList.add('yesDisplay');
muteButton.classList.remove('noDisplay');
unmuteButton.classList.remove('yesDisplay');
unmuteButton.classList.add('noDisplay');
}
});
document.getElementById('nextButton').addEventListener('click', () => {
storyIndex += 1;
displayStoryData(storyIndex);
let unmuteButton = document.getElementById('unmute');
let muteButton = document.getElementById('mute');
document.getElementById('audio').pause();
muteButton.classList.add('yesDisplay');
muteButton.classList.remove('noDisplay');
unmuteButton.classList.remove('yesDisplay');
unmuteButton.classList.add('noDisplay');
});
</script>
<script>
// Get the history button element
let historyButton = document.getElementById('history');
// Add event listener to the history button
historyButton.addEventListener('click', function () {
// Redirect to ./history.html
window.location.href = './history.html';
});
</script>
<script>
// Get the history button element
let homeButton = document.getElementById('home');
// Add event listener to the history button
homeButton.addEventListener('click', function () {
window.location.href = './';
});
</script>
</body>
</html>