diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js index e572b56..2bacd8d 100644 --- a/src/web/js/maestro_main.js +++ b/src/web/js/maestro_main.js @@ -5,6 +5,7 @@ let mouseAppList; let typingAppList; +/* function tabClicked(tabNo) { // hide and show tab for(let i = 0; i < 4; i++) { @@ -48,16 +49,16 @@ function tabClicked(tabNo) { break; } } +*/ - -function onClickPlayerListPage(item, pageNo) { +function onClickPageNo(item, pageNo) { let tagDiv = $(item).closest("div"); + // console.log(tagDiv); let tagDivIDName = tagDiv.prop("id"); // console.log(tagDivIDName); if(tagDivIDName === "add_player_list_navigator") - addPlayerListManager.onClickPlayerListPage(pageNo); + addPlayerListManager.onClickPageNo(pageNo); else if(tagDivIDName === "search_player_list_navigator") - searchPlayerListManager.onClickPlayerListPage(pageNo); + searchPlayerListManager.onClickPageNo(pageNo); } - diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 033ee03..101ceac 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -16,6 +16,7 @@ class PlayerList { let self = this; this.playerListManager = playerListManager; // console.log(tagDiv); + // console.log(playerListManager); this.playerCount = 0; this.activePageNo = 1; @@ -54,18 +55,17 @@ class PlayerList { // }) - $(id_list[i].editButton).click(function() { + // console.log(id_list[i].editButton); + $(this.listRows[i].editButton).click(function() { playerListManager.editPlayer(this); }) - $(id_list[i].deleteButton).click(function() { + $(this.listRows[i].deleteButton).click(function() { playerListManager.deletePlayer(this); }) // console.log(this.listRows[i]); // console.log(this.listRows[i].playerName.val()); } - - console.log("this.listRows : " + this.listRows.length); } disableItem(item) { diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 694fef8..39da048 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -4,14 +4,17 @@ let self = this; this.docList = docList; this.docNav = docNav; + this.playerListID = $(docList).attr("id"); this.list = new PlayerList(this.docList, this); this.list.updatePlayerList(null); - this.listNavigator = new PlayerListNavigator(this.docNav); + this.listNavigator = new PlayerListNavigator(this, this.list, this.docNav); this.playerCount = 0; this.activePageNo = 1; this.lastPageNo = 0; + + this.searchPlayerName = ""; } @@ -98,17 +101,18 @@ setupSearchPlayerList(playerName) { let self = this; + this.searchPlayerName = playerName; sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); "./../server/player/search_player_count.php", - "maestro_id=" + maestroID + "&player_name=" + playerName, + "maestro_id=" + maestroID + "&player_name=" + this.searchPlayerName, (jsonData) => { self.playerCount = jsonData["playerCount"]; self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); self.activePageNo = 1; - self.updateSearchPlayerListPage(playerName, 1); + self.updateSearchPlayerListPage(this.searchPlayerName, 1); }, (errorMessage, errorCode) => { @@ -148,66 +152,39 @@ } - onClickPlayerListPage(pageNo) { - let self = this; - - switch(pageNo) { - case "first": - this.activePageNo = 1; - self.loadAddPlayerListPage(self.activePageNo); - return; - - case "prev": - if(this.activePageNo > 1) - this.activePageNo -= 1; - self.loadAddPlayerListPage(self.activePageNo); - return; - - case "next": - if(this.activePageNo < this.lastPageNo) - this.activePageNo += 1; - self.loadAddPlayerListPage(self.activePageNo); - return; - - case "last": - this.loadAddPlayerListPage(this.lastPageNo); - return; - } - - this.activePageNo = pageNo; - self.loadAddPlayerListPage(self.activePageNo); - } editPlayer(inputButton) { let self = this; - // console.log(inputButton); - let clickedObjectID = this.getClickedObjectID(inputButton); + console.log(inputButton); + // let clickedObjectID = this.getClickedObjectID(inputButton); let id = $(inputButton).siblings(".player_id"); let playerID = id.text(); - // console.log(playerID); + console.log(playerID); let name = $(inputButton).siblings(".player_name"); let playerName = name.val(); - // console.log(playerName); + console.log(playerName); let enterCode = $(inputButton).siblings(".player_entercode"); let playerEnterCode = enterCode.val(); - // console.log(playerEnterCode); + 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") { + console.log(jsonData); + if(this.playerListID === "add_player_list") { self.setupAddPlayerList(); - } else if(clickedObjectID === "search_player_list") { - let playerName = $("#search_name").val(); - self.setupSearchPlayerList(playerName); + } else if(this.playerListID === "search_player_list") { + // let playerName = $("#search_name").val(); + self.setupSearchPlayerList(this.searchPlayerName); } + showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); }, (errorMessage, errorCode) => { @@ -225,7 +202,11 @@ let id = $(inputButton).siblings(".player_id"); let playerID = id.text(); - let clickedObjectID = this.getClickedObjectID(inputButton); + let name = $(inputButton).siblings(".player_name"); + let playerName = name.val(); + console.log(playerName); + + // let clickedObjectID = this.getClickedObjectID(inputButton); if(playerID === null || playerID === "") return; @@ -235,12 +216,13 @@ "maestro_id=" + maestroID + "&player_id=" + playerID, (jsonData) => { - if(clickedObjectID === "add_player_list") { + if(this.playerListID === "add_player_list") { self.setupAddPlayerList(); - } else if(clickedObjectID === "search_player_list") { - let playerName = $("#search_name").val(); - self.setupSearchPlayerList(playerName); + } else if(this.playerListID === "search_player_list") { + // let searchPlayerName = $("#search_name").val(); + self.setupSearchPlayerList(searchPlayerName); } + showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); onChangePlayerCount(); }, @@ -254,11 +236,15 @@ ); } - getClickedObjectID(clickedObject) { - let tagDiv = $(clickedObject).closest(".player_list"); - let tagDivID = tagDiv.prop("id"); - // console.log(tagDivIDName); + onClickPageNo(pageNo) { + let self = this; + + self.activePageNo = pageNo; + if(this.playerListID === "add_player_list") { + self.updateAddPlayerListPage(self.activePageNo); + } else if(this.playerListID === "search_player_list") { + self.updateSearchPlayerListPage(this.searchPlayerName, self.activePageNo); + } - return tagDivID; } } \ 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 d086003..0ba7c87 100644 --- a/src/web/js/player_list_navigator.js +++ b/src/web/js/player_list_navigator.js @@ -1,7 +1,9 @@ class PlayerListNavigator { - constructor(pageNoArea) { + constructor(playerListManager, playerList, pageNoArea) { let self = this; + this.playerListManager = playerListManager; + this.playerList = playerList; this.pageNoArea = pageNoArea; // console.log(parent); @@ -18,37 +20,54 @@ for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) { $(this.pageNoArea).append( - " " + pageNo + " " + " " + pageNo + " " ); + /* + let aTag = $(this.pageNoArea).append( + " " + pageNo + " " + ); + aTag.click( + this.onClickPageNo(pageNo) + ); + */ } } - onClickPlayerListPage(pageNo) { + onClickPageNo(pageNo) { switch(pageNo) { case "first": this.activePageNo = 1; - this.playerList.loadPlayerListPage(this.activePageNo); + // this.playerList.loadPlayerListPage(this.activePageNo); + this.playerListManager.onClickPageNo(this.activePageNo); return; case "prev": if(this.activePageNo > 1) this.activePageNo -= 1; - this.playerList.loadPlayerListPage(this.activePageNo); + // this.playerList.loadPlayerListPage(this.activePageNo); + this.playerListManager.onClickPageNo(this.activePageNo); return; case "next": if(this.activePageNo < this.lastPageNo) this.activePageNo += 1; - this.playerList.loadPlayerListPage(this.activePageNo); + // this.playerList.loadPlayerListPage(this.activePageNo); + this.playerListManager.onClickPageNo(this.activePageNo); return; case "last": - this.playerList.loadPlayerListPage(this.lastPageNo); + // this.playerList.loadPlayerListPage(this.lastPageNo); + this.activePageNo = this.lastPageNo; + this.playerListManager.onClickPageNo(this.activePageNo); return; + + default: + this.activePageNo = pageNo; } this.activePageNo = pageNo; - this.playerList.loadPlayerListPage(this.activePageNo); + // this.playerList.loadPlayerListPage(this.activePageNo); + this.playerListManager.onClickPageNo(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 4fb8b73..a9d1c45 100644 --- a/src/web/module/maestro_section_add_player.html +++ b/src/web/module/maestro_section_add_player.html @@ -76,7 +76,7 @@ function onErrorPlayerPW(message) {