Skip to content

Commit

Permalink
Merge pull request #62 from Tekken-Supporter/feature/newjinlee
Browse files Browse the repository at this point in the history
Feature/newjinlee
  • Loading branch information
newjinlee authored Nov 29, 2023
2 parents eccd1a4 + 4e87c0c commit 1509a26
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions challenge_result.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const itemsPerPage = 5;

// 대결 전적 정보 연결
document.addEventListener("DOMContentLoaded", loadName);
document.addEventListener("DOMContentLoaded", loadChallengeInfo);

function loadName() {
const userId = localStorage.getItem("userId");
Expand Down Expand Up @@ -45,7 +44,9 @@ function loadName() {

if (objects["status"] == "ok") {
userName = objects["name"];
console.log(userName);
console.log("계정주 이름:" + userName);
loadChallengeInfo();
updateList(1);
}
} catch (e) {
console.error("Error parsing response:", e);
Expand All @@ -57,6 +58,7 @@ function loadName() {
};
}


function loadChallengeInfo() {
const userId = localStorage.getItem("userId");
jwt = localStorage.getItem("jwt");
Expand Down Expand Up @@ -97,6 +99,12 @@ function loadChallengeInfo() {
}

function updateList(pageNumber) {
if (!userName) {
console.error("userName is not loaded yet");
return;
}
console.log("UserName in another function:", userName);

const startIndex = (pageNumber - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
const paginatedItems = challengess.slice(startIndex, endIndex);
Expand All @@ -105,7 +113,11 @@ function updateList(pageNumber) {
listElement.innerHTML = "";

paginatedItems.forEach((challenge, index) => {
const nameToShow = (userName === challenge.challenger) ? challenge.challenger : challenge.contender;
let nameToShow;
if (userName === challenge.challenger)
nameToShow = challenge.contender;
if (userName === challenge.contender)
nameToShow = challenge.challenger;
console.log(nameToShow);
const challengeRow = document.createElement("div");
challengeRow.innerHTML = `
Expand Down

0 comments on commit 1509a26

Please sign in to comment.