Add: player list manager
This commit is contained in:
+22
-48
@@ -1,13 +1,16 @@
|
|||||||
let maestroID = -1;
|
let maestroID = -1;
|
||||||
let playerCount = 0;
|
// let playerCount = 0;
|
||||||
let playerListPage = 0;
|
// let playerListPage = 0;
|
||||||
let lastPageNo = 0;
|
// let lastPageNo = 0;
|
||||||
|
|
||||||
let addPlayerList;
|
let addPlayerListManager;
|
||||||
let addPlayerListNavigator;
|
let searchPlayerListManager;
|
||||||
|
|
||||||
let searchPlayerList;
|
// let addPlayerList;
|
||||||
let searchPlayerListNavigator;
|
// let addPlayerListNavigator;
|
||||||
|
|
||||||
|
// let searchPlayerList;
|
||||||
|
// let searchPlayerListNavigator;
|
||||||
|
|
||||||
let mouseAppList;
|
let mouseAppList;
|
||||||
|
|
||||||
@@ -19,47 +22,6 @@ $(document).ready(function() {
|
|||||||
console.log("maestroID : " + maestroID);
|
console.log("maestroID : " + maestroID);
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadPlayerList() {
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/user/registered_player_count.php', true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
playerCount = replyJSON["Count"];
|
|
||||||
|
|
||||||
loadPlayerListPage(1);
|
|
||||||
addPlayerListNavigator.addPlayerListPages(playerCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function tabClicked(tabNo) {
|
function tabClicked(tabNo) {
|
||||||
// hide and show tab
|
// hide and show tab
|
||||||
for(let i = 0; i < 4; i++) {
|
for(let i = 0; i < 4; i++) {
|
||||||
@@ -98,3 +60,15 @@ function tabClicked(tabNo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onClickPlayerListPage(item, pageNo) {
|
||||||
|
let tagDiv = $(item).closest("div");
|
||||||
|
let tagDivIDName = tagDiv.prop("id");
|
||||||
|
// console.log(tagDivIDName);
|
||||||
|
|
||||||
|
if(tagDivIDName === "add_player_list_navigator")
|
||||||
|
addPlayerListManager.onClickPlayerListPage(pageNo);
|
||||||
|
else if(tagDivIDName === "search_player_list_navigator")
|
||||||
|
searchPlayerListManager.onClickPlayerListPage(pageNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+47
-40
@@ -15,7 +15,10 @@ class PlayerList {
|
|||||||
constructor(parent) {
|
constructor(parent) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.listParent = parent;
|
this.listParent = parent;
|
||||||
console.log(parent);
|
// console.log(parent);
|
||||||
|
|
||||||
|
this.playerCount = 0;
|
||||||
|
this.playerListPage = 1;
|
||||||
|
|
||||||
let id_list = parent.find(".player_id");
|
let id_list = parent.find(".player_id");
|
||||||
// console.log(id_list);
|
// console.log(id_list);
|
||||||
@@ -136,50 +139,54 @@ class PlayerList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
loadPlayerListPage(pageNo) {
|
||||||
|
self = this;
|
||||||
|
this.playerListPage = pageNo;
|
||||||
|
|
||||||
function loadPlayerListPage(pageNo) {
|
let pageIndex = pageNo - 1;
|
||||||
playerListPage = pageNo;
|
let startNo = pageIndex * 10;
|
||||||
|
let endNo = pageIndex * 10 + 9;
|
||||||
|
|
||||||
let pageIndex = pageNo - 1;
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
let startNo = pageIndex * 10;
|
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
|
||||||
let endNo = pageIndex * 10 + 9;
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
|
||||||
|
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 xhr = new XMLHttpRequest(); //new로 생성.
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
|
// console.log(replyJSON);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
|
if(replyJSON === null) {
|
||||||
xhr.onload = function() {
|
console.log("no data from server");
|
||||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
return;
|
||||||
// console.log(xhr.responseText);
|
}
|
||||||
// console.log(xhr.responseText.length);
|
|
||||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||||
console.log("no data from server");
|
console.log(replyJSON["ERROR"]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(replyJSON["RESULT"] === "fail") {
|
||||||
|
console.log(replyJSON["RESULT"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(replyJSON["PlayerList"]);
|
||||||
|
// updatePlayerListPage(replyJSON["PlayerList"]);
|
||||||
|
self.updatePlayerList(replyJSON["PlayerList"]);
|
||||||
|
|
||||||
|
self.playerCount = replyJSON["PlayerList"].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(replyJSON["PlayerList"]);
|
|
||||||
// updatePlayerListPage(replyJSON["PlayerList"]);
|
|
||||||
addPlayerList.updatePlayerList(replyJSON["PlayerList"]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,196 @@
|
|||||||
|
class PlayerListManager {
|
||||||
|
|
||||||
|
constructor(docList, docNav) {
|
||||||
|
let self = this;
|
||||||
|
this.docList = docList;
|
||||||
|
this.docNav = docNav;
|
||||||
|
|
||||||
|
this.list = new PlayerList(this.docList);
|
||||||
|
this.listNavigator = new PlayerListNavigator(this.docNav);
|
||||||
|
// console.log(this.list);
|
||||||
|
// console.log(this.listNavigator);
|
||||||
|
|
||||||
|
this.playerCount = 0;
|
||||||
|
this.activePageNo = 1;
|
||||||
|
this.lastPageNo = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setupAddPlayerList() {
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/registered_player_count.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.playerCount = replyJSON["Count"];
|
||||||
|
self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 );
|
||||||
|
self.activePageNo = 1;
|
||||||
|
|
||||||
|
self.list.loadPlayerListPage(self.activePageNo);
|
||||||
|
self.listNavigator.updateNavigator(self.playerCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateAddPlayerListPage(pageNo) {
|
||||||
|
self = this;
|
||||||
|
this.playerListPage = pageNo;
|
||||||
|
|
||||||
|
let pageIndex = pageNo - 1;
|
||||||
|
let startNo = pageIndex * 10;
|
||||||
|
let endNo = pageIndex * 10 + 9;
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(replyJSON["PlayerList"]);
|
||||||
|
self.list.updatePlayerList(replyJSON["PlayerList"]);
|
||||||
|
|
||||||
|
self.playerCount = replyJSON["PlayerList"].length;
|
||||||
|
console.log(self.playerCount);
|
||||||
|
self.listNavigator.updateNavigator(self.playerCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSearchPlayerListPage(playerName, pageNo) {
|
||||||
|
let self = this;
|
||||||
|
this.playerListPage = pageNo;
|
||||||
|
|
||||||
|
let pageIndex = pageNo - 1;
|
||||||
|
let startNo = pageIndex * 10;
|
||||||
|
let endNo = pageIndex * 10 + 9;
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID + "&playerName=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(replyJSON["PlayerList"]);
|
||||||
|
self.list.updatePlayerList(replyJSON["PlayerList"]);
|
||||||
|
|
||||||
|
self.playerCount = replyJSON["PlayerList"].length;
|
||||||
|
self.listNavigator.updateNavigator(self.playerCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// onClickPlayerListPage(pageNo) {
|
||||||
|
// this.listNavigator.onClickPlayerListPage(pageNo);
|
||||||
|
// }
|
||||||
|
|
||||||
|
onClickPlayerListPage(pageNo) {
|
||||||
|
switch(pageNo) {
|
||||||
|
case "first":
|
||||||
|
this.activePageNo = 1;
|
||||||
|
this.list.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case "prev":
|
||||||
|
if(this.activePageNo > 1)
|
||||||
|
this.activePageNo -= 1;
|
||||||
|
this.list.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case "next":
|
||||||
|
if(this.activePageNo < this.lastPageNo)
|
||||||
|
this.activePageNo += 1;
|
||||||
|
this.list.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case "last":
|
||||||
|
this.list.loadPlayerListPage(this.lastPageNo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activePageNo = pageNo;
|
||||||
|
this.list.loadPlayerListPage(this.activePageNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4,48 +4,52 @@
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.pageNoArea = pageNoArea;
|
this.pageNoArea = pageNoArea;
|
||||||
// console.log(parent);
|
// console.log(parent);
|
||||||
|
|
||||||
|
this.activePageNo = 1;
|
||||||
|
this.lastPageNo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerListPages(playerCount) {
|
updateNavigator(playerCount) {
|
||||||
lastPageNo = Math.ceil( (playerCount + 1) / 10 );
|
this.lastPageNo = Math.ceil( (playerCount + 1) / 10 );
|
||||||
|
|
||||||
$(this.pageNoArea).empty();
|
$(this.pageNoArea).empty();
|
||||||
|
|
||||||
for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) {
|
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
|
||||||
$(this.pageNoArea).append(
|
$(this.pageNoArea).append(
|
||||||
"<a onClick='onClickPlayerListPage(" + pageNo + ")'> " + pageNo + " </a>"
|
"<a onClick='onClickPlayerListPage(this, " + pageNo + ")'> " + pageNo + " </a>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
onClickPlayerListPage(pageNo) {
|
||||||
|
switch(pageNo) {
|
||||||
|
case "first":
|
||||||
|
this.activePageNo = 1;
|
||||||
|
this.playerList.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case "prev":
|
||||||
|
if(this.activePageNo > 1)
|
||||||
|
this.activePageNo -= 1;
|
||||||
|
this.playerList.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case "next":
|
||||||
|
if(this.activePageNo < this.lastPageNo)
|
||||||
|
this.activePageNo += 1;
|
||||||
|
this.playerList.loadPlayerListPage(this.activePageNo);
|
||||||
|
return;
|
||||||
|
|
||||||
function onClickPlayerListPage(pageNo) {
|
case "last":
|
||||||
switch(pageNo) {
|
this.playerList.loadPlayerListPage(this.lastPageNo);
|
||||||
case "first":
|
return;
|
||||||
playerListPage = 1;
|
}
|
||||||
loadPlayerListPage(playerListPage);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "prev":
|
this.activePageNo = pageNo;
|
||||||
if(playerListPage > 1)
|
this.playerList.loadPlayerListPage(this.activePageNo);
|
||||||
playerListPage -= 1;
|
|
||||||
loadPlayerListPage(playerListPage);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "next":
|
|
||||||
if(playerListPage < lastPageNo)
|
|
||||||
playerListPage += 1;
|
|
||||||
loadPlayerListPage(playerListPage);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "last":
|
|
||||||
loadPlayerListPage(lastPageNo);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPlayerListPage(pageNo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<script type="text/javascript" src="./../js/maestro_main.js"></script>
|
<script type="text/javascript" src="./../js/maestro_main.js"></script>
|
||||||
<script type="text/javascript" src="./../js/player_list.js"></script>
|
<script type="text/javascript" src="./../js/player_list.js"></script>
|
||||||
<script type="text/javascript" src="./../js/player_list_navigator.js"></script>
|
<script type="text/javascript" src="./../js/player_list_navigator.js"></script>
|
||||||
|
<script type="text/javascript" src="./../js/player_list_manager.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#header").load("./../module/maestro_header.html");
|
$("#header").load("./../module/maestro_header.html");
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
addPlayerList = new PlayerList($("#add_player_list"));
|
addPlayerListManager = new PlayerListManager(
|
||||||
addPlayerListNavigator = new PlayerListNavigator($("#add_player_list_navigator > #page_no_area"));
|
$("#add_player_list"),
|
||||||
|
$("#add_player_list_navigator > #page_no_area")
|
||||||
|
);
|
||||||
|
// addPlayerListNavigator = new PlayerListNavigator($("#add_player_list_navigator > #page_no_area"));
|
||||||
|
// addPlayerList = new PlayerList($("#add_player_list"), addPlayerListNavigator);
|
||||||
|
|
||||||
loadPlayerList();
|
// addPlayerList.loadPlayerListPage(1);
|
||||||
addPlayerListNavigator.addPlayerListPages();
|
addPlayerListManager.setupAddPlayerList();
|
||||||
});
|
});
|
||||||
|
|
||||||
function addPlayer() {
|
function addPlayer() {
|
||||||
@@ -180,10 +184,10 @@ function addPlayer() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="add_player_list_navigator" class="player_list_navigator">
|
<div id="add_player_list_navigator" class="player_list_navigator">
|
||||||
<span><a onClick="onClickPlayerListPage('first')"> ≪ </a></span>
|
<span><a onClick="onClickPlayerListPage(this, 'first')"> ≪ </a></span>
|
||||||
<span><a onClick="onClickPlayerListPage('prev')"> < </a></span>
|
<span><a onClick="onClickPlayerListPage(this, 'prev')"> < </a></span>
|
||||||
<span id="page_no_area"></span>
|
<span id="page_no_area"></span>
|
||||||
<span><a onClick="onClickPlayerListPage('next')"> > </a></span>
|
<span><a onClick="onClickPlayerListPage(this, 'next')"> > </a></span>
|
||||||
<span><a onClick="onClickPlayerListPage('last')"> ≫ </a></span>
|
<span><a onClick="onClickPlayerListPage(this, 'last')"> ≫ </a></span>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
@@ -1,8 +1,61 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
searchPlayerList = new PlayerList($("#search_player_list"));
|
searchPlayerListManager = new PlayerListManager(
|
||||||
searchPlayerListNavigator = new PlayerListNavigator($("#search_player_list_navigator > #page_no_area"));
|
$("#search_player_list"),
|
||||||
|
$("#search_player_list_navigator > #page_no_area")
|
||||||
|
);
|
||||||
|
|
||||||
|
// searchPlayerList = new PlayerList($("#search_player_list"));
|
||||||
|
// searchPlayerListNavigator = new PlayerListNavigator($("#search_player_list_navigator > #page_no_area"));
|
||||||
|
searchPlayerListManager.updateSearchPlayerListPage(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function searchPlayer() {
|
||||||
|
// let maestroID = sessionStorage.getItem("maestroID");
|
||||||
|
let playerName = $("#search_name").val();
|
||||||
|
|
||||||
|
if(playerName.length === 0) {
|
||||||
|
$("#add_player_notice").val("학생 이름을 입력하세요.");
|
||||||
|
$("#add_player_name").focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/search_player.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$maestroID = $_POST["maestro_id"];
|
||||||
|
$playerName = $_POST["player_name"];
|
||||||
|
$enterCode = $_POST["enter_code"];
|
||||||
|
/*
|
||||||
|
if(!is_numeric($enterCode)) {
|
||||||
|
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
|
||||||
|
exit;
|
||||||
|
} else if(strlen($enterCode) != 6) {
|
||||||
|
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
$result = hasPlayerName($maestroID, $playerName, $enterCode);
|
||||||
|
if($result !== null) {
|
||||||
|
send_error_message($replyJSON, "이미 등록된 학생과 입장 코드 정보입니다.");
|
||||||
|
// $db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
addPlayer($maestroID, $playerName, $enterCode);
|
||||||
|
|
||||||
|
$result = hasPlayerName($maestroID, $playerName, $enterCode);
|
||||||
|
if($result === null) {
|
||||||
|
send_result_message($replyJSON, "fail");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
send_result_message($replyJSON, "success");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||||
|
// $db_conn->close();
|
||||||
|
|
||||||
|
|
||||||
|
function hasPlayerName($maestroID, $playerName, $enterCode) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND EnterCode=?";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($userID);
|
||||||
|
// while($stmt->fetch())
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// $replyJSON["UserID"] = $userID;
|
||||||
|
return $userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPlayer($maestroID, $playerName, $enterCode) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "INSERT INTO moty_user (MaestroID, Name, EnterCode) VALUES (?, ?, ?)";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user