From f23665a5f08acf324a8451561db160739ac76d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 12 Jul 2018 10:55:44 +0900 Subject: [PATCH] Fix: revised php code to maestro search --- src/web/js/player_list.js | 6 +- src/web/js/player_list_manager.js | 279 ++++++++++++++---- .../module/maestro_section_add_player.html | 52 +--- src/web/module/maestro_section_main.html | 4 +- src/web/module/maestro_section_search.html | 1 + src/web/server/player/add_player.php | 28 +- src/web/server/player/delete_player.php | 34 +-- src/web/server/player/edit_player.php | 29 +- .../server/player/registered_player_count.php | 32 +- .../server/player/registered_player_list.php | 34 +-- src/web/server/player/search_player_count.php | 33 +-- src/web/server/player/search_player_list.php | 34 +-- 12 files changed, 339 insertions(+), 227 deletions(-) diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 7dba2d0..1e09d4f 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -69,9 +69,9 @@ class PlayerList { $(this.listRows[i].playerID).empty(); if(i < jsonData.length) { - $(this.listRows[i].playerID).append(jsonData[i]["PlayerID"]); - $(this.listRows[i].playerName).val(jsonData[i]["Name"]); - $(this.listRows[i].enterCode).val(jsonData[i]["EnterCode"]); + $(this.listRows[i].playerID).append(jsonData[i]["playerID"]); + $(this.listRows[i].playerName).val(jsonData[i]["playerName"]); + $(this.listRows[i].enterCode).val(jsonData[i]["enterCode"]); this.enableItem(this.listRows[i]); } else { diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 5f4a97f..da30e17 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -18,6 +18,28 @@ setupAddPlayerList() { let self = this; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/registered_player_count.php", + "maestro_id=" + maestroID, + + (jsonData) => { + self.playerCount = jsonData["playerCount"]; + self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); + self.activePageNo = 1; + + self.loadAddPlayerListPage(self.activePageNo); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/registered_player_count.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -31,25 +53,25 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } - self.playerCount = replyJSON["Count"]; + self.playerCount = jsonData["Count"]; self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); self.activePageNo = 1; @@ -57,6 +79,7 @@ self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); } } + */ } loadAddPlayerListPage(pageNo) { @@ -67,6 +90,24 @@ let startNo = pageIndex * 10; let endNo = pageIndex * 10 + 9; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/registered_player_list.php", + "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, + + (jsonData) => { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/registered_player_list.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -80,31 +121,32 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } - // console.log(replyJSON["PlayerList"]); - // updatePlayerListPage(replyJSON["PlayerList"]); - self.list.updatePlayerList(replyJSON["PlayerList"]); + // console.log(jsonData["PlayerList"]); + // updatePlayerListPage(jsonData["PlayerList"]); + self.list.updatePlayerList(jsonData["PlayerList"]); - self.playerCount = replyJSON["PlayerList"].length; + self.playerCount = jsonData["PlayerList"].length; } } + */ } @@ -116,6 +158,26 @@ let startNo = pageIndex * 10; let endNo = pageIndex * 10 + 9; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/registered_player_list.php", + "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, + + (jsonData) => { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/registered_player_list.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -129,28 +191,28 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } - // console.log(replyJSON["PlayerList"]); - self.list.updatePlayerList(replyJSON["PlayerList"]); + // console.log(jsonData["PlayerList"]); + self.list.updatePlayerList(jsonData["PlayerList"]); - self.playerCount = replyJSON["PlayerList"].length; + self.playerCount = jsonData["PlayerList"].length; // console.log(self.playerCount); // self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); // self.activePageNo = 1; @@ -158,6 +220,7 @@ self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); } } + */ } @@ -165,6 +228,27 @@ setupSearchPlayerList(playerName) { let self = this; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/search_player_count.php", + "maestro_id=" + maestroID + "&player_name=" + playerName, + + (jsonData) => { + self.playerCount = jsonData["playerCount"]; + self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); + self.activePageNo = 1; + + self.updateSearchPlayerListPage(playerName, 1); + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/search_player_count.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -178,31 +262,32 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } - self.playerCount = replyJSON["Count"]; + self.playerCount = jsonData["Count"]; self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); self.activePageNo = 1; self.updateSearchPlayerListPage(playerName, 1); } } + */ } updateSearchPlayerListPage(playerName, pageNo) { @@ -213,6 +298,26 @@ let startNo = pageIndex * 10; let endNo = pageIndex * 10 + 9; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/search_player_list.php", + "maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo, + + (jsonData) => { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/search_player_list.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -226,34 +331,35 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } - // console.log(replyJSON["PlayerList"]); - self.list.updatePlayerList(replyJSON["PlayerList"]); + // console.log(jsonData["PlayerList"]); + self.list.updatePlayerList(jsonData["PlayerList"]); - self.playerCount = replyJSON["PlayerList"].length; + self.playerCount = jsonData["PlayerList"].length; // self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); // self.activePageNo = 1; self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); } } + */ } @@ -303,6 +409,29 @@ let playerEnterCode = enterCode.val(); // console.log(playerEnterCode); + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/edit_player.php", + "maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode, + + (jsonData) => { + if(clickedObjectID === "add_player_list") { + self.setupAddPlayerList(); + } else if(clickedObjectID === "search_player_list") { + let playerName = $("#search_name").val(); + self.setupSearchPlayerList(playerName); + } + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/edit_player.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -316,21 +445,21 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } @@ -343,6 +472,7 @@ } } } + */ } deletePlayer(inputButton) { @@ -356,6 +486,29 @@ if(playerID === null || playerID === "") return; + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/delete_player.php", + "maestro_id=" + maestroID + "&player_id=" + playerID, + + (jsonData) => { + if(clickedObjectID === "add_player_list") { + self.setupAddPlayerList(); + } else if(clickedObjectID === "search_player_list") { + let playerName = $("#search_name").val(); + self.setupSearchPlayerList(playerName); + } + }, + + (errorMessage) => { + if($("#error_message").length) { + $("#error_message").text(errorMessage); + } + } + + ); + + +/* let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/player/delete_player.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -369,21 +522,21 @@ return; } - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); + let jsonData = JSON.parse(xhr.responseText); + // console.log(jsonData); - if(replyJSON === null) { + if(jsonData === null) { console.log("no data from server"); return; } - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); + if(jsonData["ERROR"] !== undefined || jsonData["RESULT"] === undefined) { + console.log(jsonData["ERROR"]); return; } - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); + if(jsonData["RESULT"] === "fail") { + console.log(jsonData["RESULT"]); return; } @@ -396,6 +549,7 @@ } } } + */ } getClickedObjectID(clickedObject) { @@ -405,7 +559,4 @@ return tagDivID; } - - - } \ No newline at end of file diff --git a/src/web/module/maestro_section_add_player.html b/src/web/module/maestro_section_add_player.html index 82e55da..6189c68 100644 --- a/src/web/module/maestro_section_add_player.html +++ b/src/web/module/maestro_section_add_player.html @@ -1,63 +1,43 @@  @@ -72,7 +52,7 @@ function addPlayer() {
학생 이름
입장 코드 - +