From cbde6256d6424d3c5f6fba6fb74eb2213ac68151 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: Sun, 16 Sep 2018 19:57:15 +0900 Subject: [PATCH] Fix: maestro search bug --- src/web/js/player_list_manager.js | 92 ++++++++++------------ src/web/module/maestro_section_search.html | 2 +- 2 files changed, 41 insertions(+), 53 deletions(-) diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 72ca2ba..eeb1749 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -1,5 +1,4 @@ function PlayerListManager(docList, docNav) { - var self = this; this.docList = docList; this.docNav = docNav; this.playerListID = $(docList).attr("id"); @@ -17,20 +16,18 @@ PlayerListManager.prototype.setupAddPlayerList = function() { - var self = this; - sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); "./../server/player/registered_player_count.php", "maestro_id=" + maestroID, - function(jsonData) { - self.playerCount = jsonData["playerCount"]; - self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); - self.activePageNo = 1; + (function(jsonData) { + this.playerCount = jsonData["playerCount"]; + this.lastPageNo = Math.ceil( (this.playerCount + 1) / 10 ); + this.activePageNo = 1; - self.loadAddPlayerListPage(self.activePageNo); - self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); - }, + this.loadAddPlayerListPage(this.activePageNo); + this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo); + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -40,7 +37,6 @@ PlayerListManager.prototype.setupAddPlayerList = function() { } PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) { - var self = this; this.activePageNo = pageNo; var pageIndex = pageNo - 1; @@ -51,10 +47,10 @@ PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) { "./../server/player/registered_player_list.php", "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - }, + (function(jsonData) { + this.playerCount = jsonData["playerList"].length; + this.list.updatePlayerList(jsonData["playerList"]); + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -65,7 +61,6 @@ PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) { PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) { - var self = this; this.playerListPage = pageNo; var pageIndex = pageNo - 1; @@ -76,11 +71,11 @@ PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) { "./../server/player/registered_player_list.php", "maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo, - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); - }, + (function(jsonData) { + this.playerCount = jsonData["playerList"].length; + this.list.updatePlayerList(jsonData["playerList"]); + this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo); + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -92,23 +87,22 @@ PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) { PlayerListManager.prototype.setupSearchPlayerList = function(playerName) { - var self = this; this.searchPlayerName = playerName; sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); "./../server/player/search_player_count.php", "maestro_id=" + maestroID + "&player_name=" + this.searchPlayerName, - function(jsonData) { - self.playerCount = jsonData["playerCount"]; - self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); - self.activePageNo = 1; + (function(jsonData) { + this.playerCount = jsonData["playerCount"]; + this.lastPageNo = Math.ceil( (this.playerCount + 1) / 10 ); + this.activePageNo = 1; - self.updateSearchPlayerListPage(this.searchPlayerName, 1); + this.updateSearchPlayerListPage(this.searchPlayerName, 1); - if(self.playerCount === 0) + if(this.playerCount === 0) showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info"); - }, + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -118,7 +112,6 @@ PlayerListManager.prototype.setupSearchPlayerList = function(playerName) { } PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pageNo) { - var self = this; this.playerListPage = pageNo; var pageIndex = pageNo - 1; @@ -129,11 +122,11 @@ PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pa "./../server/player/search_player_list.php", "maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo, - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); - }, + (function(jsonData) { + this.playerCount = jsonData["playerList"].length; + this.list.updatePlayerList(jsonData["playerList"]); + this.listNavigator.updateNavigator(this.activePageNo, this.lastPageNo); + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -146,8 +139,7 @@ PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pa PlayerListManager.prototype.editPlayer = function(inputButton) { - var self = this; - console.log(inputButton); + // console.log(inputButton); // var clickedObjectID = this.getClickedObjectID(inputButton); @@ -167,15 +159,15 @@ PlayerListManager.prototype.editPlayer = function(inputButton) { "./../server/player/edit_player.php", "maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode, - function(jsonData) { + (function(jsonData) { // console.log(jsonData); if(this.playerListID === "add_player_list") { - self.setupAddPlayerList(); + this.setupAddPlayerList(); } else if(this.playerListID === "search_player_list") { - self.setupSearchPlayerList(this.searchPlayerName); + this.setupSearchPlayerList(this.searchPlayerName); } showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); - }, + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -185,8 +177,6 @@ PlayerListManager.prototype.editPlayer = function(inputButton) { } PlayerListManager.prototype.deletePlayer = function(inputButton) { - var self = this; - var id = $(inputButton).siblings(".player_id"); var playerID = id.text(); @@ -203,16 +193,16 @@ PlayerListManager.prototype.deletePlayer = function(inputButton) { "./../server/player/delete_player.php", "maestro_id=" + maestroID + "&player_id=" + playerID, - function(jsonData) { + (function(jsonData) { if(this.playerListID === "add_player_list") { - self.setupAddPlayerList(); + this.setupAddPlayerList(); } else if(this.playerListID === "search_player_list") { - self.setupSearchPlayerList(this.searchPlayerName); + this.setupSearchPlayerList(this.searchPlayerName); } showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); onChangePlayerCount(); - }, + }).bind(this), function(errorMessage, errorCode) { showErrorMessage(errorMessage, "error"); @@ -222,13 +212,11 @@ PlayerListManager.prototype.deletePlayer = function(inputButton) { } PlayerListManager.prototype.onClickPageNo = function(pageNo) { - var self = this; - - self.activePageNo = pageNo; + this.activePageNo = pageNo; if(this.playerListID === "add_player_list") { - self.updateAddPlayerListPage(self.activePageNo); + this.updateAddPlayerListPage(this.activePageNo); } else if(this.playerListID === "search_player_list") { - self.updateSearchPlayerListPage(this.searchPlayerName, self.activePageNo); + this.updateSearchPlayerListPage(this.searchPlayerName, this.activePageNo); } } \ No newline at end of file diff --git a/src/web/module/maestro_section_search.html b/src/web/module/maestro_section_search.html index 56c63a1..b5813bd 100644 --- a/src/web/module/maestro_section_search.html +++ b/src/web/module/maestro_section_search.html @@ -49,7 +49,7 @@ function searchPlayer() { -
+
검색 결과