-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweapon.html
More file actions
94 lines (88 loc) · 2.97 KB
/
weapon.html
File metadata and controls
94 lines (88 loc) · 2.97 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
<!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 Weapon</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('weapon');
console.log('removed weapon');
});
</script>
</head>
<body>
<h1>Arm Yourself</h1>
<div class="imageRow">
<div class="imageGroup">
<a href="./sidekick.html">
<img
id="sword"
class="circleImage"
src="./3212groupProjectAIImages/sword.jpg"
/>
</a>
<h2>Sword</h2>
</div>
<div class="imageGroup">
<a href="./sidekick.html">
<img
id="revolver"
class="circleImage"
src="./3212groupProjectAIImages/revolver.jpg"
/>
</a>
<h2>Revolver</h2>
</div>
<div class="imageGroup">
<a href="./sidekick.html">
<img
id="club"
class="circleImage"
src="./3212groupProjectAIImages/club.jpg"
/>
</a>
<h2>Club</h2>
</div>
</div>
<!-- <a href="./sidekick.html" id="startButton">CONTINUE</a> -->
</body>
</html>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Capitalize first letter function
const capitalizeFirstLetter = (string) =>
string.charAt(0).toUpperCase() + string.slice(1);
// 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';
});
// Capitalize the first letter of the clicked image's id
const capitalizedId = capitalizeFirstLetter(this.id);
// Store the capitalized id in a session variable called 'weapon'
sessionStorage.setItem('weapon', capitalizedId);
console.log(sessionStorage.getItem('weapon'));
// Change border color of clicked image
this.style.borderColor = '#4f0b27';
});
});
});
</script>