Fix: maestro html ES6 -> ES5

This commit is contained in:
2018-09-15 13:51:48 +09:00
parent 53e3dbb3bc
commit 753325d84a
9 changed files with 585 additions and 613 deletions
+64 -69
View File
@@ -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자리 숫자로 입력해 주세요.";
}
+56 -60
View File
@@ -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;
}
+5 -5
View File
@@ -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();
+6 -6
View File
@@ -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";
+15 -20
View File
@@ -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(
"<a onClick='onClickPlayerListPage(" + pageNo + ")'> " + pageNo + " </a>"
);
}
}
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(
"<a onClick='onClickPlayerListPage(" + pageNo + ")'> " + pageNo + " </a>"
);
}
}
function onClickPlayerListPage(pageNo) {
+81 -88
View File
@@ -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]);
}
}
}
}
+221 -224
View File
@@ -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);
}
}
+129 -133
View File
@@ -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 = '\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="First">\
<span aria-hidden="true">&laquo;</span>\
<span class="sr-only">First</span>\
</a>\
</li>\
PlayerListNavigator.prototype.makePagination = function() {
// left arrows
var paginationLeftArrows = '\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="First">\
<span aria-hidden="true">&laquo;</span>\
<span class="sr-only">First</span>\
</a>\
</li>\
\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Previous">\
<span aria-hidden="true">&lt;</span>\
<span class="sr-only">Previous</span>\
</a>\
</li>\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Previous">\
<span aria-hidden="true">&lt;</span>\
<span class="sr-only">Previous</span>\
</a>\
</li>\
\
<li>&nbsp</li>\
<li>&nbsp</li>\
\ ';
$(this.pagination).append(paginationLeftArrows);
$(this.pagination).append(paginationLeftArrows);
// numbers
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$(this.pagination).append(
'<li class="page-item"><a class="page-link" href="javascript:void(0);" aria-label="' + pageNo + '">' + pageNo + '</a></li>'
);
}
// numbers
for(var pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$(this.pagination).append(
'<li class="page-item"><a class="page-link" href="javascript:void(0);" aria-label="' + pageNo + '">' + pageNo + '</a></li>'
);
}
// right arrows
let paginationRightArrows = '\
<li>&nbsp</li>\
// right arrows
var paginationRightArrows = '\
<li>&nbsp</li>\
\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Next">\
<span aria-hidden="true">&gt;</span>\
<span class="sr-only">Next</span>\
</a>\
</li>\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Next">\
<span aria-hidden="true">&gt;</span>\
<span class="sr-only">Next</span>\
</a>\
</li>\
\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Last">\
<span aria-hidden="true">&raquo;</span>\
<span class="sr-only">Last</span>\
</a>\
</li>\
';
$(this.pagination).append(paginationRightArrows);
}
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="Last">\
<span aria-hidden="true">&raquo;</span>\
<span class="sr-only">Last</span>\
</a>\
</li>\
';
$(this.pagination).append(paginationRightArrows);
}
applyClickEvent() {
let self = this;
PlayerListNavigator.prototype.applyClickEvent = function() {
var self = this;
$("[aria-label='First']").click(function() {
self.onClickPageNo("first");
});
$("[aria-label='First']").click(function() {
self.onClickPageNo("first");
});
$("[aria-label='Previous']").click(function() {
self.onClickPageNo("previous");
});
$("[aria-label='Previous']").click(function() {
self.onClickPageNo("previous");
});
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$("[aria-label='" + pageNo + "']").click(function() {
self.onClickPageNo(pageNo);
});
}
$("[aria-label='Next']").click(function() {
self.onClickPageNo("next");
});
$("[aria-label='Last']").click(function() {
self.onClickPageNo("last");
for(var pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$("[aria-label='" + pageNo + "']").click(function() {
self.onClickPageNo(pageNo);
});
}
disableNavButtons() {
/*
console.log(this.activePageNo);
console.log(this.lastPageNo);
console.log($("[aria-label='First']").parent());
$("[aria-label='Next']").click(function() {
self.onClickPageNo("next");
});
if(this.activePageNo === 1 || this.lastPageNo === 1)
$("[aria-label='First']").parent().prop("disabled", true);
$("[aria-label='Last']").click(function() {
self.onClickPageNo("last");
});
}
PlayerListNavigator.prototype.disableNavButtons = function() {
/*
console.log(this.activePageNo);
console.log(this.lastPageNo);
console.log($("[aria-label='First']").parent());
if(this.activePageNo === 1 || this.lastPageNo === 1)
$("[aria-label='First']").parent().prop("disabled", true);
else
$("[aria-label='First']").parent().prop("disabled", false);
if(this.activePageNo === 1 || this.lastPageNo === 1)
$("[aria-label='Previous']").parent().prop("disabled", true);
else
$("[aria-label='Previous']").parent().prop("disabled", false);
for(var pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
if(this.activePageNo === pageNo)
$("[aria-label='" + pageNo + "']").parent().prop("disabled", true);
else
$("[aria-label='First']").parent().prop("disabled", false);
if(this.activePageNo === 1 || this.lastPageNo === 1)
$("[aria-label='Previous']").parent().prop("disabled", true);
else
$("[aria-label='Previous']").parent().prop("disabled", false);
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
if(this.activePageNo === pageNo)
$("[aria-label='" + pageNo + "']").parent().prop("disabled", true);
else
$("[aria-label='" + pageNo + "']").parent().prop("disabled", false);
}
if(this.activePageNo === this.lastPageNo)
$("[aria-label='Next']").parent().prop("disabled", true);
else
$("[aria-label='Next']").parent().prop("disabled", false);
if(this.activePageNo === this.lastPageNo)
$("[aria-label='Last']").parent().prop("disabled", true);
else
$("[aria-label='Last']").parent().prop("disabled", false);
*/
$("[aria-label='" + pageNo + "']").parent().prop("disabled", false);
}
onClickPageNo(pageNo) {
console.log(pageNo);
switch(pageNo) {
case "first":
this.activePageNo = 1;
break;
if(this.activePageNo === this.lastPageNo)
$("[aria-label='Next']").parent().prop("disabled", true);
else
$("[aria-label='Next']").parent().prop("disabled", false);
case "previous":
if(this.activePageNo > 1)
this.activePageNo -= 1;
break;
if(this.activePageNo === this.lastPageNo)
$("[aria-label='Last']").parent().prop("disabled", true);
else
$("[aria-label='Last']").parent().prop("disabled", false);
*/
}
case "next":
if(this.activePageNo < this.lastPageNo)
this.activePageNo += 1;
break;
PlayerListNavigator.prototype.onClickPageNo = function(pageNo) {
console.log(pageNo);
switch(pageNo) {
case "first":
this.activePageNo = 1;
break;
case "last":
this.activePageNo = this.lastPageNo;
break;
case "previous":
if(this.activePageNo > 1)
this.activePageNo -= 1;
break;
default:
this.activePageNo = pageNo;
}
case "next":
if(this.activePageNo < this.lastPageNo)
this.activePageNo += 1;
break;
console.log(this.activePageNo);
this.playerListManager.onClickPageNo(this.activePageNo);
case "last":
this.activePageNo = this.lastPageNo;
break;
default:
this.activePageNo = pageNo;
}
console.log(this.activePageNo);
this.playerListManager.onClickPageNo(this.activePageNo);
}
+8 -8
View File
@@ -5,7 +5,7 @@
// console.log(onFail);
// console.log(isDebugMode);
let xhr = new XMLHttpRequest(); //new로 생성.
var xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(sendParams);
@@ -15,25 +15,25 @@
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
let errorMessage = "서버에서 요청을 수행하지 못했습니다.";
let errorCode = "no_reply_from_server";
var errorMessage = "서버에서 요청을 수행하지 못했습니다.";
var errorCode = "no_reply_from_server";
printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
return;
}
let jsonReply = JSON.parse(xhr.responseText);
var jsonReply = JSON.parse(xhr.responseText);
// console.log(jsonReply);
if(jsonReply === null) {
let errorMessage = "서버에서 데이터가 넘어오지 않았습니다.";
let errorCode = "no_data_from_server";
var errorMessage = "서버에서 데이터가 넘어오지 않았습니다.";
var errorCode = "no_data_from_server";
printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
return;
}
if(!isSuccess(jsonReply)) {
let errorMessage = getErrorMessage(jsonReply);
let errorCode = jsonReply["error_code"];
var errorMessage = getErrorMessage(jsonReply);
var errorCode = jsonReply["error_code"];
printErrorMessage(errorMessage, errorCode, onFail, isDebugMode);
return;
}