diff --git a/public/js/game.js b/public/js/game.js index afea724..435c245 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -1295,22 +1295,21 @@ const profileUpdate = async (uid, isMe) => { document.getElementsByClassName("profileStatValue")[3].textContent = profile.playtime; document.getElementsByClassName("profileStatValue")[4].textContent = profile["1stNum"]; banners = JSON.parse(profile.banner); - if (banners.length == 0) { - document.getElementById("profileBanner").innerHTML = `${nothingHere}`; - } else { - document.getElementById("profileBanner").innerHTML = `
`; - for (let i = 0; i < banners.length; i++) { - if (banners[i].indexOf("(-)") != -1 && !isMe) continue; - document.getElementById("profileBannerContainer").innerHTML += ` + document.getElementById("profileBanner").innerHTML = `
`; + let count = 0; + for (let i = 0; i < banners.length; i++) { + if (banners[i].indexOf("(-)") != -1 && !isMe) continue; + count++; + document.getElementById("profileBannerContainer").innerHTML += `
+ isMe ? `onclick="bannerToggle(${i})"` : "" + }>
`; - } } + if (count == 0) document.getElementById("profileBanner").innerHTML = `${nothingHere}`; let recentPlay = JSON.parse(profile.recentPlay); if (recentPlay.length == 0) { document.getElementsByClassName("profileStatValue")[5].textContent = "-"; diff --git a/src/index.ts b/src/index.ts index 019ae17..f0520cc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -122,7 +122,10 @@ const upload = multer({ }).single("img"); app.post("/profile/:userid/:type", async (req, res) => { - if (req.params.type != "picture" && req.params.type != "background") { + let type = ""; + if (req.params.type == "picture") type = "picture"; + else if (req.params.type == "background") type = "background"; + else { res.status(400).json({ result: "failed", message: "Error occured while uploading", @@ -150,7 +153,7 @@ app.post("/profile/:userid/:type", async (req, res) => { }); return; } - fetch(`${config.project.api}/profile/${req.params.type}`, { + fetch(`${config.project.api}/profile/${type}`, { method: "PUT", headers: { "Content-Type": "application/json",