2021-01-29 08:30:05 +00:00
|
|
|
const expandTemplates = async () => {
|
2021-01-30 00:52:25 +00:00
|
|
|
template.apply("navbar").values([
|
2021-01-29 08:30:05 +00:00
|
|
|
{ section: "left" },
|
|
|
|
{ section: "right" }
|
|
|
|
]);
|
2021-01-30 00:52:25 +00:00
|
|
|
template.apply("navbar-section-left").values([
|
2021-01-29 08:30:05 +00:00
|
|
|
{ item: "games", title: "Games" },
|
|
|
|
{ item: "achievements", title: "Achievements" }
|
|
|
|
]);
|
2021-01-30 00:52:25 +00:00
|
|
|
template.apply("navbar-section-right").values([
|
2021-01-29 08:30:05 +00:00
|
|
|
{ item: "profile", title: "Profile" }
|
|
|
|
]);
|
2021-01-30 00:52:25 +00:00
|
|
|
template.apply("content-body").values([
|
2021-01-29 08:30:05 +00:00
|
|
|
{ page: "games", title: "Games" },
|
|
|
|
{ page: "achievements", title: "Achievements" },
|
|
|
|
{ page: "profile", title: "Profile" }
|
|
|
|
]);
|
2021-01-30 00:52:25 +00:00
|
|
|
template.apply("extern-games-page" ).values("games_page" );
|
|
|
|
template.apply("extern-achievements-page").values("achievements_page");
|
|
|
|
template.apply("extern-profile-page" ).values("profile_page" );
|
|
|
|
template.apply("achievements-page-list" ).fetch("achievements", "https://localhost:4730/achievements");
|
|
|
|
|
2021-01-29 08:30:05 +00:00
|
|
|
await template.expand();
|
|
|
|
};
|
|
|
|
|
2021-01-22 07:57:23 +00:00
|
|
|
let pages = null;
|
2021-01-29 08:30:05 +00:00
|
|
|
const loadPages = () => {
|
2021-01-22 07:57:23 +00:00
|
|
|
pages = document.querySelectorAll(".page");
|
|
|
|
}
|
|
|
|
|
|
|
|
const connectNavbar = () => {
|
|
|
|
const navItems = document.querySelectorAll(".navbar-item");
|
|
|
|
|
2021-01-29 08:30:05 +00:00
|
|
|
for (const item of navItems) {
|
2021-01-22 07:57:23 +00:00
|
|
|
item.addEventListener("click", (clickEvent) => {
|
|
|
|
const navItemPageId = item.dataset.pageName + "-page"
|
2021-01-29 08:30:05 +00:00
|
|
|
for (const page of pages) {
|
2021-01-22 07:57:23 +00:00
|
|
|
if (page.id === navItemPageId) {
|
|
|
|
page.style.display = "block";
|
|
|
|
} else {
|
|
|
|
page.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const connectProfile = () => {
|
|
|
|
const games = document.querySelector("#profile-games");
|
|
|
|
const achievements = document.querySelector("#profile-achievements");
|
|
|
|
|
|
|
|
games.children[0].addEventListener("click", (clickEvent) => {
|
2021-01-29 08:30:05 +00:00
|
|
|
for (const page of pages) {
|
2021-01-22 07:57:23 +00:00
|
|
|
if (page.id === "games-page") {
|
|
|
|
page.style.display = "block";
|
|
|
|
} else {
|
|
|
|
page.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
achievements.children[0].addEventListener("click", (clickEvent) => {
|
|
|
|
for (page of pages) {
|
|
|
|
if (page.id === "achievements-page") {
|
|
|
|
page.style.display = "block";
|
|
|
|
} else {
|
|
|
|
page.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadFilters = () => {
|
|
|
|
const filters = document.querySelectorAll(".list-page-filter");
|
|
|
|
for (let filter of filters) {
|
|
|
|
filter.addEventListener("click", (clickEvent) => {
|
|
|
|
if (filter.classList.contains("selected")) {
|
|
|
|
filter.classList.remove("selected");
|
|
|
|
} else {
|
|
|
|
filter.classList.add("selected");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-29 08:30:05 +00:00
|
|
|
window.addEventListener("load", async (loadEvent) => {
|
|
|
|
await expandTemplates();
|
|
|
|
|
2021-01-22 07:57:23 +00:00
|
|
|
loadPages();
|
|
|
|
|
|
|
|
connectNavbar();
|
|
|
|
connectProfile();
|
|
|
|
|
|
|
|
loadFilters();
|
|
|
|
});
|