mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-13 18:38:11 +02:00
Added social page and fixed garden page layout. ALSO added text next to
navbar.
This commit is contained in:
1 parent
2ea195475e
commit
b3902d4f69
9 files changed
+317
-159
No files matched your search
@@ -88,7 +88,6 @@ async function StartGame() {
|
||||
);
|
||||
|
||||
await RenderUser();
|
||||
await RenderLeaderboard();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
async function RenderLeaderboard() {
|
||||
async function RenderLeaderboard(
|
||||
CurrentUsername = null
|
||||
) {
|
||||
const Body =
|
||||
document.getElementById(
|
||||
"LeaderboardBody"
|
||||
);
|
||||
|
||||
if (Body === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const Response = await fetch(
|
||||
ApiUrl + "/Leaderboard.php"
|
||||
@@ -53,13 +59,16 @@ async function RenderLeaderboard() {
|
||||
}
|
||||
|
||||
|
||||
const UsernameDisplay =
|
||||
document.getElementById(
|
||||
"UsernameDisplay"
|
||||
);
|
||||
if (CurrentUsername === null) {
|
||||
const UsernameDisplay =
|
||||
document.getElementById(
|
||||
"UsernameDisplay"
|
||||
);
|
||||
|
||||
const CurrentUsername =
|
||||
UsernameDisplay?.textContent;
|
||||
CurrentUsername =
|
||||
UsernameDisplay?.textContent ??
|
||||
null;
|
||||
}
|
||||
|
||||
|
||||
for (
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
async function StartSocial() {
|
||||
let CurrentUsername = null;
|
||||
|
||||
try {
|
||||
const Profile = await GetProfile();
|
||||
|
||||
if (
|
||||
Profile.Success &&
|
||||
Profile.Username !== null
|
||||
) {
|
||||
CurrentUsername =
|
||||
Profile.Username;
|
||||
}
|
||||
} catch (Error) {
|
||||
console.error(
|
||||
"Couldn't load current profile:",
|
||||
Error
|
||||
);
|
||||
}
|
||||
|
||||
await RenderLeaderboard(
|
||||
CurrentUsername
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
StartSocial
|
||||
);
|
||||
+27
-1
@@ -1,6 +1,25 @@
|
||||
const DefaultColourPickerValue = "#000000";
|
||||
|
||||
|
||||
function RenderGardenOwnerHeading(
|
||||
Username
|
||||
) {
|
||||
const Heading =
|
||||
document.getElementById(
|
||||
"GardenPageHeading"
|
||||
);
|
||||
|
||||
if (Heading === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Heading.textContent =
|
||||
Username === null
|
||||
? "Your Garden"
|
||||
: Username + "'s Garden";
|
||||
}
|
||||
|
||||
|
||||
function IsValidPlayerColour(
|
||||
Colour
|
||||
) {
|
||||
@@ -270,6 +289,10 @@ async function RenderUser() {
|
||||
|
||||
UsernameForm.hidden = true;
|
||||
|
||||
RenderGardenOwnerHeading(
|
||||
Profile.Username
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -282,6 +305,10 @@ async function RenderUser() {
|
||||
);
|
||||
|
||||
UsernameForm.hidden = false;
|
||||
|
||||
RenderGardenOwnerHeading(
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +343,6 @@ async function SubmitUsername(
|
||||
"Username set.";
|
||||
|
||||
await RenderUser();
|
||||
await RenderLeaderboard();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user