-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadoptionmanagerV2.html
229 lines (192 loc) · 10.2 KB
/
adoptionmanagerV2.html
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
<!doctype html>
<html lang="en">
<head>
<title>Adopt a Pet - Your Companion Awaits</title>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<!-- Meta tags for social media-->
<meta name="description" content="Find your perfect pet for adoption. Browse through various animal types and complete the adoption process easily.">
<meta name="keywords" content="pet adoption, adopt a dog, adopt a cat, animal shelter">
<meta property="og:type" content="website">
<meta property="og:title" content="Adopt a Pet - Your Companion Awaits">
<meta property="og:description" content="Ready to meet your new best friend? Explore a wide range of animals waiting for a loving home.">
<meta property="twitter:title" content="Adopt a Pet - Your Companion Awaits">
<meta property="twitter:description" content="Discover pets for adoption that fit your lifestyle. Begin your journey towards adding a furry member to your family.">
<!-- Bootstrap CSS v5.2.1 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<!--Styles-->
<link rel="stylesheet" href="styles/universal.css">
<link rel="stylesheet" href="styles/adoptionmanager.css">
<!--Nav Bar-->
<script src="scripts/navbar.js"></script>
<!--Font-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Belanosima:wght@400;600&family=Ultra&display=swap" rel="stylesheet">
</head>
<body>
<main>
<div class="container main__content mt-5">
<h2>Adoption Manager</h2>
<img id="adopt__banner" alt="Banner talking about adoption fees" src="https://images.squarespace-cdn.com/content/v1/51fbb364e4b0d35aeaac238d/1375490813782-F18USZ5NXAJE2ZGDMIKV/adoption-fee-banner.jpg?format=1500w">
<div class="mb-3">
<label class="form-label" for="animalType">Type of Animal</label>
<select class="form-select" id="animalType" onchange="showAnimals(this.value)">
<option value="">All</option>
</select>
</div>
<div class="d-flex flex-wrap" id="animalsContainer">
<!-- Animal cards -->
</div>
</div>
<!-- Adoption Form Modal -->
<div class="modal" id="adoptionFormModal" role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Complete Adoption Form</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- Step 1: Confirm Pet Selection -->
<div id="step1">
<h5>Selected Pet</h5>
<p>Pet's Name: <span id="selectedPetName"></span></p>
<p>Pet ID: <span id="selectedPetId"></span></p>
<button class="btn btn-primary" onclick="goToStep2()">Next</button>
</div>
<!-- Step 2: Collect Adopter Information -->
<div id="step2" style="display: none;">
<form id="adopterInfoForm">
<div class="mb-3">
<label class="form-label" for="fullName">Full Name</label>
<input class="form-control" id="fullName" required type="text">
</div>
<div class="mb-3">
<label class="form-label" for="address">Address</label>
<input class="form-control" id="address" required type="text">
</div>
<div class="mb-3">
<label class="form-label" for="creditCardInfo">Credit Card Info</label>
<input class="form-control" id="creditCardInfo" required type="text">
</div>
<button class="btn btn-primary" type="submit">Submit</button>
</form>
</div>
<!-- Summary -->
<div id="summary" style="display: none;">
<!-- Summary details will be added by JavaScript -->
</div>
</div>
</div>
</div>
</div>
</main>
<footer>
Adopt-a-Pet©. Animal Adoption Center, 2023
<div class="gtranslate_wrapper" ></div>
</footer>
<!-- Bootstrap JavaScript Libraries -->
<script>
document.addEventListener('DOMContentLoaded', function() {
fetch('data/animals.json')
.then(response => response.json())
.then(data => {
populateSpeciesDropdown(data);
showAnimals(data);
});
document.getElementById('animalType').addEventListener('change', function(event) {
fetch('data/animals.json')
.then(response => response.json())
.then(data => showAnimals(data, event.target.value));
});
});
function populateSpeciesDropdown(animals) {
const speciesSet = new Set(animals.map(animal => animal.species));
const speciesDropdown = document.getElementById('animalType');
speciesSet.forEach(species => {
const option = document.createElement('option');
option.value = species;
option.textContent = species;
speciesDropdown.appendChild(option);
});
}
function showAnimals(animals, selectedSpecies = '') {
const animalsContainer = document.getElementById('animalsContainer');
animalsContainer.innerHTML = '';
animals.forEach(animal => {
if (selectedSpecies === '' || animal.species.toLowerCase() === selectedSpecies.toLowerCase()) {
const imagePath = `images/animals/${animal.species.toLowerCase()}${animal.id}.jpg`;
const card = document.createElement('div');
card.className = 'card';
card.style = 'width: 18rem; margin: 10px;';
card.innerHTML = `
<img src="${imagePath}" class="card-img-top" alt="${animal.name}" onerror="this.onerror=null; this.src='images/animals/default.jpg'">
<div class="card-body">
<h5 class="card-title">${animal.name}</h5>
<p class="card-text"><b>Species:</b> ${animal.species}</p>
<p class="card-text"><b>Age:</b> ${animal.age} years</p>
<p class="card-text"><b>Description:</b> ${animal.description}</p>
<button class="btn btn-primary adopt-me-button" data-name="${animal.name}" data-id="${animal.id}">Adopt Me!</button>
</div>
`;
animalsContainer.appendChild(card);
}
});
}
function selectAnimal(name, id) {
// Set the selected animal's name and id in the modal
document.getElementById('selectedPetName').textContent = name;
document.getElementById('selectedPetId').textContent = id;
// Show the modal
const myModal = new bootstrap.Modal(document.getElementById('adoptionFormModal'));
myModal.show();
// Show the first step and hide others
document.getElementById('step1').style.display = 'block';
document.getElementById('step2').style.display = 'none';
document.getElementById('summary').style.display = 'none';
}
function goToStep2() {
// Show the second step
document.getElementById('step1').style.display = 'none';
document.getElementById('step2').style.display = 'block';
}
document.getElementById('animalsContainer').addEventListener('click', function(event) {
if (event.target.classList.contains('adopt-me-button')) {
const name = event.target.getAttribute('data-name');
const id = event.target.getAttribute('data-id');
selectAnimal(name, id);
}
});
document.getElementById('adopterInfoForm').addEventListener('submit', function(event) {
event.preventDefault();
const fullName = document.getElementById('fullName').value;
const address = document.getElementById('address').value;
const creditCardInfo = document.getElementById('creditCardInfo').value;
const petName = document.getElementById('selectedPetName').textContent;
const petId = document.getElementById('selectedPetId').textContent;
document.getElementById('step2').style.display = 'none';
const summaryDiv = document.getElementById('summary');
summaryDiv.innerHTML = `
<h5>Adoption Summary</h5>
<p>Pet Name: ${petName}</p>
<p>Pet ID: ${petId}</p>
<p>Adopter's Name: ${fullName}</p>
<p>Address: ${address}</p>
<p>Credit Card Info: ${creditCardInfo}</p>
`;
summaryDiv.style.display = 'block';
});
</script>
<!-- Bootstrap JavaScript Libraries -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous">
</script>
<script>window.gtranslateSettings = {"default_language":"en","native_language_names":true,"languages":["en","fr"],"wrapper_selector":".gtranslate_wrapper","flag_style":"3d","alt_flags":{"en":"canada","fr":"quebec"}}</script>
<script src="https://cdn.gtranslate.net/widgets/latest/fn.js" defer></script>
</body>
</html>