Add: player_list.js

This commit is contained in:
2018-07-03 14:35:39 +09:00
parent c4edd7abe1
commit fa241a6ee0
9 changed files with 459 additions and 54 deletions
+27 -26
View File
@@ -3,6 +3,9 @@ let playerCount = 0;
let playerListPage = 0;
let lastPageNo = 0;
let addPlayerList;
let searchPlayerList
$(document).ready(function() {
maestroID = sessionStorage.getItem("maestroID");
@@ -44,7 +47,6 @@ function loadPlayerList() {
playerCount = replyJSON["Count"];
lastPageNo = Math.floor( (playerCount + 1) / 10 );
console.log("registered player count : " + playerCount);
loadPlayerListPage(1);
addPlayerListPages();
}
@@ -69,18 +71,21 @@ function onClickPlayerListPage(pageNo) {
playerListPage = 1;
loadPlayerListPage(playerListPage);
return;
case "prev":
if(playerListPage > 1)
playerListPage -= 1;
loadPlayerListPage(playerListPage);
return;
case "next":
console.log("playerListPage : " + playerListPage);
console.log("lastPageNo : " + lastPageNo);
if(playerListPage < lastPageNo)
playerListPage += 1;
loadPlayerListPage(playerListPage);
return;
case "last":
loadPlayerListPage(lastPageNo);
return;
@@ -90,13 +95,12 @@ function onClickPlayerListPage(pageNo) {
}
function loadPlayerListPage(pageNo) {
playerListPage = pageNo;
let pageIndex = pageNo - 1;
let startNo = pageIndex * 10;
let endNo = pageIndex * 10 + 9;
console.log("startNo : " + startNo);
console.log("endNo : " + endNo);
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -128,33 +132,26 @@ function loadPlayerListPage(pageNo) {
return;
}
console.log(replyJSON["PlayerList"]);
// console.log(replyJSON["PlayerList"]);
updatePlayerListPage(replyJSON["PlayerList"]);
}
}
}
function addPlayerListTitle() {
$("#registered_player_list").empty();
$("#registered_player_list").append(
'<li class="registered_player_list_name">이름</li><li class="registered_player_list_entercode">입장 코드</li>'
);
}
function updatePlayerListPage(playerList) {
$("#registered_player_list").empty();
addPlayerListTitle();
for(let i = 0; i < 10; i++) {
let listIndex = i + 1; // index 0 : list title
for(let i = 0; i < playerList.length; i++) {
$("#registered_player_list").append(
"<li>"
+ "" + playerList[i]["UserID"] + ""
+ "<input type='text' value='" + playerList[i]["Name"] + "' class='registered_player_list_name'>"
+ "<input type='text' value='" + playerList[i]["EnterCode"] + "' class='registered_player_list_entercode'>"
+ "<input type='button' value='수정'>"
+ "</li>"
);
if(i < playerList.length) {
$("#registered_player_list .player_id").filter(":eq(" + i + ")").empty();
$("#registered_player_list .player_id").filter(":eq(" + i + ")").append(playerList[i]["UserID"]);
$("#registered_player_list .player_name").filter(":eq(" + listIndex + ")").val(playerList[i]["Name"]);
$("#registered_player_list .player_entercode").filter(":eq(" + listIndex + ")").val(playerList[i]["EnterCode"]);
} else {
$("#registered_player_list .player_id").filter(":eq(" + i + ")").empty();
$("#registered_player_list .player_name").filter(":eq(" + listIndex + ")").val("");
$("#registered_player_list .player_entercode").filter(":eq(" + listIndex + ")").val("");
}
}
}
@@ -245,5 +242,9 @@ function addPlayer() {
loadPlayerListPage(1);
}
}
}
function deletePlayer(id) {
}