diff options
| author | Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> | 2024-07-13 00:15:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-13 01:15:58 +0300 |
| commit | 83d2243c65bf5fce5c75ef3753595d38f4d545d5 (patch) | |
| tree | 9373c05bbf60c8b63688056dc51feb6823c2e313 /frontend/src/components | |
| parent | fix: empty country code on new account (#187) (diff) | |
| download | lphub-83d2243c65bf5fce5c75ef3753595d38f4d545d5.tar.gz lphub-83d2243c65bf5fce5c75ef3753595d38f4d545d5.tar.bz2 lphub-83d2243c65bf5fce5c75ef3753595d38f4d545d5.zip | |
feat: fixes, styles, partial homepage implementation and maplist header loader (#188)
Diffstat (limited to 'frontend/src/components')
| -rw-r--r-- | frontend/src/components/pages/home.css | 12 | ||||
| -rw-r--r-- | frontend/src/components/pages/home.js | 125 | ||||
| -rw-r--r-- | frontend/src/components/pages/maplist.css | 12 | ||||
| -rw-r--r-- | frontend/src/components/pages/maplist.js | 341 | ||||
| -rw-r--r-- | frontend/src/components/sidebar.js | 1 |
5 files changed, 302 insertions, 189 deletions
diff --git a/frontend/src/components/pages/home.css b/frontend/src/components/pages/home.css index 072b12b..e5a8eab 100644 --- a/frontend/src/components/pages/home.css +++ b/frontend/src/components/pages/home.css | |||
| @@ -68,9 +68,11 @@ | |||
| 68 | 68 | ||
| 69 | .recommended-map-img { | 69 | .recommended-map-img { |
| 70 | width: 250px; | 70 | width: 250px; |
| 71 | border-radius: 24px; | 71 | border-radius: 19px; |
| 72 | margin-bottom: 0; | 72 | margin-bottom: 0; |
| 73 | border: 7px solid #2B2E46; | 73 | /* border: 7px solid #2B2E46; */ |
| 74 | background-size: cover; | ||
| 75 | background-position-x: 50%; | ||
| 74 | } | 76 | } |
| 75 | 77 | ||
| 76 | .difficulty-bar-home { | 78 | .difficulty-bar-home { |
| @@ -78,13 +80,13 @@ | |||
| 78 | display: grid; | 80 | display: grid; |
| 79 | grid-template-columns: 20% 20% 20% 20% 20%; | 81 | grid-template-columns: 20% 20% 20% 20% 20%; |
| 80 | align-items: center; | 82 | align-items: center; |
| 81 | margin: 5px; | 83 | margin: 0px; |
| 82 | margin-top: 16px; | 84 | margin-top: 7px; |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | .difficulty-point { | 87 | .difficulty-point { |
| 86 | background: #2B2E46; | 88 | background: #2B2E46; |
| 87 | height: 3px; | 89 | height: 4px; |
| 88 | margin: 5px; | 90 | margin: 5px; |
| 89 | border-radius: 10px; | 91 | border-radius: 10px; |
| 90 | } | 92 | } |
diff --git a/frontend/src/components/pages/home.js b/frontend/src/components/pages/home.js index c1477ab..55e58a8 100644 --- a/frontend/src/components/pages/home.js +++ b/frontend/src/components/pages/home.js | |||
| @@ -4,14 +4,45 @@ import { useLocation, Link } from "react-router-dom"; | |||
| 4 | import "./home.css" | 4 | import "./home.css" |
| 5 | import News from '../news'; | 5 | import News from '../news'; |
| 6 | import Record from '../record'; | 6 | import Record from '../record'; |
| 7 | import Login from '../login'; | ||
| 7 | 8 | ||
| 8 | export default function Homepage(prop) { | 9 | export default function Homepage(prop) { |
| 9 | const {token, setToken} = prop | 10 | const { token, setToken } = prop |
| 10 | const [home, setHome] = React.useState(null); | 11 | const [home, setHome] = React.useState(null); |
| 12 | const [profile, setProfile] = React.useState(null); | ||
| 13 | const [loading, setLoading] = React.useState(true) | ||
| 11 | const location = useLocation(); | 14 | const location = useLocation(); |
| 12 | 15 | ||
| 16 | const [isLoggedIn, setIsLoggedIn] = React.useState(false); | ||
| 17 | React.useEffect(() => { | ||
| 18 | try { | ||
| 19 | fetch(`https://lp.ardapektezol.com/api/v1/profile`, { | ||
| 20 | headers: { | ||
| 21 | 'Content-Type': 'application/json', | ||
| 22 | Authorization: token | ||
| 23 | } | ||
| 24 | }) | ||
| 25 | .then(r => r.json()) | ||
| 26 | .then(d => setProfile(d.data)) | ||
| 27 | .then(d => { | ||
| 28 | if (profile != null) { | ||
| 29 | setIsLoggedIn(true) | ||
| 30 | } | ||
| 31 | }) | ||
| 32 | .then(d => { | ||
| 33 | setLoading(false) | ||
| 34 | }) | ||
| 35 | } catch (error) { | ||
| 36 | console.log(error) | ||
| 37 | } | ||
| 38 | |||
| 39 | }, [token, profile]); | ||
| 40 | |||
| 13 | useEffect(() => { | 41 | useEffect(() => { |
| 14 | async function fetchMapImg() { | 42 | async function fetchMapImg() { |
| 43 | if (!isLoggedIn) { | ||
| 44 | return; | ||
| 45 | } | ||
| 15 | try { | 46 | try { |
| 16 | const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { | 47 | const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { |
| 17 | headers: { | 48 | headers: { |
| @@ -23,11 +54,11 @@ export default function Homepage(prop) { | |||
| 23 | 54 | ||
| 24 | const recommendedMapImg = document.querySelector("#recommendedMapImg"); | 55 | const recommendedMapImg = document.querySelector("#recommendedMapImg"); |
| 25 | 56 | ||
| 26 | recommendedMapImg.src = `${data.data[0].image}` | 57 | recommendedMapImg.style.backgroundImage = `url(${data.data[0].image})` |
| 27 | 58 | ||
| 28 | const column1 = document.querySelector("#column1"); | 59 | const column1 = document.querySelector("#column1"); |
| 29 | const column2 = document.querySelector("#column2"); | 60 | const column2 = document.querySelector("#column2"); |
| 30 | 61 | ||
| 31 | column2.style.height = column1.clientHeight + "px"; | 62 | column2.style.height = column1.clientHeight + "px"; |
| 32 | } catch (error) { | 63 | } catch (error) { |
| 33 | console.log(error) | 64 | console.log(error) |
| @@ -115,41 +146,57 @@ export default function Homepage(prop) { | |||
| 115 | }, | 146 | }, |
| 116 | ] | 147 | ] |
| 117 | 148 | ||
| 149 | if (loading) { | ||
| 150 | return ( | ||
| 151 | <main> | ||
| 152 | </main> | ||
| 153 | ) | ||
| 154 | } | ||
| 155 | |||
| 118 | return ( | 156 | return ( |
| 119 | <main> | 157 | <main> |
| 120 | <section style={{marginTop: "40px", userSelect: "none"}}> | 158 | <section style={{ userSelect: "none", display: "flex" }}> |
| 121 | <span style={{fontSize: "40px"}}>Welcome back,</span><br/> | 159 | <h1 style={{ marginTop: "53.6px", fontSize: "80px", marginBottom: "15px" }}>Home</h1> |
| 122 | <span><b style={{ fontSize: "96px", transform: "translateY(-20px)", display: "block"}}>Krzyhau</b></span> | 160 | {isLoggedIn ? |
| 161 | <div style={{ textAlign: "right", width: "100%", marginTop: "20px" }}> | ||
| 162 | <span style={{ fontSize: "25px" }}>Welcome back,</span><br /> | ||
| 163 | |||
| 164 | <span><b style={{ fontSize: "80px", transform: "translateY(-20px)", display: "block" }}>Wolfboy248</b></span> | ||
| 165 | </div> | ||
| 166 | : null} | ||
| 123 | </section> | 167 | </section> |
| 124 | 168 | ||
| 125 | <div style={{display: "grid", gridTemplateColumns: "calc(50%) calc(50%)"}}> | 169 | <div style={{ display: "grid", gridTemplateColumns: "calc(50%) calc(50%)" }}> |
| 126 | <div id='column1' style={{ display: "flex", alignItems: "self-start", flexWrap: "wrap", alignContent: "start" }}> | 170 | <div id='column1' style={{ display: "flex", alignItems: "self-start", flexWrap: "wrap", alignContent: "start" }}> |
| 127 | {/* Column 1 */} | 171 | {/* Column 1 */} |
| 172 | {isLoggedIn ? | ||
| 128 | <section title="Your Profile" className='homepage-panel'> | 173 | <section title="Your Profile" className='homepage-panel'> |
| 129 | <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "12px"}}> | 174 | <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "12px" }}> |
| 130 | <div className='stats-div'> | 175 | <div className='stats-div'> |
| 131 | <span>Overall rank</span><br/> | 176 | <span>Overall rank</span><br /> |
| 132 | <span><b>#69</b></span> | 177 | <span><b>{profile.rankings.overall.rank > 0 ? "#" + profile.rankings.overall.rank : "No rank"}</b></span> |
| 133 | </div> | 178 | </div> |
| 134 | <div className='stats-div'> | 179 | <div className='stats-div'> |
| 135 | <span>Singleplayer</span><br/> | 180 | <span>Singleplayer</span><br /> |
| 136 | <span style={{fontSize: "22px"}}><b>#10</b> (60/62)</span> | 181 | <span style={{ fontSize: "22px" }}><b>{profile.rankings.singleplayer.rank > 0 ? "#" + profile.rankings.singleplayer.rank : "No rank"}</b> {profile.rankings.singleplayer.rank > 0 ? "(" + profile.rankings.singleplayer.completion_count + "/" + profile.rankings.singleplayer.completion_total + ")" : ""}</span> |
| 137 | </div> | 182 | </div> |
| 138 | <div className='stats-div'> | 183 | <div className='stats-div'> |
| 139 | <span>Overall rank</span><br/> | 184 | <span>Cooperative rank</span><br /> |
| 140 | <span style={{fontSize: "22px"}}><b>#69</b> (13/37)</span> | 185 | <span style={{ fontSize: "22px" }}><b>{profile.rankings.cooperative.rank > 0 ? "#" + profile.rankings.cooperative.rank : "No rank"}</b> {profile.rankings.cooperative.rank > 0 ? "(" + profile.rankings.cooperative.completion_count + "/" + profile.rankings.cooperative.completion_total + ")" : ""}</span> |
| 141 | </div> | 186 | </div> |
| 142 | </div> | 187 | </div> |
| 143 | </section> | 188 | </section> |
| 189 | : null} | ||
| 190 | {isLoggedIn ? | ||
| 144 | <section title="What's Next?" className='homepage-panel'> | 191 | <section title="What's Next?" className='homepage-panel'> |
| 145 | <div style={{display: "flex"}}> | 192 | <div style={{ display: "flex" }}> |
| 146 | <img className='recommended-map-img' id="recommendedMapImg"></img> | 193 | <div className='recommended-map-img' id="recommendedMapImg"></div> |
| 147 | <div style={{marginLeft: "12px", display: "block", width: "100%"}}> | 194 | <div style={{ marginLeft: "12px", display: "block", width: "100%" }}> |
| 148 | <span style={{fontFamily: "BarlowSemiCondensed-SemiBold", fontSize: "32px", width: "100%", display: "block"}}>Container Ride</span> | 195 | <span style={{ fontFamily: "BarlowSemiCondensed-SemiBold", fontSize: "32px", width: "100%", display: "block" }}>Container Ride</span> |
| 149 | <span style={{fontSize: "20px"}}>Your Record: 4 portals</span> | 196 | <span style={{ fontSize: "20px", display: "block" }}>Your Record: 4 portals</span> |
| 150 | <span style={{fontFamily: "BarlowSemiCondensed-SemiBold", fontSize: "36px", width: "100%", display: "block"}}>World Record: 2 portals</span> | 197 | <span style={{ fontFamily: "BarlowSemiCondensed-SemiBold", fontSize: "36px", width: "100%", display: "block" }}>World Record: 2 portals</span> |
| 151 | <div className='difficulty-bar-home'> | 198 | <div className='difficulty-bar-home'> |
| 152 | <div className='difficulty-point' style={{backgroundColor: "#51C355"}}></div> | 199 | <div className='difficulty-point' style={{ backgroundColor: "#51C355" }}></div> |
| 153 | <div className='difficulty-point'></div> | 200 | <div className='difficulty-point'></div> |
| 154 | <div className='difficulty-point'></div> | 201 | <div className='difficulty-point'></div> |
| 155 | <div className='difficulty-point'></div> | 202 | <div className='difficulty-point'></div> |
| @@ -158,17 +205,39 @@ export default function Homepage(prop) { | |||
| 158 | </div> | 205 | </div> |
| 159 | </div> | 206 | </div> |
| 160 | </section> | 207 | </section> |
| 161 | <section title="Newest Records" className='homepage-panel' style={{height: "250px"}}> | 208 | : null} |
| 209 | <section title="Newest Records" className='homepage-panel' style={{ height: isLoggedIn ? "250px" : "960px" }}> | ||
| 162 | <div className='record-title'> | 210 | <div className='record-title'> |
| 163 | <div> | 211 | <div> |
| 164 | <span>Place</span> | 212 | <span>Place</span> |
| 165 | <span style={{textAlign: "left"}}>Runner</span> | 213 | <span style={{ textAlign: "left" }}>Runner</span> |
| 166 | <span>Portals</span> | 214 | <span>Portals</span> |
| 167 | <span>Time</span> | 215 | <span>Time</span> |
| 168 | <span>Date</span> | 216 | <span>Date</span> |
| 169 | </div> | 217 | </div> |
| 170 | </div> | 218 | </div> |
| 171 | <div style={{overflowY: "scroll", height: "calc(100% - 90px)", paddingRight: "10px"}}> | 219 | <div style={{ overflowY: "scroll", height: "calc(100% - 90px)", paddingRight: "10px" }}> |
| 220 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 221 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 222 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 223 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 224 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 225 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 226 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 227 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 228 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 229 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 230 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 231 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 232 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 233 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 234 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 235 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 236 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 237 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 238 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 239 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 240 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | ||
| 172 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | 241 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> |
| 173 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | 242 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> |
| 174 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> | 243 | <Record name={"Krzyhau"} portals={"2"} date={new Date("2024-05-21T08:45:00")} place={"2"} time={"20.20"}></Record> |
| @@ -180,9 +249,9 @@ export default function Homepage(prop) { | |||
| 180 | </section> | 249 | </section> |
| 181 | </div> | 250 | </div> |
| 182 | {/* Column 2 */} | 251 | {/* Column 2 */} |
| 183 | <div id='column2' style={{display: "flex", alignItems: "stretch", height: "87px"}}> | 252 | <div id='column2' style={{ display: "flex", alignItems: "stretch", height: "1000px" }}> |
| 184 | <section title="News" className='homepage-panel'> | 253 | <section title="News" className='homepage-panel'> |
| 185 | <div id='newsContent' style={{ display: "block", width: "100%", overflowY: "scroll", height: "calc(100% - 50px)"}}> | 254 | <div id='newsContent' style={{ display: "block", width: "100%", overflowY: "scroll", height: "calc(100% - 50px)" }}> |
| 186 | {newsList.map((newsList, index) => ( | 255 | {newsList.map((newsList, index) => ( |
| 187 | <News newsInfo={newsList} key={index}></News> | 256 | <News newsInfo={newsList} key={index}></News> |
| 188 | ))} | 257 | ))} |
| @@ -190,9 +259,9 @@ export default function Homepage(prop) { | |||
| 190 | </section> | 259 | </section> |
| 191 | </div> | 260 | </div> |
| 192 | </div> | 261 | </div> |
| 193 | |||
| 194 | 262 | ||
| 195 | 263 | ||
| 264 | |||
| 196 | </main> | 265 | </main> |
| 197 | ) | 266 | ) |
| 198 | } \ No newline at end of file | 267 | } \ No newline at end of file |
diff --git a/frontend/src/components/pages/maplist.css b/frontend/src/components/pages/maplist.css index 2f279c3..b56aacc 100644 --- a/frontend/src/components/pages/maplist.css +++ b/frontend/src/components/pages/maplist.css | |||
| @@ -52,7 +52,7 @@ a { | |||
| 52 | .game { | 52 | .game { |
| 53 | width: 100%; | 53 | width: 100%; |
| 54 | height: 192px; | 54 | height: 192px; |
| 55 | background: #202232; | 55 | /* background: #202232; */ |
| 56 | border-radius: 24px; | 56 | border-radius: 24px; |
| 57 | overflow: hidden; | 57 | overflow: hidden; |
| 58 | } | 58 | } |
| @@ -112,18 +112,22 @@ a { | |||
| 112 | align-items: center; | 112 | align-items: center; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | .game-nav-btn:hover, .selected { | 115 | .game-nav-btn:hover { |
| 116 | background-color: #202232; | ||
| 117 | cursor: pointer; | 116 | cursor: pointer; |
| 118 | } | 117 | } |
| 119 | 118 | ||
| 119 | .selected { | ||
| 120 | background-color: #202232; | ||
| 121 | } | ||
| 122 | |||
| 120 | .gameview-nav { | 123 | .gameview-nav { |
| 121 | margin-top: 20px; | 124 | margin-top: 20px; |
| 122 | display: flex; | 125 | display: flex; |
| 123 | height: 56px; | 126 | height: 56px; |
| 124 | border-radius: 24px; | 127 | border-radius: 24px; |
| 125 | overflow: hidden; | 128 | overflow: hidden; |
| 126 | background-color: #202232; | 129 | gap: 0.06em; |
| 130 | /* background-color: #202232; */ | ||
| 127 | } | 131 | } |
| 128 | 132 | ||
| 129 | .maplist { | 133 | .maplist { |
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 @@ | |||
| 1 | import React, { useEffect, useRef, useState } from 'react'; | 1 | import React, { useEffect, useRef, useState } from 'react'; |
| 2 | import { useLocation, Link } from "react-router-dom"; | 2 | import { useLocation, Link } from "react-router-dom"; |
| 3 | import { BrowserRouter as Router, Route, Routes, useNavigate } from 'react-router-dom'; | 3 | import { BrowserRouter as Router, Route, Routes, useNavigate } from 'react-router-dom'; |
| 4 | 4 | ||
| 5 | import "./maplist.css" | 5 | import "./maplist.css" |
| @@ -7,12 +7,16 @@ import img5 from "../../imgs/5.png" | |||
| 7 | import img6 from "../../imgs/6.png" | 7 | import img6 from "../../imgs/6.png" |
| 8 | 8 | ||
| 9 | export default function Maplist(prop) { | 9 | export 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'> </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> |
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index 08e9c6e..1ca17e6 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -46,7 +46,6 @@ const [sidebar, setSidebar] = React.useState(); | |||
| 46 | // Clicked buttons | 46 | // Clicked buttons |
| 47 | function SidebarClick(x){ | 47 | function SidebarClick(x){ |
| 48 | const btn = document.querySelectorAll("button.sidebar-button"); | 48 | const btn = document.querySelectorAll("button.sidebar-button"); |
| 49 | console.log(x) | ||
| 50 | 49 | ||
| 51 | if(sidebar===1){setSidebar(0);SidebarHide()} | 50 | if(sidebar===1){setSidebar(0);SidebarHide()} |
| 52 | 51 | ||