-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
52 lines (44 loc) · 1.98 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', () => {
fetch('escape_rooms_data.json')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log(data); // Debugging output
const container = document.getElementById('escape-rooms-container');
data.forEach(room => {
const card = document.createElement('div');
card.classList.add('card');
const name = document.createElement('h2');
name.textContent = room.name;
const address = document.createElement('p');
address.textContent = `Address: ${room.address}`;
const phone = document.createElement('p');
phone.textContent = `Phone: ${room.phone_number}`;
const hours = document.createElement('p');
hours.textContent = `Hours: ${room.hours_of_operation}`;
const website = document.createElement('p');
website.textContent = `Website: `;
const websiteLink = document.createElement('a');
websiteLink.href = room.website;
websiteLink.textContent = room.website;
websiteLink.target = '_blank';
website.appendChild(websiteLink);
const reviewScore = document.createElement('p');
reviewScore.textContent = `Review Score: ${room.review_score}`;
card.appendChild(name);
card.appendChild(address);
card.appendChild(phone);
card.appendChild(hours);
card.appendChild(website);
card.appendChild(reviewScore);
container.appendChild(card);
});
})
.catch(error => {
console.error('Error fetching the JSON data:', error);
});
});