diff --git a/src/web/js/lib/account_validator.js b/src/web/js/lib/account_validator.js index fba09a0..a8d26cd 100644 --- a/src/web/js/lib/account_validator.js +++ b/src/web/js/lib/account_validator.js @@ -1,88 +1,83 @@ -class AccountValidator { +function AccountValidator() { + this.patternMaestroID = /^[A-Za-z가-힣]{1}[A-Za-z0-9가-힣]{2,19}$/; + this.patternMaestroPW = /^[A-Za-z0-9]{4,16}$/; - constructor() { - this.patternMaestroID = /^[A-Za-z가-힣]{1}[A-Za-z0-9가-힣]{2,19}$/; - this.patternMaestroPW = /^[A-Za-z0-9]{4,16}$/; + this.patternPlayerID = /^[A-Za-z0-9가-힣-_]{1,8}$/; + this.patternPlayerPW = /^[0-9]{4,6}$/; +} - this.patternPlayerID = /^[A-Za-z0-9가-힣-_]{1,8}$/; - this.patternPlayerPW = /^[0-9]{4,6}$/; - } +// maestro +AccountValidator.prototype.isValidMaestroID = function(textID) { + if(!this.patternMaestroID.test(textID)) + return false; - // maestro - isValidMaestroID(textID) { - if(!this.patternMaestroID.test(textID)) - return false; + return true; +} - return true; - } - - messageForInvalidMaestroID(textID) { - if(textID.length < AccountValidator.MAESTRO_ID_LENGTH_MINIMUM) - return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다."; - else if(textID.length > AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM) - return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; - else if(!(/^[A-Za-z]/.test(textID))) - return "마에스트로 계정명은 알파벳으로 시작해야 합니다."; - else if((/[^\w]/g).test(textID)) - return "마에스트로 계정명은 알파벳과 숫자로만 적어주세요."; - } +AccountValidator.prototype.messageForInvalidMaestroID = function(textID) { + if(textID.length < AccountValidator.MAESTRO_ID_LENGTH_MINIMUM) + return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다."; + else if(textID.length > AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM) + return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; + else if(!(/^[A-Za-z]/.test(textID))) + return "마에스트로 계정명은 알파벳으로 시작해야 합니다."; + else if((/[^\w]/g).test(textID)) + return "마에스트로 계정명은 알파벳과 숫자로만 적어주세요."; +} - isValidMaestroPW(textPW) { - if(!this.patternMaestroPW.test(textPW)) - return false; +AccountValidator.prototype.isValidMaestroPW = function(textPW) { + if(!this.patternMaestroPW.test(textPW)) + return false; - return true; - } + return true; +} - messageForInvalidMaestroPW(textPW) { - console.log(textPW); - if(textPW.length < AccountValidator.MAESTRO_PW_LENGTH_MINIMUM) - return "마에스트로의 암호는 " + AccountValidator.MAESTRO_PW_LENGTH_MINIMUM + "글자 이상이어야 합니다."; - else if(textPW.length > AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM) - return "마에스트로의 암호는 " + AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; - else if((/[^\w]/g).test(textPW)) - return "마에스트로의 암호는 알파벳과 숫자로만 적어주세요."; - else - return "???"; - } +AccountValidator.prototype.messageForInvalidMaestroPW = function(textPW) { + console.log(textPW); + if(textPW.length < AccountValidator.MAESTRO_PW_LENGTH_MINIMUM) + return "마에스트로의 암호는 " + AccountValidator.MAESTRO_PW_LENGTH_MINIMUM + "글자 이상이어야 합니다."; + else if(textPW.length > AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM) + return "마에스트로의 암호는 " + AccountValidator.MAESTRO_PW_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; + else if((/[^\w]/g).test(textPW)) + return "마에스트로의 암호는 알파벳과 숫자로만 적어주세요."; + else + return "???"; +} - // player - isValidPlayerID(textID) { - if(!this.patternPlayerID.test(textID)) - return false; +// player +AccountValidator.prototype.isValidPlayerID = function(textID) { + if(!this.patternPlayerID.test(textID)) + return false; - return true; - } + return true; +} - messageForInvalidPlayerID(textID) { - if(textID.length < Number(AccountValidator.Player_ID_LENGTH_MINIMUM)) - return "학생 이름은 " + AccountValidator.Player_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다."; - else if(textID.length > Number(AccountValidator.PLAYER_ID_LENGTH_MAXIMUM)) - return "학생 이름은 " + AccountValidator.PLAYER_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; - else // if((/[^A-Za-z0-9가-힣-_]/g).test(textID)) - return "학생 이름 입력 가능한 문자는 [ 한글, 알파벳, 숫자, -, _ ] 입니다."; - } +AccountValidator.prototype.messageForInvalidPlayerID = function(textID) { + if(textID.length < Number(AccountValidator.Player_ID_LENGTH_MINIMUM)) + return "학생 이름은 " + AccountValidator.Player_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다."; + else if(textID.length > Number(AccountValidator.PLAYER_ID_LENGTH_MAXIMUM)) + return "학생 이름은 " + AccountValidator.PLAYER_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; + else // if((/[^A-Za-z0-9가-힣-_]/g).test(textID)) + return "학생 이름 입력 가능한 문자는 [ 한글, 알파벳, 숫자, -, _ ] 입니다."; +} - isValidPlayerPW(textPW) { - if(!this.patternPlayerPW.test(textPW)) - return false; - - return true; - } - - messageForInvalidPlayerPW(textPW) { - if(textPW.length < Number(AccountValidator.PLAYER_PW_LENGTH_MINIMUM)) - return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MINIMUM + "글자 이상의 숫자로 입력해 주세요."; - else if(textPW.length > Number(AccountValidator.PLAYER_PW_LENGTH_MAXIMUM)) - return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MAXIMUM + "글자 이하의 숫자로 입력해 주세요."; - else - return "학생 입장 번호는 4~6자리 숫자로 입력해 주세요."; - } +AccountValidator.prototype.isValidPlayerPW = function(textPW) { + if(!this.patternPlayerPW.test(textPW)) + return false; + return true; +} +AccountValidator.prototype.messageForInvalidPlayerPW = function(textPW) { + if(textPW.length < Number(AccountValidator.PLAYER_PW_LENGTH_MINIMUM)) + return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MINIMUM + "글자 이상의 숫자로 입력해 주세요."; + else if(textPW.length > Number(AccountValidator.PLAYER_PW_LENGTH_MAXIMUM)) + return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MAXIMUM + "글자 이하의 숫자로 입력해 주세요."; + else + return "학생 입장 번호는 4~6자리 숫자로 입력해 주세요."; } diff --git a/src/web/js/lib/maestro_info.js b/src/web/js/lib/maestro_info.js index 8c5c39e..c85a8c8 100644 --- a/src/web/js/lib/maestro_info.js +++ b/src/web/js/lib/maestro_info.js @@ -1,61 +1,57 @@ -class MaestroInfo { - - constructor() { - this.maestroID = sessionStorage.getItem("maestroID"); - this.maestroName = ""; - this.accountType = 0; - this.playerCount = 0; - } - - loadMaestroInfo(onSuccess, onFail) { - let self = this; - - sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); - "./../server/maestro/maestro_info.php", - "maestro_id=" + this.maestroID, - - function(jsonData) { - self.maestroName = jsonData["name"]; - self.accountType = jsonData["accountType"]; - self.playerCount = jsonData["playerCount"]; - - onSuccess(); - }, - - function(errorMessage, errorCode) { - onFail(errorMessage, errorCode); - } - - ); - } - - getMaxPlayerCount() { - switch(this.accountType) { - case 0: - case 1: - case 100: - case 101: - return 20; - - case 2: - return 50; - - case 3: - return 100; - - case 4: - return 500; - - case 5: - return 1000; - - default: - return 0; - } - } - - getRegisteredPlayerCount() { - return this.playerCount; - } - +function MaestroInfo() { + this.maestroID = sessionStorage.getItem("maestroID"); + this.maestroName = ""; + this.accountType = 0; + this.playerCount = 0; } + +MaestroInfo.prototype.loadMaestroInfo = function(onSuccess, onFail) { + var self = this; + + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/maestro/maestro_info.php", + "maestro_id=" + this.maestroID, + + function(jsonData) { + self.maestroName = jsonData["name"]; + self.accountType = jsonData["accountType"]; + self.playerCount = jsonData["playerCount"]; + + onSuccess(); + }, + + function(errorMessage, errorCode) { + onFail(errorMessage, errorCode); + } + + ); +} + +MaestroInfo.prototype.getMaxPlayerCount = function() { + switch(this.accountType) { + case 0: + case 1: + case 100: + case 101: + return 20; + + case 2: + return 50; + + case 3: + return 100; + + case 4: + return 500; + + case 5: + return 1000; + + default: + return 0; + } +} + +MaestroInfo.prototype.getRegisteredPlayerCount = function() { + return this.playerCount; +} \ No newline at end of file diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js index 6715517..cb5c34f 100644 --- a/src/web/js/maestro_main.js +++ b/src/web/js/maestro_main.js @@ -1,7 +1,7 @@ -let addPlayerListManager; -let searchPlayerListManager; +var addPlayerListManager; +var searchPlayerListManager; -let mouseAppList; -let typingAppList; +var mouseAppList; +var typingAppList; -let accountValidator = new AccountValidator(); +var accountValidator = new AccountValidator(); diff --git a/src/web/js/main.js b/src/web/js/main.js index ea6beac..fff1db9 100644 --- a/src/web/js/main.js +++ b/src/web/js/main.js @@ -1,4 +1,4 @@ -let maestroID = -1; +var maestroID = -1; $(document).ready(function() { loadMaestroID(); @@ -21,7 +21,7 @@ function saveMaestroID(maestroID) { } function getParentDirectory(url) { - let directories = url.split("/"); + var directories = url.split("/"); if(directories.length < 2) return ""; @@ -29,7 +29,7 @@ function getParentDirectory(url) { } function getPage(url) { - let directories = url.split("/"); + var directories = url.split("/"); if(directories.length < 1) return ""; @@ -37,7 +37,7 @@ function getPage(url) { } function goHome() { - let url = window.location.href; + var url = window.location.href; if(getParentDirectory(url) === "maestro") { if(getPage(url) !== "main_menu.html") @@ -66,12 +66,12 @@ function logout() { function showErrorMessage(message, type) { console.log("showErrorMessage : " + message); - let messageBox = $("#message_box"); + var messageBox = $("#message_box"); if(!messageBox) return; - let alertType = ""; + var alertType = ""; switch(type) { case "success": alertType = "alert-success"; diff --git a/src/web/js/mouse_app_list.js b/src/web/js/mouse_app_list.js index c9ea772..2ba8e8d 100644 --- a/src/web/js/mouse_app_list.js +++ b/src/web/js/mouse_app_list.js @@ -1,25 +1,20 @@ -class MouseAppList { - - constructor(pageNoArea) { - let self = this; - this.pageNoArea = pageNoArea; - // console.log(parent); - } - - addPlayerListPages(playerCount) { - lastPageNo = Math.ceil( (playerCount + 1) / 10 ); - - $(this.pageNoArea).empty(); - - for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) { - $(this.pageNoArea).append( - " " + pageNo + " " - ); - } - } - +function MouseAppList(pageNoArea) { + var self = this; + this.pageNoArea = pageNoArea; + // console.log(parent); } +MouseAppList.prototype.addPlayerListPages = function(playerCount) { + lastPageNo = Math.ceil( (playerCount + 1) / 10 ); + + $(this.pageNoArea).empty(); + + for(var pageNo = 1; pageNo < lastPageNo + 1; pageNo++) { + $(this.pageNoArea).append( + " " + pageNo + " " + ); + } +} function onClickPlayerListPage(pageNo) { diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 6caa673..327d374 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -1,101 +1,94 @@ -class PlayerListRow { - - constructor(playerID, playerName, enterCode, editButton, deleteButton) { - this.playerID = playerID; - this.playerName = playerName; - this.enterCode = enterCode; - this.editButton = editButton; - this.deleteButton = deleteButton; - } - +function PlayerListRow(playerID, playerName, enterCode, editButton, deleteButton) { + this.playerID = playerID; + this.playerName = playerName; + this.enterCode = enterCode; + this.editButton = editButton; + this.deleteButton = deleteButton; } -class PlayerList { - constructor(tagDiv, playerListManager) { - let self = this; - this.playerListManager = playerListManager; - // console.log(tagDiv); - // console.log(playerListManager); +function PlayerList(tagDiv, playerListManager) { + var self = this; + this.playerListManager = playerListManager; + // console.log(tagDiv); + // console.log(playerListManager); - this.playerCount = 0; - this.activePageNo = 1; + this.playerCount = 0; + this.activePageNo = 1; - // let id_list = tagDiv.find(".player_id"); - let id_list = tagDiv.find(".player-list"); - // console.log(id_list); + // var id_list = tagDiv.find(".player_id"); + var id_list = tagDiv.find(".player-list"); + // console.log(id_list); - this.listRows = new Array(); - for(let i = 0; i < id_list.length; i++) { - this.listRows[i] = new PlayerListRow( - id_list[i].getElementsByClassName("player_id"), - id_list[i].getElementsByClassName("player_name"), - id_list[i].getElementsByClassName("player_entercode"), - id_list[i].getElementsByClassName("player_edit"), - id_list[i].getElementsByClassName("player_delete") - ); + this.listRows = new Array(); + for(var i = 0; i < id_list.length; i++) { + this.listRows[i] = new PlayerListRow( + id_list[i].getElementsByClassName("player_id"), + id_list[i].getElementsByClassName("player_name"), + id_list[i].getElementsByClassName("player_entercode"), + id_list[i].getElementsByClassName("player_edit"), + id_list[i].getElementsByClassName("player_delete") + ); - $(this.listRows[i].editButton).click(function() { - playerListManager.editPlayer(this); - }) + $(this.listRows[i].editButton).click(function() { + playerListManager.editPlayer(this); + }) - $(this.listRows[i].deleteButton).click(function() { - playerListManager.deletePlayer(this); - }) - // console.log(this.listRows[i]); - // console.log(this.listRows[i].playerName.val()); + $(this.listRows[i].deleteButton).click(function() { + playerListManager.deletePlayer(this); + }) + // console.log(this.listRows[i]); + // console.log(this.listRows[i].playerName.val()); + + this.disableItem(this.listRows[i]); + } +} + +PlayerList.prototype.disableItem = function(item) { + $(item.playerID).empty(); + $(item.playerName).prop("disabled", true); + $(item.enterCode).prop("disabled", true); + // $(item.playerName).prop("readonly", true); + // $(item.enterCode).prop("readonly", true); + $(item.editButton).prop("disabled", true); + $(item.deleteButton).prop("disabled", true); +} + +PlayerList.prototype.enableItem = function(item) { + $(item.playerName).prop("disabled", false); + $(item.enterCode).prop("disabled", false); + // $(item.playerName).prop("readonly", false); + // $(item.enterCode).prop("readonly", false); + $(item.editButton).prop("disabled", false); + $(item.deleteButton).prop("disabled", false); +} + +PlayerList.prototype.updatePlayerList = function(jsonData) { + if(jsonData === null) { + for(var i = 0; i < 10; i++) { + $(this.listRows[i].playerName).val(""); + $(this.listRows[i].enterCode).val(""); + + this.disableItem(this.listRows[i]); + } + + return; + } + + for(var i = 0; i < 10; i++) { + $(this.listRows[i].playerID).empty(); + + if(i < jsonData.length) { + $(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 { + $(this.listRows[i].playerName).val(""); + $(this.listRows[i].enterCode).val(""); this.disableItem(this.listRows[i]); } } - - disableItem(item) { - $(item.playerID).empty(); - $(item.playerName).prop("disabled", true); - $(item.enterCode).prop("disabled", true); - // $(item.playerName).prop("readonly", true); - // $(item.enterCode).prop("readonly", true); - $(item.editButton).prop("disabled", true); - $(item.deleteButton).prop("disabled", true); - } - - enableItem(item) { - $(item.playerName).prop("disabled", false); - $(item.enterCode).prop("disabled", false); - // $(item.playerName).prop("readonly", false); - // $(item.enterCode).prop("readonly", false); - $(item.editButton).prop("disabled", false); - $(item.deleteButton).prop("disabled", false); - } - - updatePlayerList(jsonData) { - if(jsonData === null) { - for(let i = 0; i < 10; i++) { - $(this.listRows[i].playerName).val(""); - $(this.listRows[i].enterCode).val(""); - - this.disableItem(this.listRows[i]); - } - - return; - } - - for(let i = 0; i < 10; i++) { - $(this.listRows[i].playerID).empty(); - - if(i < jsonData.length) { - $(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 { - $(this.listRows[i].playerName).val(""); - $(this.listRows[i].enterCode).val(""); - - this.disableItem(this.listRows[i]); - } - } - } - } \ 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 1651a04..72ca2ba 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -1,237 +1,234 @@ -class PlayerListManager { +function PlayerListManager(docList, docNav) { + var self = this; + this.docList = docList; + this.docNav = docNav; + this.playerListID = $(docList).attr("id"); - constructor(docList, docNav) { - 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); - this.list = new PlayerList(this.docList, this); - this.list.updatePlayerList(null); - this.listNavigator = new PlayerListNavigator(this.docNav, this); + this.playerCount = 0; + this.activePageNo = 1; + this.lastPageNo = 0; - this.playerCount = 0; - this.activePageNo = 1; - this.lastPageNo = 0; - - this.searchPlayerName = ""; - } + this.searchPlayerName = ""; +} - setupAddPlayerList() { - let self = this; +PlayerListManager.prototype.setupAddPlayerList = function() { + var self = this; - sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); - "./../server/player/registered_player_count.php", - "maestro_id=" + maestroID, + 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) { + 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); - }, + self.loadAddPlayerListPage(self.activePageNo); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - loadAddPlayerListPage(pageNo) { - let self = this; - this.activePageNo = pageNo; - - let pageIndex = pageNo - 1; - 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, - - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - - updateAddPlayerListPage(pageNo) { - let self = this; - this.playerListPage = pageNo; - - let pageIndex = pageNo - 1; - 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, - - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - - - 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=" + this.searchPlayerName, - - function(jsonData) { - self.playerCount = jsonData["playerCount"]; - self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 ); - self.activePageNo = 1; - - self.updateSearchPlayerListPage(this.searchPlayerName, 1); - - if(self.playerCount === 0) - showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info"); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - updateSearchPlayerListPage(playerName, pageNo) { - let self = this; - this.playerListPage = pageNo; - - let pageIndex = pageNo - 1; - 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, - - function(jsonData) { - self.playerCount = jsonData["playerList"].length; - self.list.updatePlayerList(jsonData["playerList"]); - self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - - - - editPlayer(inputButton) { - let self = this; - console.log(inputButton); - // let clickedObjectID = this.getClickedObjectID(inputButton); - - - let id = $(inputButton).siblings(".player_id"); - let playerID = id.text(); - // console.log(playerID); - - let name = $(inputButton).siblings(".player_name"); - let playerName = name.val(); - // console.log(playerName); - - let enterCode = $(inputButton).siblings(".player_entercode"); - 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, - - function(jsonData) { - // console.log(jsonData); - if(this.playerListID === "add_player_list") { - self.setupAddPlayerList(); - } else if(this.playerListID === "search_player_list") { - self.setupSearchPlayerList(this.searchPlayerName); - } - showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - deletePlayer(inputButton) { - let self = this; - - let id = $(inputButton).siblings(".player_id"); - let playerID = id.text(); - - let name = $(inputButton).siblings(".player_name"); - let playerName = name.val(); - // console.log(playerName); - - // let clickedObjectID = this.getClickedObjectID(inputButton); - - if(playerID === null || playerID === "") - return; - - sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); - "./../server/player/delete_player.php", - "maestro_id=" + maestroID + "&player_id=" + playerID, - - function(jsonData) { - if(this.playerListID === "add_player_list") { - self.setupAddPlayerList(); - } else if(this.playerListID === "search_player_list") { - self.setupSearchPlayerList(this.searchPlayerName); - } - showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); - - onChangePlayerCount(); - }, - - function(errorMessage, errorCode) { - showErrorMessage(errorMessage, "error"); - } - - ); - } - - 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); + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); } + ); +} + +PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) { + var self = this; + this.activePageNo = pageNo; + + var pageIndex = pageNo - 1; + var startNo = pageIndex * 10; + var 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, + + function(jsonData) { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + + +PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) { + var self = this; + this.playerListPage = pageNo; + + var pageIndex = pageNo - 1; + var startNo = pageIndex * 10; + var 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, + + function(jsonData) { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + + + +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; + + self.updateSearchPlayerListPage(this.searchPlayerName, 1); + + if(self.playerCount === 0) + showErrorMessage(this.searchPlayerName + " : 검색 결과가 없습니다.", "info"); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + +PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pageNo) { + var self = this; + this.playerListPage = pageNo; + + var pageIndex = pageNo - 1; + var startNo = pageIndex * 10; + var 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, + + function(jsonData) { + self.playerCount = jsonData["playerList"].length; + self.list.updatePlayerList(jsonData["playerList"]); + self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + + + + +PlayerListManager.prototype.editPlayer = function(inputButton) { + var self = this; + console.log(inputButton); + // var clickedObjectID = this.getClickedObjectID(inputButton); + + + var id = $(inputButton).siblings(".player_id"); + var playerID = id.text(); + // console.log(playerID); + + var name = $(inputButton).siblings(".player_name"); + var playerName = name.val(); + // console.log(playerName); + + var enterCode = $(inputButton).siblings(".player_entercode"); + var 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, + + function(jsonData) { + // console.log(jsonData); + if(this.playerListID === "add_player_list") { + self.setupAddPlayerList(); + } else if(this.playerListID === "search_player_list") { + self.setupSearchPlayerList(this.searchPlayerName); + } + showErrorMessage("학생 데이터가 [ " + playerName + " / " + playerEnterCode + " ] 으로 변경되었습니다.", "success"); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + +PlayerListManager.prototype.deletePlayer = function(inputButton) { + var self = this; + + var id = $(inputButton).siblings(".player_id"); + var playerID = id.text(); + + var name = $(inputButton).siblings(".player_name"); + var playerName = name.val(); + // console.log(playerName); + + // var clickedObjectID = this.getClickedObjectID(inputButton); + + if(playerID === null || playerID === "") + return; + + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/player/delete_player.php", + "maestro_id=" + maestroID + "&player_id=" + playerID, + + function(jsonData) { + if(this.playerListID === "add_player_list") { + self.setupAddPlayerList(); + } else if(this.playerListID === "search_player_list") { + self.setupSearchPlayerList(this.searchPlayerName); + } + showErrorMessage("[ " + playerName + "] 학생 데이터가 삭제되었습니다.", "success"); + + onChangePlayerCount(); + }, + + function(errorMessage, errorCode) { + showErrorMessage(errorMessage, "error"); + } + + ); +} + +PlayerListManager.prototype.onClickPageNo = function(pageNo) { + var 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); } + } \ 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 7e5fbbd..b8a71b5 100644 --- a/src/web/js/player_list_navigator.js +++ b/src/web/js/player_list_navigator.js @@ -1,163 +1,159 @@ -class PlayerListNavigator { +function PlayerListNavigator(pageNoArea, playerListManager) { + var self = this; + this.playerListManager = playerListManager; + this.pagination = pageNoArea; + // console.log(parent); - constructor(pageNoArea, playerListManager) { - let self = this; - this.playerListManager = playerListManager; - this.pagination = pageNoArea; - // console.log(parent); + this.activePageNo = 1; + this.lastPageNo = 1; +} - this.activePageNo = 1; - this.lastPageNo = 1; - } +PlayerListNavigator.prototype.updateNavigator = function(activePageNo, lastPageNo) { + this.activePageNo = activePageNo; + this.lastPageNo = lastPageNo; + // this.lastPageNo = Math.ceil( (playerCount + 1) / 10 ); - updateNavigator(activePageNo, lastPageNo) { - this.activePageNo = activePageNo; - this.lastPageNo = lastPageNo; - // this.lastPageNo = Math.ceil( (playerCount + 1) / 10 ); + $(this.pagination).empty(); + this.makePagination(); + this.applyClickEvent(); + this.disableNavButtons(); +} - $(this.pagination).empty(); - this.makePagination(); - this.applyClickEvent(); - this.disableNavButtons(); - } - - makePagination() { - // left arrows - let paginationLeftArrows = '\ -