Fix: move addPlayer function
This commit is contained in:
@@ -4,11 +4,15 @@ let playerListPage = 0;
|
||||
let lastPageNo = 0;
|
||||
|
||||
let addPlayerList;
|
||||
let searchPlayerList;
|
||||
|
||||
let addPlayerListNavigator;
|
||||
|
||||
let searchPlayerList;
|
||||
let searchPlayerListNavigator;
|
||||
|
||||
let mouseAppList;
|
||||
|
||||
let typingAppList;
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
maestroID = sessionStorage.getItem("maestroID");
|
||||
@@ -94,51 +98,3 @@ function tabClicked(tabNo) {
|
||||
}
|
||||
}
|
||||
|
||||
function addPlayer() {
|
||||
// let maestroID = sessionStorage.getItem("maestroID");
|
||||
let playerName = $("#add_player_name").val();
|
||||
let enterCode = $("#add_player_enter_code").val();
|
||||
|
||||
if(playerName.length === 0) {
|
||||
$("#add_player_notice").val("학생 이름을 입력하세요.");
|
||||
$("#add_player_name").focus();
|
||||
} else if(enterCode.length === 0) {
|
||||
$("#add_player_notice").val("엔터 코드를 입력하세요.");
|
||||
$("#add_player_enter_code").focus();
|
||||
}
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/user/add_player.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode);
|
||||
xhr.onload = function() {
|
||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||
// console.log(xhr.responseText);
|
||||
// console.log(xhr.responseText.length);
|
||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
// console.log(replyJSON);
|
||||
|
||||
if(replyJSON === null) {
|
||||
console.log("no data from server");
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||
console.log(replyJSON["ERROR"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(replyJSON["RESULT"] === "fail") {
|
||||
console.log(replyJSON["RESULT"]);
|
||||
return;
|
||||
}
|
||||
|
||||
loadPlayerListPage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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 onClickPlayerListPage(pageNo) {
|
||||
switch(pageNo) {
|
||||
case "first":
|
||||
playerListPage = 1;
|
||||
loadPlayerListPage(playerListPage);
|
||||
return;
|
||||
|
||||
case "prev":
|
||||
if(playerListPage > 1)
|
||||
playerListPage -= 1;
|
||||
loadPlayerListPage(playerListPage);
|
||||
return;
|
||||
|
||||
case "next":
|
||||
if(playerListPage < lastPageNo)
|
||||
playerListPage += 1;
|
||||
loadPlayerListPage(playerListPage);
|
||||
return;
|
||||
|
||||
case "last":
|
||||
loadPlayerListPage(lastPageNo);
|
||||
return;
|
||||
}
|
||||
|
||||
loadPlayerListPage(pageNo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user