-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
62 lines (48 loc) · 1.77 KB
/
index.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
53
54
55
56
const port = "http://localhost:3000";
const zoneApi = new ZoneApi(port);
const attractionApi = new AttractionApi(port);
const exhibitApi = new ExhibitApi(port);
const reviewApi = new ReviewApi(port);
const logo = document.querySelector(".js-logo");
const mainDisplay = document.querySelector(".js-main-display");
const mapGroups = document.querySelectorAll(".js-map-group");
const viewReviewsButton = document.querySelector(".js-view-reviews-btn");
const reviewsContainer = document.querySelector(".js-reviews");
const toTopIcon = document.querySelector(".js-to-top-btn");
//Get core data and setup map
attractionApi.getAttractions();
zoneApi.setupZonesWithMap(mapGroups);
exhibitApi.getExhibits();
// Reset page to home view on logo click
const renderHomeView = () => {
MapZone.all.forEach(zone => {
zone.path.classList.remove("js-inactive");
zone.path.classList.remove("js-active");
});
mainDisplay.classList.remove("zone-selected");
mainDisplay.style.display = "";
document.querySelector(".js-reviews").style.display = "none";
document.querySelector(".js-exhibits").style.display = "none";
document.querySelector(".js-exhibit-card-container").innerHTML = "";
document.querySelector(".js-to-top").style.display = "none";
}
//Set event listeners on already-present DOM elements
viewReviewsButton.addEventListener("click", (e) => {
Review.setSelectedQuery(e.target);
reviewApi.getReviews()
});
reviewsContainer.addEventListener("click", Review.handleClick);
logo.addEventListener('click', renderHomeView);
const scrollUp = (focusElement) => {
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
})
setTimeout(() => {
focusElement.focus()
}, 1000)
}
toTopIcon.addEventListener("click", () => {
scrollUp(document.querySelector(".js-site-name"));
})