-
Notifications
You must be signed in to change notification settings - Fork 0
/
match.html
313 lines (309 loc) · 11.6 KB
/
match.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
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
311
312
313
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TinDog Match</title>
<link rel="stylesheet" href="./styles/styles.css">
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<style>
#sidenav {display: none;}
#dogCards {
margin: auto auto;
display: grid;
grid-template: auto / auto auto auto;
}
@media only screen and (max-width: 1060px) {
#dogCards {
grid-template: auto/ auto auto;
}
}
@media only screen and (max-width: 720px) {
#dogCards {
grid-template: auto/ auto;
}
}
.specifics {
display: grid;
grid-template: auto auto / auto auto;
}
.specifics p {
margin: auto .2em;
}
.card {
border-radius: 1em;
margin: 0 auto 1em auto;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 20em;
}
.card img {
width: inherit;
border-radius: inherit;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.info {
padding: 2px 16px;
}
</style>
<script>
var openMenu = false;
var srcString = "https://placedog.net/400/400?id="
var originalDogArr = [
{
"name": "Jeffrey",
"img": "121",
"breed": "Beagle",
"age": "5",
"size": "S",
"favoriteToy": "Frisbee",
"type": "Relaxed"
},
{
"name": "Arlo",
"img": "15",
"breed": "Australian Shepherd",
"age": "2",
"size": "M",
"favoriteToy": "Tennis Ball",
"type": "Active"
},
{
"name": "Griffin",
"img": "160",
"breed": "Husky",
"age": "1",
"size": "S",
"type": "Active",
"favoriteToy": "Stuffed Dragon"
},
{
"name": "Harriet",
"img": "65",
"breed": "Husky",
"age": "3",
"size": "L",
"type": "Active",
"favoriteToy": "Rope"
},
{
"name": "Meghan",
"img": "172",
"breed": "Golden Retriever",
"age": "6",
"size": "L",
"type": "Active",
"favoriteToy": "Football"
},
{
"name": "Beth",
"img": "75",
"breed": "Corgi",
"age": "1",
"size": "S",
"type": "Relaxed",
"favoriteToy": "Rubber Duck"
},
{
"name": "Ryan",
"img": "18",
"breed": "Golden Retriever",
"age": "2",
"size": "L",
"type": "Active",
"favoriteToy": "Socks"
},
{
"name": "Joan",
"img": "122",
"breed": "Spaniel",
"age": "2",
"size": "S",
"type": "Relaxed",
"favoriteToy": "Sticks"
},
{
"name": "Mike",
"img": "63",
"breed": "Bulldog",
"age": "4",
"size": "S",
"type": "Relaxed",
"favoriteToy": "Stuffed Moon"
}
]
var dogArr = originalDogArr;
$(document).ready(() => {
$("#hamburger").click(menuslide);
$("#closeMenu").click(menuslide);
$("#sidenav").slideUp();
$(".card").click(() => {
console.log("click");
var email = '[email protected]';
var subject = this.attr('id');
window.location = 'mailto:' + email + '?subject=' + subject;
})
$("#type").change(() => {
updateDogs();
})
$("#size").change(() => {
updateDogs();
})
dogScript(dogArr);
});
function menuslide () {
if (!openMenu) {
$("#hamburger").attr("src", "./imgs/openmenu.png");
$("#sidenav").slideDown()
} else {
$("#hamburger").attr("src", "./imgs/menu.png");
$("#sidenav").slideUp()
}
openMenu = !openMenu;
}
function dogScript(dogArr) {
$("#dogCards").html('')
let html = ""
for (let d of dogArr) {
let size = d.size;
switch (size) {
case "S":
size = "Small"
break;
case "M":
size = "Medium"
break;
default: // L
size = "Large"
break;
}
html += `<div class="card" id='${d.name}'>
<img src="${srcString + d.img}">
<div class="info">
<h3 style="margin: 0 auto">${d.name}, ${d.age}</h3>
<div class="specifics">
<p><strong>Breed:</strong> ${d.breed}</p>
<p><strong>Size:</strong> ${size}</p>
<p><strong>Demeanor:</strong> ${d.type}</p>
<p><strong>Favorite Toy:</strong> ${d.favoriteToy}</p>
</div>
</div>
</div>`
}
$("#dogCards").html(html);
}
function updateDogs() {
let type = $("#type option:selected").text()
let size = $("#size option:selected").text()
let newDogArr = originalDogArr;
newDogArr = newDogArr.filter((d) => {
console.log(d.type)
console.log(type)
console.log(d.size)
console.log(size)
if (d.type !== type && type !== "All") {
return false;
} else if (d.size !== size && size !== "All") {
return false;
}
return true;
})
dogScript(newDogArr)
}
</script>
</head>
<body>
<header>
<div class="logoBar">
<div class="box">
<a href="index.html"><img src="./imgs/tindoglogo.png"></a>
</div>
<div class="box">
<h3>TinDog</h3>
</div>
</div>
<div class="nav">
<div class="box">
<img id="hamburger" style="height: 2em" src="./imgs/menu.png">
</div>
<div class="box">
<a href="index.html"><h4>Home</h4></a>
</div>
<div class="box">
<a href="match.html"><h4>Our Dogs</h4></a>
</div>
<div class="box">
<a href="donate.html"><h4>Donate</h4></a>
</div>
<div class="box">
<a href="care.html"><h4>Care Materials</h4></a>
</div>
<div class="box">
<a href="resources.html"><h4>Owner Resources</h4></a>
</div>
<div class="box">
<a href="about.html"><h4>About TinDog</h4></a>
</div>
<div class="box">
<a href="contact.html"><h4>Contact</h4></a>
</div>
</div>
<div id="sidenav">
<a href="index.html">Home</a>
<br>
<a href="match.html">Our Dogs</a>
<br>
<a href="donate.html">Donate</a>
<br>
<a href="care.html">Care Materials</a>
<br>
<a href="resources.html">Owner Resources</a>
<br>
<a href="about.html">About TinDog</a>
<br>
<a href="contact.html">Contact Us</a>
<br>
<button id="closeMenu">×</button>
</div>
</header>
<div class="main">
<div id="imgdiv">
<h1>Match with Dogs</h1>
</div>
<div id="text" style="text-align: center;">
<h2>Find the right dog for you! If you see one you like, <a href="contact.html">contact us</a> for more info!</h2>
<div id="form">
<label for="type">Demeanor:</label>
<select name="type" id="type">
<option>All</option>
<option>Relaxed</option>
<option>Active</option>
</select>
<label for="size">Size:</label>
<select name="size" id="size">
<option>All</option>
<option>S</option>
<option>M</option>
<option>L</option>
</select>
</div>
<br>
<div id="dogCards">
</div>
<div id="donate">
<h3>
TinDog relies upon your support to stay running!
</h3>
<p>If you like our service, please consider <a href="donate.html">donating!</a></p>
<form action="donate.html" method="get" id="btnform">
<button id="donatebtn">Donate Now!</button>
</form>
<br>
</div>
</div>
</div>
</body>
</html>