-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.html
More file actions
101 lines (96 loc) · 4.02 KB
/
location.html
File metadata and controls
101 lines (96 loc) · 4.02 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
<!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" />
<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-status-bar-style" content="black" />
<title>Choose Your location</title>
<link rel="stylesheet" href="styles.css" />
<script>
window.addEventListener('load', function () {
const imageRow = document.querySelector('.imageRow');
imageRow.classList.add('fade-in');
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Remove the 'character' variable from session storage on page load
sessionStorage.removeItem('location');
});
</script>
</head>
<body>
<h1>Choose Your Setting</h1>
<div class="imageRow">
<div class="imageGroup">
<a href="./play.html">
<img
id="medievalCity"
class="circleImage"
src="./3212groupProjectAIImages/medievalCity.jpg"
/>
</a>
<h2>Medieval City</h2>
</div>
<div class="imageGroup">
<a href="./play.html">
<img
id="westernTown"
class="circleImage"
src="./3212groupProjectAIImages/westernTown.jpg"
/>
</a>
<h2>Western Town</h2>
</div>
<div class="imageGroup">
<a href="./play.html">
<img
id="jungle"
class="circleImage"
src="./3212groupProjectAIImages/jungle.jpg"
/>
</a>
<h2>Enchanted Jungle</h2>
</div>
</div>
<!-- <a href="./play.html" id="startButton">CONTINUE</a> -->
<script>
document.addEventListener('DOMContentLoaded', function () {
// Add event listener to each image
const images = document.querySelectorAll('.circleImage');
images.forEach(function (image) {
image.addEventListener('click', function () {
// Reset border color of all images to white
images.forEach(function (img) {
img.style.borderColor = 'white';
});
// Store the id of the clicked image in a session variable called 'character'
sessionStorage.setItem(
'location',
(function (clickedImage) {
if (clickedImage.id === 'medievalCity') {
sessionStorage.setItem('databaseLocation', 'Medieval City');
return 'bustling city in medieval europe filled with a variety of people, and a massive castle on the hill. The city has a multitude of shops, and may even have a city watch to keep the peace, which our main characters will probably disturb';
} else if (clickedImage.id === 'westernTown') {
sessionStorage.setItem('databaseLocation', 'Western Town');
return 'busy cattle town in the american west in the wild west days. The town is filled with mostly good people, but a gang of cattle rustlers is always causing trouble';
} else if (clickedImage.id === 'jungle') {
sessionStorage.setItem('databaseLocation', 'Jungle');
return 'A jungle which seems empty at first, but a tribe of jungle dwelling people are soon found. They are mostly good, but their witchdoctor could be a villan. This is yet to be seen. Also, a massive pyramid may be unveiled';
}
})(this) // Pass the clicked image element as an argument
);
console.log(sessionStorage.getItem('location'));
// Change border color of clicked image
this.style.borderColor = '#4f0b27';
});
});
});
</script>
</body>
</html>