aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/pages/maplist.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/pages/maplist.js')
-rw-r--r--frontend/src/components/pages/maplist.js341
1 files changed, 190 insertions, 151 deletions
diff --git a/frontend/src/components/pages/maplist.js b/frontend/src/components/pages/maplist.js
index a7464e9..a5c6c19 100644
--- a/frontend/src/components/pages/maplist.js
+++ b/frontend/src/components/pages/maplist.js
@@ -1,5 +1,5 @@
1import React, { useEffect, useRef, useState } from 'react'; 1import React, { useEffect, useRef, useState } from 'react';
2import { useLocation, Link } from "react-router-dom"; 2import { useLocation, Link } from "react-router-dom";
3import { BrowserRouter as Router, Route, Routes, useNavigate } from 'react-router-dom'; 3import { BrowserRouter as Router, Route, Routes, useNavigate } from 'react-router-dom';
4 4
5import "./maplist.css" 5import "./maplist.css"
@@ -7,12 +7,16 @@ import img5 from "../../imgs/5.png"
7import img6 from "../../imgs/6.png" 7import img6 from "../../imgs/6.png"
8 8
9export default function Maplist(prop) { 9export default function Maplist(prop) {
10 const {token,setToken} = prop 10 const { token, setToken } = prop
11 const scrollRef = useRef(null) 11 const scrollRef = useRef(null)
12 const [games, setGames] = React.useState(null); 12 const [games, setGames] = React.useState(null);
13 const [hasOpenedStatistics, setHasOpenedStatistics] = React.useState(false);
14 const [totalPortals, setTotalPortals] = React.useState(0);
15 const [loading, setLoading] = React.useState(true)
13 const location = useLocation(); 16 const location = useLocation();
14 17
15 let gameTitle; 18 const [gameTitle, setGameTitle] = React.useState("");
19 const [catPortalCount, setCatPortalCount] = React.useState(0);
16 let minPage; 20 let minPage;
17 let maxPage; 21 let maxPage;
18 let currentPage; 22 let currentPage;
@@ -33,23 +37,21 @@ export default function Maplist(prop) {
33 const params = new URLSearchParams(url.search) 37 const params = new URLSearchParams(url.search)
34 gameState = parseFloat(location.pathname.split("/")[2]) 38 gameState = parseFloat(location.pathname.split("/")[2])
35 39
36 document.querySelector("#catPortalCount").innerText = data.data[gameState - 1].category_portals[0].portal_count; 40 if (gameState == 1) {
37 41 setGameTitle(data.data[0].name);
38 if (gameState == 1){
39 gameTitle = data.data[0].name;
40 42
41 maxPage = 9; 43 maxPage = 9;
42 minPage = 1; 44 minPage = 1;
43 createCategories(1); 45 createCategories(1);
44 } else if (gameState == 2){ 46 } else if (gameState == 2) {
45 gameTitle = data.data[1].name; 47 setGameTitle(data.data[1].name);
46 48
47 maxPage = 16; 49 maxPage = 16;
48 minPage = 10; 50 minPage = 10;
49 add = 10 51 add = 10
50 createCategories(2); 52 createCategories(2);
51 } 53 }
52 54
53 let chapterParam = params.get("chapter") 55 let chapterParam = params.get("chapter")
54 56
55 currentPage = minPage; 57 currentPage = minPage;
@@ -60,14 +62,22 @@ export default function Maplist(prop) {
60 62
61 changePage(currentPage); 63 changePage(currentPage);
62 64
65 // if (!loading) {
66
67 // document.querySelector("#catPortalCount").innerText = data.data[gameState - 1].category_portals[0].portal_count;
68
69 // }
70
71 setCatPortalCount(data.data[gameState - 1].category_portals[0].portal_count);
72
63 // if (chapterParam) { 73 // if (chapterParam) {
64 // document.querySelector("#pageNumbers").innerText = `${chapterParam - minPage + 1}/${maxPage - minPage + 1}` 74 // document.querySelector("#pageNumbers").innerText = `${chapterParam - minPage + 1}/${maxPage - minPage + 1}`
65 // } 75 // }
66 } 76 }
67 77
68 function changeMaplistOrStatistics(index, name) { 78 function changeMaplistOrStatistics(index, name) {
69 const maplistBtns = document.querySelectorAll("#maplistBtn"); 79 const maplistBtns = document.querySelectorAll("#maplistBtn");
70 maplistBtns.forEach((btn, i) => { 80 maplistBtns.forEach((btn, i) => {
71 if (i == index) { 81 if (i == index) {
72 btn.className = "game-nav-btn selected" 82 btn.className = "game-nav-btn selected"
73 83
@@ -78,9 +88,10 @@ export default function Maplist(prop) {
78 } else { 88 } else {
79 document.querySelector(".stats").style.display = "block"; 89 document.querySelector(".stats").style.display = "block";
80 document.querySelector(".maplist").style.display = "none"; 90 document.querySelector(".maplist").style.display = "none";
81 91
82 document.querySelector(".maplist-page").scrollTo({ top: 372, behavior: "smooth" }) 92 document.querySelector(".maplist-page").scrollTo({ top: 372, behavior: "smooth" })
83 document.querySelector(".maplist").setAttribute("currentTab", "stats"); 93 document.querySelector(".maplist").setAttribute("currentTab", "stats");
94 setHasOpenedStatistics(true);
84 } 95 }
85 } else { 96 } else {
86 btn.className = "game-nav-btn"; 97 btn.className = "game-nav-btn";
@@ -106,6 +117,8 @@ export default function Maplist(prop) {
106 categoriesArr.forEach((category) => { 117 categoriesArr.forEach((category) => {
107 createCategory(category); 118 createCategory(category);
108 }); 119 });
120
121 setLoading(false);
109 } 122 }
110 123
111 let categoryNum = 0; 124 let categoryNum = 0;
@@ -131,6 +144,12 @@ export default function Maplist(prop) {
131 } 144 }
132 145
133 async function changeCategory(category, btn) { 146 async function changeCategory(category, btn) {
147 const navBtns = document.querySelectorAll("#catBtn");
148 navBtns.forEach((btns) => {
149 btns.classList.remove("selected");
150 });
151
152 btn.srcElement.classList.add("selected");
134 const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { 153 const response = await fetch("https://lp.ardapektezol.com/api/v1/games", {
135 headers: { 154 headers: {
136 'Authorization': token 155 'Authorization': token
@@ -139,19 +158,13 @@ export default function Maplist(prop) {
139 158
140 const data = await response.json(); 159 const data = await response.json();
141 catState = category.category.id - 1; 160 catState = category.category.id - 1;
142 console.log(catState) 161 // console.log(catState)
143 const navBtns = document.querySelectorAll("#catBtn");
144 navBtns.forEach((btns) => {
145 btns.classList.remove("selected");
146 });
147
148 btn.srcElement.classList.add("selected");
149 document.querySelector("#catPortalCount").innerText = category.portal_count; 162 document.querySelector("#catPortalCount").innerText = category.portal_count;
150 } 163 }
151 164
152 async function changePage(page) { 165 async function changePage(page) {
153 const pageNumbers = document.querySelector("#pageNumbers"); 166 const pageNumbers = document.querySelector("#pageNumbers");
154 167
155 pageNumbers.innerText = `${currentPage - minPage + 1}/${maxPage - minPage + 1}`; 168 pageNumbers.innerText = `${currentPage - minPage + 1}/${maxPage - minPage + 1}`;
156 169
157 const maplistMaps = document.querySelector(".maplist-maps"); 170 const maplistMaps = document.querySelector(".maplist-maps");
@@ -165,7 +178,7 @@ export default function Maplist(prop) {
165 const data = await fetchMaps(page); 178 const data = await fetchMaps(page);
166 const maps = data.data.maps; 179 const maps = data.data.maps;
167 const name = data.data.chapter.name; 180 const name = data.data.chapter.name;
168 181
169 let chapterName = "Chapter"; 182 let chapterName = "Chapter";
170 const chapterNumberOld = name.split(" - ")[0]; 183 const chapterNumberOld = name.split(" - ")[0];
171 let chapterNumber1 = chapterNumberOld.split("Chapter ")[1]; 184 let chapterNumber1 = chapterNumberOld.split("Chapter ")[1];
@@ -195,13 +208,10 @@ export default function Maplist(prop) {
195 addMap(map.name, portalCount, map.image, map.difficulty + 1, map.id); 208 addMap(map.name, portalCount, map.image, map.difficulty + 1, map.id);
196 }); 209 });
197 210
198 const gameTitleElement = document.querySelector("#gameTitle");
199 gameTitleElement.innerText = gameTitle;
200
201 const url = new URL(window.location.href) 211 const url = new URL(window.location.href)
202 212
203 const params = new URLSearchParams(url.search) 213 const params = new URLSearchParams(url.search)
204 214
205 let chapterParam = params.get("chapter") 215 let chapterParam = params.get("chapter")
206 216
207 try { 217 try {
@@ -263,10 +273,10 @@ export default function Maplist(prop) {
263 difficultyPoint3.className = "difficulty-point"; 273 difficultyPoint3.className = "difficulty-point";
264 difficultyPoint4.className = "difficulty-point"; 274 difficultyPoint4.className = "difficulty-point";
265 difficultyPoint5.className = "difficulty-point"; 275 difficultyPoint5.className = "difficulty-point";
266 276
267 277
268 maplistTitle.innerText = mapName; 278 maplistTitle.innerText = mapName;
269 difficultyLabel.innerText = "Difficulty: " 279 difficultyLabel.innerText = "Difficulty: "
270 maplistPortalcountPortals.innerText = "portals" 280 maplistPortalcountPortals.innerText = "portals"
271 b.innerText = mapPortalCount; 281 b.innerText = mapPortalCount;
272 maplistImg.style.backgroundImage = `url(${mapImage})`; 282 maplistImg.style.backgroundImage = `url(${mapImage})`;
@@ -301,7 +311,7 @@ export default function Maplist(prop) {
301 } 311 }
302 312
303 async function fetchMaps(chapterID) { 313 async function fetchMaps(chapterID) {
304 try{ 314 try {
305 const response = await fetch(`https://lp.ardapektezol.com/api/v1/chapters/${chapterID}`, { 315 const response = await fetch(`https://lp.ardapektezol.com/api/v1/chapters/${chapterID}`, {
306 headers: { 316 headers: {
307 'Authorization': token 317 'Authorization': token
@@ -349,92 +359,108 @@ export default function Maplist(prop) {
349 React.useEffect(() => { 359 React.useEffect(() => {
350 360
351 const lineChart = document.querySelector(".line-chart") 361 const lineChart = document.querySelector(".line-chart")
352 function createGraph() { 362 let tempTotalPortals = 0
363 fetch("https://lp.ardapektezol.com/api/v1/games/1/maps", {
364 headers: {
365 'Authorization': token
366 }
367 })
368 .then(r => r.json())
369 .then(d => {
370 d.data.maps.forEach((map, i) => {
371 tempTotalPortals += map.portal_count
372 })
373 })
374 .then(() => {
375 setTotalPortals(tempTotalPortals)
376 })
377 async function createGraph() {
378 console.log(totalPortals)
353 // max 379 // max
354 let items = [ 380 let items = [
355 { 381 {
356 record: "100", 382 record: "100",
357 date: new Date(2011, 4, 4), 383 date: new Date(2011, 4, 4),
358 map: "Container Ride", 384 map: "Container Ride",
359 first: "tiny zach" 385 first: "tiny zach"
360 }, 386 },
361 { 387 {
362 record: "98", 388 record: "98",
363 date: new Date(2012, 6, 4), 389 date: new Date(2012, 6, 4),
364 map: "Container Ride", 390 map: "Container Ride",
365 first: "tiny zach" 391 first: "tiny zach"
366 }, 392 },
367 { 393 {
368 record: "94", 394 record: "94",
369 date: new Date(2013, 0, 1), 395 date: new Date(2013, 0, 1),
370 map: "Container Ride", 396 map: "Container Ride",
371 first: "tiny zach" 397 first: "tiny zach"
372 }, 398 },
373 { 399 {
374 record: "90", 400 record: "90",
375 date: new Date(2014, 0, 1), 401 date: new Date(2014, 0, 1),
376 map: "Container Ride", 402 map: "Container Ride",
377 first: "tiny zach" 403 first: "tiny zach"
378 }, 404 },
379 { 405 {
380 record: "88", 406 record: "88",
381 date: new Date(2015, 6, 14), 407 date: new Date(2015, 6, 14),
382 map: "Container Ride", 408 map: "Container Ride",
383 first: "tiny zach" 409 first: "tiny zach"
384 }, 410 },
385 { 411 {
386 record: "84", 412 record: "84",
387 date: new Date(2016, 8, 19), 413 date: new Date(2016, 8, 19),
388 map: "Container Ride", 414 map: "Container Ride",
389 first: "tiny zach" 415 first: "tiny zach"
390 }, 416 },
391 { 417 {
392 record: "82", 418 record: "82",
393 date: new Date(2017, 3, 20), 419 date: new Date(2017, 3, 20),
394 map: "Container Ride", 420 map: "Container Ride",
395 first: "tiny zach" 421 first: "tiny zach"
396 }, 422 },
397 { 423 {
398 record: "81", 424 record: "81",
399 date: new Date(2018, 2, 25), 425 date: new Date(2018, 2, 25),
400 map: "Container Ride", 426 map: "Container Ride",
401 first: "tiny zach" 427 first: "tiny zach"
402 }, 428 },
403 { 429 {
404 record: "80", 430 record: "80",
405 date: new Date(2019, 3, 4), 431 date: new Date(2019, 3, 4),
406 map: "Container Ride", 432 map: "Container Ride",
407 first: "tiny zach" 433 first: "tiny zach"
408 }, 434 },
409 { 435 {
410 record: "78", 436 record: "78",
411 date: new Date(2020, 11, 21), 437 date: new Date(2020, 11, 21),
412 map: "Container Ride", 438 map: "Container Ride",
413 first: "tiny zach" 439 first: "tiny zach"
414 }, 440 },
415 { 441 {
416 record: "77", 442 record: "77",
417 date: new Date(2021, 10, 25), 443 date: new Date(2021, 10, 25),
418 map: "Container Ride", 444 map: "Container Ride",
419 first: "tiny zach" 445 first: "tiny zach"
420 }, 446 },
421 { 447 {
422 record: "76", 448 record: "76",
423 date: new Date(2022, 4, 17), 449 date: new Date(2022, 4, 17),
424 map: "Container Ride", 450 map: "Container Ride",
425 first: "tiny zach" 451 first: "tiny zach"
426 }, 452 },
427 { 453 {
428 record: "75", 454 record: "75",
429 date: new Date(2023, 9, 31), 455 date: new Date(2023, 9, 31),
430 map: "Container Ride", 456 map: "Container Ride",
431 first: "tiny zach" 457 first: "tiny zach"
432 }, 458 },
433 { 459 {
434 record: "74", 460 record: "74",
435 date: new Date(2024, 4, 4), 461 date: new Date(2024, 4, 4),
436 map: "Container Ride", 462 map: "Container Ride",
437 first: "tiny zach" 463 first: "tiny zach"
438 }, 464 },
439 ] 465 ]
440 466
@@ -449,7 +475,7 @@ export default function Maplist(prop) {
449 475
450 const graph_width = document.querySelector(".portalcount-over-time-div").clientWidth 476 const graph_width = document.querySelector(".portalcount-over-time-div").clientWidth
451 // console.log(graph_width) 477 // console.log(graph_width)
452 478
453 const uniqueYears = new Set() 479 const uniqueYears = new Set()
454 items.forEach(dp => uniqueYears.add(dp.date.getFullYear())) 480 items.forEach(dp => uniqueYears.add(dp.date.getFullYear()))
455 let minYear = Infinity; 481 let minYear = Infinity;
@@ -474,7 +500,7 @@ export default function Maplist(prop) {
474 map: dp.map, 500 map: dp.map,
475 first: dp.first 501 first: dp.first
476 })) 502 }))
477 503
478 const yearInterval = lineChart.clientWidth / uniqueYears.size 504 const yearInterval = lineChart.clientWidth / uniqueYears.size
479 for (let index = 1; index < (uniqueYears.size); index++) { 505 for (let index = 1; index < (uniqueYears.size); index++) {
480 const placeholderlmao = document.createElement("div") 506 const placeholderlmao = document.createElement("div")
@@ -493,7 +519,7 @@ export default function Maplist(prop) {
493 yearSpan.style.fontSize = "22px" 519 yearSpan.style.fontSize = "22px"
494 yearSpan.style.opacity = "0.8" 520 yearSpan.style.opacity = "0.8"
495 lineChart.appendChild(yearSpan) 521 lineChart.appendChild(yearSpan)
496 522
497 } 523 }
498 524
499 let maxPortals; 525 let maxPortals;
@@ -529,19 +555,19 @@ export default function Maplist(prop) {
529 555
530 function calculateIntermediateControlPoints(t, P0, P1, P2, P3) { 556 function calculateIntermediateControlPoints(t, P0, P1, P2, P3) {
531 const x = (1 - t) ** 3 * P0.x + 557 const x = (1 - t) ** 3 * P0.x +
532 3 * (1 - t) ** 2 * t * P1.x + 558 3 * (1 - t) ** 2 * t * P1.x +
533 3 * (1 - t) * t ** 2 * P2.x + 559 3 * (1 - t) * t ** 2 * P2.x +
534 t ** 3 * P3.x; 560 t ** 3 * P3.x;
535 561
536 const y = (1 - t) ** 3 * P0.y + 562 const y = (1 - t) ** 3 * P0.y +
537 3 * (1 - t) ** 2 * t * P1.y + 563 3 * (1 - t) ** 2 * t * P1.y +
538 3 * (1 - t) * t ** 2 * P2.y + 564 3 * (1 - t) * t ** 2 * P2.y +
539 t ** 3 * P3.y; 565 t ** 3 * P3.y;
540 566
541 return { x, y }; 567 return { x, y };
542 } 568 }
543 569
544 570
545 let delay = 0; 571 let delay = 0;
546 for (let index = 0; index < items.length; index++) { 572 for (let index = 0; index < items.length; index++) {
547 let chart_height = 340; 573 let chart_height = 340;
@@ -587,11 +613,11 @@ export default function Maplist(prop) {
587 numPortalsText.style.bottom = `${(point_height * current_portal_count * multiplier) - 2 - 9}px` 613 numPortalsText.style.bottom = `${(point_height * current_portal_count * multiplier) - 2 - 9}px`
588 numPortalsTextBottom.style.bottom = `${0 - 2 - 8}px` 614 numPortalsTextBottom.style.bottom = `${0 - 2 - 8}px`
589 placeholderDiv.id = placeholderDiv.style.bottom 615 placeholderDiv.id = placeholderDiv.style.bottom
590 placeholderDiv.style.width = "100%" 616 placeholderDiv.style.width = "100%"
591 placeholderDiv.style.height = "2px" 617 placeholderDiv.style.height = "2px"
592 placeholderDiv.style.backgroundColor = "#2B2E46" 618 placeholderDiv.style.backgroundColor = "#2B2E46"
593 placeholderDiv.style.zIndex = "0" 619 placeholderDiv.style.zIndex = "0"
594 620
595 if (index == 0) { 621 if (index == 0) {
596 lineChart.appendChild(numPortalsTextBottom) 622 lineChart.appendChild(numPortalsTextBottom)
597 } 623 }
@@ -627,11 +653,11 @@ export default function Maplist(prop) {
627 lineSeg.style.animationDelay = delay + "s" 653 lineSeg.style.animationDelay = delay + "s"
628 } 654 }
629 dataPoint.style.animationDelay = delay + "s" 655 dataPoint.style.animationDelay = delay + "s"
630 656
631 let isHoveringOverData = true; 657 let isHoveringOverData = true;
632 let isDataActive = false; 658 let isDataActive = false;
633 document.querySelector("#dataPointInfo").style.left = item.x + "px"; 659 document.querySelector("#dataPointInfo").style.left = item.x + "px";
634 document.querySelector("#dataPointInfo").style.bottom = (point_height * item.record -3) + "px"; 660 document.querySelector("#dataPointInfo").style.bottom = (point_height * item.record - 3) + "px";
635 dataPoint.addEventListener("mouseenter", (e) => { 661 dataPoint.addEventListener("mouseenter", (e) => {
636 isDataActive = true; 662 isDataActive = true;
637 isHoveringOverData = true; 663 isHoveringOverData = true;
@@ -645,14 +671,14 @@ export default function Maplist(prop) {
645 document.querySelector("#dataPointDate").innerText = item.date.toLocaleDateString("en-GB"); 671 document.querySelector("#dataPointDate").innerText = item.date.toLocaleDateString("en-GB");
646 document.querySelector("#dataPointFirst").innerText = item.first; 672 document.querySelector("#dataPointFirst").innerText = item.first;
647 if ((lineChart.clientWidth - 400) < item.x) { 673 if ((lineChart.clientWidth - 400) < item.x) {
648 document.querySelector("#dataPointInfo").style.left = item.x - 400 + "px"; 674 document.querySelector("#dataPointInfo").style.left = item.x - 400 + "px";
649 } else { 675 } else {
650 document.querySelector("#dataPointInfo").style.left = item.x + "px"; 676 document.querySelector("#dataPointInfo").style.left = item.x + "px";
651 } 677 }
652 if ((lineChart.clientHeight - 115) < (point_height * (item.record - minPortals) -3)) { 678 if ((lineChart.clientHeight - 115) < (point_height * (item.record - minPortals) - 3)) {
653 document.querySelector("#dataPointInfo").style.bottom = (point_height * (item.record - minPortals) -3) - 115 + "px"; 679 document.querySelector("#dataPointInfo").style.bottom = (point_height * (item.record - minPortals) - 3) - 115 + "px";
654 } else { 680 } else {
655 document.querySelector("#dataPointInfo").style.bottom = (point_height * (item.record - minPortals) -3) + "px"; 681 document.querySelector("#dataPointInfo").style.bottom = (point_height * (item.record - minPortals) - 3) + "px";
656 } 682 }
657 document.querySelector("#dataPointInfo").style.opacity = "1"; 683 document.querySelector("#dataPointInfo").style.opacity = "1";
658 document.querySelector("#dataPointInfo").style.zIndex = "10"; 684 document.querySelector("#dataPointInfo").style.zIndex = "10";
@@ -689,8 +715,6 @@ export default function Maplist(prop) {
689 } 715 }
690 } 716 }
691 717
692 createGraph()
693
694 async function fetchGames() { 718 async function fetchGames() {
695 try { 719 try {
696 const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { 720 const response = await fetch("https://lp.ardapektezol.com/api/v1/games", {
@@ -726,40 +750,42 @@ export default function Maplist(prop) {
726 750
727 const handleResize = (entries) => { 751 const handleResize = (entries) => {
728 for (let entry of entries) { 752 for (let entry of entries) {
729 lineChart.innerHTML = "" 753 if (hasOpenedStatistics) {
730 createGraph() 754 lineChart.innerHTML = ""
755 createGraph()
756 }
731 if (document.querySelector(".maplist").getAttribute("currentTab") == "stats") { 757 if (document.querySelector(".maplist").getAttribute("currentTab") == "stats") {
732 document.querySelector(".stats").style.display = "block" 758 document.querySelector(".stats").style.display = "block"
733 } else { 759 } else {
734 document.querySelector(".stats").style.display = "none" 760 document.querySelector(".stats").style.display = "none"
735 } 761 }
736 } 762 }
737 }; 763 };
738 764
739 const resizeObserver = new ResizeObserver(handleResize); 765 const resizeObserver = new ResizeObserver(handleResize);
740 766
741 // if (scrollRef.current) { 767 // if (scrollRef.current) {
742 // //hi 768 // //hi
743 // if (new URLSearchParams(new URL(window.location.href).search).get("chapter")) { 769 // if (new URLSearchParams(new URL(window.location.href).search).get("chapter")) {
744 // setTimeout(() => { 770 // setTimeout(() => {
745 // scrollRef.current.scrollIntoView({ behavior: "smooth", block: "start" }) 771 // scrollRef.current.scrollIntoView({ behavior: "smooth", block: "start" })
746 // }, 200); 772 // }, 200);
747 // } 773 // }
748 774
749 // } 775 // }
750 776
751 if (divRef.current) { 777 if (divRef.current) {
752 resizeObserver.observe(divRef.current); 778 resizeObserver.observe(divRef.current);
753 } 779 }
754 780
755 return () => { 781 return () => {
756 if (divRef.current) { 782 if (divRef.current) {
757 resizeObserver.unobserve(divRef.current); 783 resizeObserver.unobserve(divRef.current);
758 } 784 }
759 resizeObserver.disconnect(); 785 resizeObserver.disconnect();
760 }; 786 };
787
761 788
762
763 }) 789 })
764 return ( 790 return (
765 <div ref={divRef} className='maplist-page'> 791 <div ref={divRef} className='maplist-page'>
@@ -769,36 +795,49 @@ export default function Maplist(prop) {
769 <i className='triangle'></i> 795 <i className='triangle'></i>
770 <span>Games list</span> 796 <span>Games list</span>
771 </button></Link> 797 </button></Link>
772 <span><b id='gameTitle'>&nbsp;</b></span> 798 {!loading ?
799 <span><b id='gameTitle'>{gameTitle}</b></span>
800 :
801 <span><b id='gameTitle' className='loader-text'>LOADINGLOADING</b></span>}
773 </section> 802 </section>
774 803
775 <div className='game'> 804 <div className='game'>
776 <div className='game-header'> 805 {!loading ?
777 <div className='game-img'></div> 806 <div className='game-header'>
778 <div className='game-header-text'> 807 <div className='game-img'></div>
779 <span><b id='catPortalCount'>0</b></span> 808 <div className='game-header-text'>
780 <span>portals</span> 809 <span><b id='catPortalCount'>{catPortalCount}</b></span>
810 <span>portals</span>
811 </div>
781 </div> 812 </div>
782 </div> 813 : <div className='game-header loader'>
783 814 <div className='game-img'></div>
784 <div className='game-nav'> 815 <div className='game-header-text'>
785 </div> 816 <span className='loader-text'><b id='catPortalCount'>00</b></span>
817 <span className='loader-text'>portals</span>
818 </div>
819 </div>}
820 {!loading ?
821 <div className='game-nav'>
822 </div>
823 : <div className='game-nav loader'>
824 </div>}
786 </div> 825 </div>
787 826
788 <div className='gameview-nav'> 827 <div className='gameview-nav'>
789 <button id='maplistBtn' onClick={() => {changeMaplistOrStatistics(0, "maplist")}} className='game-nav-btn selected'> 828 <button id='maplistBtn' onClick={() => { changeMaplistOrStatistics(0, "maplist") }} className='game-nav-btn selected'>
790 <img id='maplistImg'/> 829 <img id='maplistImg' />
791 <span>Map List</span> 830 <span>Map List</span>
792 </button> 831 </button>
793 <button id='maplistBtn' onClick={() => changeMaplistOrStatistics(1, "stats")} className='game-nav-btn'> 832 <button id='maplistBtn' onClick={() => changeMaplistOrStatistics(1, "stats")} className='game-nav-btn'>
794 <img id='statisticsImg'/> 833 <img id='statisticsImg' />
795 <span>Statistics</span> 834 <span>Statistics</span>
796 </button> 835 </button>
797 </div> 836 </div>
798 837
799 <div ref={scrollRef} className='maplist'> 838 <div ref={scrollRef} className='maplist'>
800 <div className='chapter'> 839 <div className='chapter'>
801 <span className='chapter-num'>undefined</span><br/> 840 <span className='chapter-num'>undefined</span><br />
802 <span className='chapter-name'>undefined</span> 841 <span className='chapter-name'>undefined</span>
803 842
804 <div className='chapter-page-div'> 843 <div className='chapter-page-div'>
@@ -810,19 +849,19 @@ export default function Maplist(prop) {
810 <i style={{ transform: "rotate(180deg)" }} className='triangle'></i> 849 <i style={{ transform: "rotate(180deg)" }} className='triangle'></i>
811 </button> 850 </button>
812 </div> 851 </div>
813 852
814 <div className='maplist-maps'> 853 <div className='maplist-maps'>
815 </div> 854 </div>
816 </div> 855 </div>
817 </div> 856 </div>
818 857
819 <div style={{display: "block"}} className='stats'> 858 <div style={{ display: "block" }} className='stats'>
820 <div className='portalcount-over-time-div'> 859 <div className='portalcount-over-time-div'>
821 <span className='graph-title'>Portal count over time</span><br/> 860 <span className='graph-title'>Portal count over time</span><br />
822 861
823 <div className='portalcount-graph'> 862 <div className='portalcount-graph'>
824 <figure className='chart'> 863 <figure className='chart'>
825 <div style={{display: "block"}}></div> 864 <div style={{ display: "block" }}></div>
826 <div id="dataPointInfo"> 865 <div id="dataPointInfo">
827 <div className='section-header'> 866 <div className='section-header'>
828 <span className='header-title'>Date</span> 867 <span className='header-title'>Date</span>
@@ -839,7 +878,7 @@ export default function Maplist(prop) {
839 </div> 878 </div>
840 </div> 879 </div>
841 <ul className='line-chart'> 880 <ul className='line-chart'>
842 881
843 </ul> 882 </ul>
844 </figure> 883 </figure>
845 </div> 884 </div>