Fix: setupSearchPlayerList after delete search player list
This commit is contained in:
+17
-121
@@ -12,15 +12,15 @@
|
||||
|
||||
class PlayerList {
|
||||
|
||||
constructor(parent) {
|
||||
constructor(tagDiv, parent) {
|
||||
let self = this;
|
||||
this.listParent = parent;
|
||||
// console.log(parent);
|
||||
this.parent = parent;
|
||||
// console.log(tagDiv);
|
||||
|
||||
this.playerCount = 0;
|
||||
this.playerListPage = 1;
|
||||
this.activePageNo = 1;
|
||||
|
||||
let id_list = parent.find(".player_id");
|
||||
let id_list = tagDiv.find(".player_id");
|
||||
// console.log(id_list);
|
||||
|
||||
this.listRows = new Array();
|
||||
@@ -36,11 +36,11 @@ class PlayerList {
|
||||
this.disableItem(this.listRows[i]);
|
||||
|
||||
$(id_list[i]).siblings(".player_edit").click(function() {
|
||||
self.editPlayer(this);
|
||||
parent.editPlayer(this);
|
||||
})
|
||||
|
||||
$(id_list[i]).siblings(".player_delete").click(function() {
|
||||
self.deletePlayer(this);
|
||||
parent.deletePlayer(this);
|
||||
})
|
||||
// console.log(this.listRows[i].playerName.val());
|
||||
// console.log(this.listRows[i]);
|
||||
@@ -55,136 +55,32 @@ class PlayerList {
|
||||
$(item.deleteButton).prop("disabled", true);
|
||||
}
|
||||
|
||||
enableItem(item) {
|
||||
$(item.playerName).prop("disabled", false);
|
||||
$(item.enterCode).prop("disabled", false);
|
||||
$(item.editButton).prop("disabled", false);
|
||||
$(item.deleteButton).prop("disabled", false);
|
||||
}
|
||||
|
||||
updatePlayerList(jsonData) {
|
||||
// console.log(jsonData);
|
||||
|
||||
for(let i = 0; i < 10; i++) {
|
||||
// $(this.listRows[i].playerID).empty();
|
||||
this.disableItem(this.listRows[i]);
|
||||
$(this.listRows[i].playerID).empty();
|
||||
|
||||
if(i < jsonData.length) {
|
||||
$(this.listRows[i].playerID).append(jsonData[i]["UserID"]);
|
||||
|
||||
$(this.listRows[i].playerName).val(jsonData[i]["Name"]);
|
||||
$(this.listRows[i].playerName).prop("disabled", false);
|
||||
|
||||
$(this.listRows[i].enterCode).val(jsonData[i]["EnterCode"]);
|
||||
$(this.listRows[i].enterCode).prop("disabled", false);
|
||||
|
||||
$(this.listRows[i].editButton).prop("disabled", false);
|
||||
$(this.listRows[i].deleteButton).prop("disabled", false);
|
||||
this.enableItem(this.listRows[i]);
|
||||
} else {
|
||||
$(this.listRows[i].playerName).val("");
|
||||
// $(this.listRows[i].playerName).prop("disabled", true);
|
||||
|
||||
$(this.listRows[i].enterCode).val("");
|
||||
// $(this.listRows[i].enterCode).prop("disabled", true);
|
||||
|
||||
// $(this.listRows[i].editButton).prop("disabled", true);
|
||||
// $(this.listRows[i].deleteButton).prop("disabled", true);
|
||||
this.disableItem(this.listRows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editPlayer(inputButton) {
|
||||
// console.log(inputButton);
|
||||
|
||||
let id = $(inputButton).siblings(".player_id");
|
||||
// console.log(id);
|
||||
let playerID = id.text();
|
||||
|
||||
console.log(playerID);
|
||||
}
|
||||
|
||||
deletePlayer(inputButton) {
|
||||
let id = $(inputButton).siblings(".player_id");
|
||||
let playerID = id.text();
|
||||
|
||||
if(playerID === null || playerID === "")
|
||||
return;
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/user/delete_player.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
xhr.onload = function() {
|
||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||
// console.log(xhr.responseText);
|
||||
// console.log(xhr.responseText.length);
|
||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
// console.log(replyJSON);
|
||||
|
||||
if(replyJSON === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||
console.log(replyJSON["ERROR"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["RESULT"] === "fail") {
|
||||
console.log(replyJSON["RESULT"]);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("update player list");
|
||||
self.loadPlayerListPage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadPlayerListPage(pageNo) {
|
||||
self = this;
|
||||
this.playerListPage = pageNo;
|
||||
|
||||
let pageIndex = pageNo - 1;
|
||||
let startNo = pageIndex * 10;
|
||||
let endNo = pageIndex * 10 + 9;
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/user/registered_player_list.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
|
||||
xhr.onload = function() {
|
||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||
// console.log(xhr.responseText);
|
||||
// console.log(xhr.responseText.length);
|
||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
// console.log(replyJSON);
|
||||
|
||||
if(replyJSON === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||
console.log(replyJSON["ERROR"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["RESULT"] === "fail") {
|
||||
console.log(replyJSON["RESULT"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log(replyJSON["PlayerList"]);
|
||||
// updatePlayerListPage(replyJSON["PlayerList"]);
|
||||
self.updatePlayerList(replyJSON["PlayerList"]);
|
||||
|
||||
self.playerCount = replyJSON["PlayerList"].length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user