diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js index c7c1c94..7c3d553 100644 --- a/src/web/js/maestro_main.js +++ b/src/web/js/maestro_main.js @@ -1,19 +1,9 @@ let maestroID = -1; -// let playerCount = 0; -// let playerListPage = 0; -// let lastPageNo = 0; let addPlayerListManager; let searchPlayerListManager; -// let addPlayerList; -// let addPlayerListNavigator; - -// let searchPlayerList; -// let searchPlayerListNavigator; - let mouseAppList; - let typingAppList; @@ -41,7 +31,11 @@ function tabClicked(tabNo) { break; case 2: $("#section_add_player").addClass("hide"); + + $("#search_name").val(""); + searchPlayerListManager.setupSearchPlayerList(""); $("#search").removeClass("hide"); + $("#mouse_app_list").addClass("hide"); $("#typing_app_list").addClass("hide"); break; diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 5c980b7..ec5477c 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -135,7 +135,7 @@ class PlayerList { } console.log("update player list"); - loadPlayerListPage(1); + self.loadPlayerListPage(1); } } } @@ -149,7 +149,7 @@ class PlayerList { let endNo = pageIndex * 10 + 9; let xhr = new XMLHttpRequest(); //new로 생성. - xhr.open('POST', './../server/user/registered_player_list_page.php', true); + 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() { @@ -187,6 +187,4 @@ class PlayerList { } } } -} - - +} \ No newline at end of file diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 70cb632..b6c4d6c 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -56,7 +56,7 @@ self.activePageNo = 1; self.list.loadPlayerListPage(self.activePageNo); - self.listNavigator.updateNavigator(self.playerCount); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); } } } @@ -71,7 +71,7 @@ let endNo = pageIndex * 10 + 9; let xhr = new XMLHttpRequest(); //new로 생성. - xhr.open('POST', './../server/user/registered_player_list_page.php', true); + 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() { @@ -106,7 +106,57 @@ self.playerCount = replyJSON["PlayerList"].length; console.log(self.playerCount); - self.listNavigator.updateNavigator(self.playerCount); + // self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); + // self.activePageNo = 1; + + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + } + } + } + + + + setupSearchPlayerList(playerName) { + let self = this; + + let xhr = new XMLHttpRequest(); //new로 생성. + xhr.open('POST', './../server/user/search_player_count.php', true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName); + 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; + } + + self.playerCount = replyJSON["Count"]; + self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); + self.activePageNo = 1; + + // self.list.loadPlayerListPage(self.activePageNo); + // self.listNavigator.updateNavigator(self.playerCount); + self.updateSearchPlayerListPage(playerName, 1); } } } @@ -120,9 +170,9 @@ let endNo = pageIndex * 10 + 9; let xhr = new XMLHttpRequest(); //new로 생성. - xhr.open('POST', './../server/user/registered_player_list_page.php', true); + xhr.open('POST', './../server/user/search_player_list.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.send("maestro_id=" + maestroID + "&playerName=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo); + xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo); xhr.onload = function() { if(xhr.readyState === 4 && xhr.status === 200) { // console.log(xhr.responseText); @@ -154,14 +204,14 @@ self.list.updatePlayerList(replyJSON["PlayerList"]); self.playerCount = replyJSON["PlayerList"].length; - self.listNavigator.updateNavigator(self.playerCount); + // self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); + // self.activePageNo = 1; + + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); } } } - // onClickPlayerListPage(pageNo) { - // this.listNavigator.onClickPlayerListPage(pageNo); - // } onClickPlayerListPage(pageNo) { switch(pageNo) { @@ -191,6 +241,4 @@ this.list.loadPlayerListPage(this.activePageNo); } -} - - +} \ No newline at end of file diff --git a/src/web/js/player_list_navigator.js b/src/web/js/player_list_navigator.js index a7d3df7..d086003 100644 --- a/src/web/js/player_list_navigator.js +++ b/src/web/js/player_list_navigator.js @@ -9,8 +9,10 @@ this.lastPageNo = 1; } - updateNavigator(playerCount) { - this.lastPageNo = Math.ceil( (playerCount + 1) / 10 ); + updateNavigator(activePageNo, lastPageNo) { + this.activePageNo = activePageNo; + this.lastPageNo = lastPageNo; + // this.lastPageNo = Math.ceil( (playerCount + 1) / 10 ); $(this.pageNoArea).empty(); @@ -49,7 +51,4 @@ this.playerList.loadPlayerListPage(this.activePageNo); } -} - - - +} \ 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 7f47ca2..59cae42 100644 --- a/src/web/module/maestro_section_add_player.html +++ b/src/web/module/maestro_section_add_player.html @@ -55,7 +55,7 @@ function addPlayer() { return; } - loadPlayerListPage(1); + addPlayerListManager.updateAddPlayerListPage(1); } } } diff --git a/src/web/module/maestro_section_search.html b/src/web/module/maestro_section_search.html index 3fe52d0..d0dc8f5 100644 --- a/src/web/module/maestro_section_search.html +++ b/src/web/module/maestro_section_search.html @@ -7,7 +7,7 @@ $(document).ready(function() { // searchPlayerList = new PlayerList($("#search_player_list")); // searchPlayerListNavigator = new PlayerListNavigator($("#search_player_list_navigator > #page_no_area")); - searchPlayerListManager.updateSearchPlayerListPage(1); + searchPlayerListManager.setupSearchPlayerList(""); }); @@ -20,40 +20,7 @@ function searchPlayer() { $("#add_player_name").focus(); } - let xhr = new XMLHttpRequest(); //new로 생성. - xhr.open('POST', './../server/user/search_player.php', true); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName); - 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; - } - - loadPlayerListPage(1); - } - } + searchPlayerListManager.setupSearchPlayerList(playerName); } @@ -61,9 +28,10 @@ function searchPlayer() { - 검색 - 아이디 -
+

검색

+ + 학생 이름 +