Add: register_maestro
This commit is contained in:
@@ -7,14 +7,163 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="./../css/module.css">
|
||||
<link rel="stylesheet" type="text/css" href="./../css/color_button.css">
|
||||
<link rel="stylesheet" type="text/css" href="./../css/admin.css">
|
||||
|
||||
<script type="text/javascript" src="./../../../resources/jquery/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript" src="./../js/main.js"></script>
|
||||
<script type="text/javascript" src="./../js/maestro_list_manager.js"></script>
|
||||
<script type="text/javascript" src="./../js/maestro_list.js"></script>
|
||||
<script type="text/javascript" src="./../js/maestro_list_navigator.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#header").load("admin_header.html");
|
||||
$("#section").load("admin_section.html");
|
||||
|
||||
loadMaestroList("");
|
||||
});
|
||||
|
||||
function searchMaestro() {
|
||||
let maestroName = $("#search_name").val();
|
||||
|
||||
if(maestroName.length === 0) {
|
||||
// $("#search_name_notice").val("학생 이름을 입력하세요.");
|
||||
$("#search_name").focus();
|
||||
}
|
||||
|
||||
loadMaestroList($maestroName);
|
||||
}
|
||||
|
||||
function loadMaestroList($maestroName) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', './../server/admin/registered_maestro_list.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("maestro_name=" + $maestroName);
|
||||
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;
|
||||
}
|
||||
|
||||
updateMaestroList(replyJSON["MaestroList"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateMaestroList(jsonList) {
|
||||
$("#maestro_list_result_contents").empty();
|
||||
printHeader();
|
||||
printContents(jsonList);
|
||||
printFooter();
|
||||
}
|
||||
|
||||
function printHeader() {
|
||||
$("#maestro_list_result_contents").append(
|
||||
"<ul id='search_maestro_list' class='maestro_list'>"
|
||||
+ " <li>"
|
||||
+ " <span class='maestro_name'>이름</span>"
|
||||
+ " <span class='maestro_account_type'>금액</span>"
|
||||
+ " </li>"
|
||||
);
|
||||
}
|
||||
|
||||
function printContents(jsonList) {
|
||||
console.log(jsonList);
|
||||
if(jsonList === undefined || jsonList.length === 0)
|
||||
return;
|
||||
|
||||
for(let i = 0; i < jsonList.length; i++) {
|
||||
$("#maestro_list_result_contents").append(
|
||||
"<li class='search_result_list'>"
|
||||
+ " <span class='maestro_id hide'>" + jsonList[i].MaestroID + "</span>"
|
||||
+ " <input type='text' value='" + jsonList[i].Name + "' class='maestro_name'>"
|
||||
+ " <input type='text' value='" + jsonList[i].AccountType + "' class='maestro_account_type'>"
|
||||
+ " <input type='button' class='maestro_register' value='등록' onClick='register(this)'>"
|
||||
+ "</li>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function printFooter() {
|
||||
$("#maestro_list_result_contents").append("</ul>");
|
||||
}
|
||||
|
||||
function getClickedObjectID(clickedObject) {
|
||||
let tagDiv = $(clickedObject).closest(".player_list");
|
||||
let tagDivID = tagDiv.prop("id");
|
||||
// console.log(tagDivIDName);
|
||||
|
||||
return tagDivID;
|
||||
}
|
||||
|
||||
function register(inputButton) {
|
||||
console.log(inputButton);
|
||||
|
||||
|
||||
let id = $(inputButton).siblings(".maestro_id");
|
||||
let maestroID = id.text();
|
||||
console.log(maestroID);
|
||||
|
||||
let name = $(inputButton).siblings(".maestro_name");
|
||||
let maestroName = name.val();
|
||||
console.log(maestroName);
|
||||
|
||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||
xhr.open('POST', './../server/admin/register_maestro.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;
|
||||
}
|
||||
|
||||
loadMaestroList("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -28,6 +177,19 @@
|
||||
</header>
|
||||
|
||||
<section id="section">
|
||||
<span id="search_maestro_name">
|
||||
<h1>검색</h1>
|
||||
|
||||
마에스트로 이름
|
||||
<input type="text" id="search_name"><input type="submit" name="찾기" onClick="searchMaestro()"><br/>
|
||||
<br/>
|
||||
</span>
|
||||
|
||||
<span id="search_result">
|
||||
검색 결과
|
||||
<div id="maestro_list_result_contents">
|
||||
</div>
|
||||
</span>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user