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
+19 -24
View File
@@ -1,22 +1,20 @@
class AccountValidator {
constructor() {
function AccountValidator() {
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}$/;
}
}
// maestro
isValidMaestroID(textID) {
// maestro
AccountValidator.prototype.isValidMaestroID = function(textID) {
if(!this.patternMaestroID.test(textID))
return false;
return true;
}
}
messageForInvalidMaestroID(textID) {
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)
@@ -25,17 +23,17 @@ class AccountValidator {
return "마에스트로 계정명은 알파벳으로 시작해야 합니다.";
else if((/[^\w]/g).test(textID))
return "마에스트로 계정명은 알파벳과 숫자로만 적어주세요.";
}
}
isValidMaestroPW(textPW) {
AccountValidator.prototype.isValidMaestroPW = function(textPW) {
if(!this.patternMaestroPW.test(textPW))
return false;
return true;
}
}
messageForInvalidMaestroPW(textPW) {
AccountValidator.prototype.messageForInvalidMaestroPW = function(textPW) {
console.log(textPW);
if(textPW.length < AccountValidator.MAESTRO_PW_LENGTH_MINIMUM)
return "마에스트로의 암호는 " + AccountValidator.MAESTRO_PW_LENGTH_MINIMUM + "글자 이상이어야 합니다.";
@@ -45,44 +43,41 @@ class AccountValidator {
return "마에스트로의 암호는 알파벳과 숫자로만 적어주세요.";
else
return "???";
}
}
// player
isValidPlayerID(textID) {
// player
AccountValidator.prototype.isValidPlayerID = function(textID) {
if(!this.patternPlayerID.test(textID))
return false;
return true;
}
}
messageForInvalidPlayerID(textID) {
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) {
AccountValidator.prototype.isValidPlayerPW = function(textPW) {
if(!this.patternPlayerPW.test(textPW))
return false;
return true;
}
}
messageForInvalidPlayerPW(textPW) {
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자리 숫자로 입력해 주세요.";
}
}
+10 -14
View File
@@ -1,14 +1,12 @@
class MaestroInfo {
constructor() {
function MaestroInfo() {
this.maestroID = sessionStorage.getItem("maestroID");
this.maestroName = "";
this.accountType = 0;
this.playerCount = 0;
}
}
loadMaestroInfo(onSuccess, onFail) {
let self = this;
MaestroInfo.prototype.loadMaestroInfo = function(onSuccess, onFail) {
var self = this;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/maestro_info.php",
@@ -27,9 +25,9 @@ class MaestroInfo {
}
);
}
}
getMaxPlayerCount() {
MaestroInfo.prototype.getMaxPlayerCount = function() {
switch(this.accountType) {
case 0:
case 1:
@@ -52,10 +50,8 @@ class MaestroInfo {
default:
return 0;
}
}
getRegisteredPlayerCount() {
return this.playerCount;
}
}
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";
+5 -10
View File
@@ -1,27 +1,22 @@
class MouseAppList {
constructor(pageNoArea) {
let self = this;
function MouseAppList(pageNoArea) {
var self = this;
this.pageNoArea = pageNoArea;
// console.log(parent);
}
}
addPlayerListPages(playerCount) {
MouseAppList.prototype.addPlayerListPages = function(playerCount) {
lastPageNo = Math.ceil( (playerCount + 1) / 10 );
$(this.pageNoArea).empty();
for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) {
for(var pageNo = 1; pageNo < lastPageNo + 1; pageNo++) {
$(this.pageNoArea).append(
"<a onClick='onClickPlayerListPage(" + pageNo + ")'> " + pageNo + " </a>"
);
}
}
}
function onClickPlayerListPage(pageNo) {
switch(pageNo) {
case "first":
+14 -21
View File
@@ -1,19 +1,14 @@
class PlayerListRow {
constructor(playerID, playerName, enterCode, editButton, 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;
function PlayerList(tagDiv, playerListManager) {
var self = this;
this.playerListManager = playerListManager;
// console.log(tagDiv);
// console.log(playerListManager);
@@ -21,12 +16,12 @@ class PlayerList {
this.playerCount = 0;
this.activePageNo = 1;
// let id_list = tagDiv.find(".player_id");
let id_list = tagDiv.find(".player-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++) {
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"),
@@ -47,9 +42,9 @@ class PlayerList {
this.disableItem(this.listRows[i]);
}
}
}
disableItem(item) {
PlayerList.prototype.disableItem = function(item) {
$(item.playerID).empty();
$(item.playerName).prop("disabled", true);
$(item.enterCode).prop("disabled", true);
@@ -57,20 +52,20 @@ class PlayerList {
// $(item.enterCode).prop("readonly", true);
$(item.editButton).prop("disabled", true);
$(item.deleteButton).prop("disabled", true);
}
}
enableItem(item) {
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);
}
}
updatePlayerList(jsonData) {
PlayerList.prototype.updatePlayerList = function(jsonData) {
if(jsonData === null) {
for(let i = 0; i < 10; i++) {
for(var i = 0; i < 10; i++) {
$(this.listRows[i].playerName).val("");
$(this.listRows[i].enterCode).val("");
@@ -80,7 +75,7 @@ class PlayerList {
return;
}
for(let i = 0; i < 10; i++) {
for(var i = 0; i < 10; i++) {
$(this.listRows[i].playerID).empty();
if(i < jsonData.length) {
@@ -96,6 +91,4 @@ class PlayerList {
this.disableItem(this.listRows[i]);
}
}
}
}
+47 -50
View File
@@ -1,7 +1,5 @@
class PlayerListManager {
constructor(docList, docNav) {
let self = this;
function PlayerListManager(docList, docNav) {
var self = this;
this.docList = docList;
this.docNav = docNav;
this.playerListID = $(docList).attr("id");
@@ -15,11 +13,11 @@
this.lastPageNo = 0;
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",
@@ -39,15 +37,15 @@
}
);
}
}
loadAddPlayerListPage(pageNo) {
let self = this;
PlayerListManager.prototype.loadAddPlayerListPage = function(pageNo) {
var self = this;
this.activePageNo = pageNo;
let pageIndex = pageNo - 1;
let startNo = pageIndex * 10;
let endNo = pageIndex * 10 + 9;
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",
@@ -63,16 +61,16 @@
}
);
}
}
updateAddPlayerListPage(pageNo) {
let self = this;
PlayerListManager.prototype.updateAddPlayerListPage = function(pageNo) {
var self = this;
this.playerListPage = pageNo;
let pageIndex = pageNo - 1;
let startNo = pageIndex * 10;
let endNo = pageIndex * 10 + 9;
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",
@@ -89,12 +87,12 @@
}
);
}
}
setupSearchPlayerList(playerName) {
let self = this;
PlayerListManager.prototype.setupSearchPlayerList = function(playerName) {
var self = this;
this.searchPlayerName = playerName;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
@@ -117,15 +115,15 @@
}
);
}
}
updateSearchPlayerListPage(playerName, pageNo) {
let self = this;
PlayerListManager.prototype.updateSearchPlayerListPage = function(playerName, pageNo) {
var self = this;
this.playerListPage = pageNo;
let pageIndex = pageNo - 1;
let startNo = pageIndex * 10;
let endNo = pageIndex * 10 + 9;
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",
@@ -142,27 +140,27 @@
}
);
}
}
editPlayer(inputButton) {
let self = this;
PlayerListManager.prototype.editPlayer = function(inputButton) {
var self = this;
console.log(inputButton);
// let clickedObjectID = this.getClickedObjectID(inputButton);
// var clickedObjectID = this.getClickedObjectID(inputButton);
let id = $(inputButton).siblings(".player_id");
let playerID = id.text();
var id = $(inputButton).siblings(".player_id");
var playerID = id.text();
// console.log(playerID);
let name = $(inputButton).siblings(".player_name");
let playerName = name.val();
var name = $(inputButton).siblings(".player_name");
var playerName = name.val();
// console.log(playerName);
let enterCode = $(inputButton).siblings(".player_entercode");
let playerEnterCode = enterCode.val();
var enterCode = $(inputButton).siblings(".player_entercode");
var playerEnterCode = enterCode.val();
// console.log(playerEnterCode);
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
@@ -184,19 +182,19 @@
}
);
}
}
deletePlayer(inputButton) {
let self = this;
PlayerListManager.prototype.deletePlayer = function(inputButton) {
var self = this;
let id = $(inputButton).siblings(".player_id");
let playerID = id.text();
var id = $(inputButton).siblings(".player_id");
var playerID = id.text();
let name = $(inputButton).siblings(".player_name");
let playerName = name.val();
var name = $(inputButton).siblings(".player_name");
var playerName = name.val();
// console.log(playerName);
// let clickedObjectID = this.getClickedObjectID(inputButton);
// var clickedObjectID = this.getClickedObjectID(inputButton);
if(playerID === null || playerID === "")
return;
@@ -221,10 +219,10 @@
}
);
}
}
onClickPageNo(pageNo) {
let self = this;
PlayerListManager.prototype.onClickPageNo = function(pageNo) {
var self = this;
self.activePageNo = pageNo;
if(this.playerListID === "add_player_list") {
@@ -233,5 +231,4 @@
self.updateSearchPlayerListPage(this.searchPlayerName, self.activePageNo);
}
}
}
+18 -22
View File
@@ -1,16 +1,14 @@
class PlayerListNavigator {
constructor(pageNoArea, playerListManager) {
let self = this;
function PlayerListNavigator(pageNoArea, playerListManager) {
var self = this;
this.playerListManager = playerListManager;
this.pagination = pageNoArea;
// console.log(parent);
this.activePageNo = 1;
this.lastPageNo = 1;
}
}
updateNavigator(activePageNo, lastPageNo) {
PlayerListNavigator.prototype.updateNavigator = function(activePageNo, lastPageNo) {
this.activePageNo = activePageNo;
this.lastPageNo = lastPageNo;
// this.lastPageNo = Math.ceil( (playerCount + 1) / 10 );
@@ -19,11 +17,11 @@
this.makePagination();
this.applyClickEvent();
this.disableNavButtons();
}
}
makePagination() {
PlayerListNavigator.prototype.makePagination = function() {
// left arrows
let paginationLeftArrows = '\
var paginationLeftArrows = '\
<li class="page-item">\
<a class="page-link" href="javascript:void(0);" aria-label="First">\
<span aria-hidden="true">&laquo;</span>\
@@ -43,14 +41,14 @@
$(this.pagination).append(paginationLeftArrows);
// numbers
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
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 = '\
var paginationRightArrows = '\
<li>&nbsp</li>\
\
<li class="page-item">\
@@ -68,10 +66,10 @@
</li>\
';
$(this.pagination).append(paginationRightArrows);
}
}
applyClickEvent() {
let self = this;
PlayerListNavigator.prototype.applyClickEvent = function() {
var self = this;
$("[aria-label='First']").click(function() {
self.onClickPageNo("first");
@@ -81,7 +79,7 @@
self.onClickPageNo("previous");
});
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
for(var pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$("[aria-label='" + pageNo + "']").click(function() {
self.onClickPageNo(pageNo);
});
@@ -94,9 +92,9 @@
$("[aria-label='Last']").click(function() {
self.onClickPageNo("last");
});
}
}
disableNavButtons() {
PlayerListNavigator.prototype.disableNavButtons = function() {
/*
console.log(this.activePageNo);
console.log(this.lastPageNo);
@@ -112,7 +110,7 @@
else
$("[aria-label='Previous']").parent().prop("disabled", false);
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
for(var pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
if(this.activePageNo === pageNo)
$("[aria-label='" + pageNo + "']").parent().prop("disabled", true);
else
@@ -129,9 +127,9 @@
else
$("[aria-label='Last']").parent().prop("disabled", false);
*/
}
}
onClickPageNo(pageNo) {
PlayerListNavigator.prototype.onClickPageNo = function(pageNo) {
console.log(pageNo);
switch(pageNo) {
case "first":
@@ -158,6 +156,4 @@
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;
}