Fix: revised php code to maestro app typing list

This commit is contained in:
2018-07-12 11:14:29 +09:00
parent f23665a5f0
commit 07b65f004b
4 changed files with 103 additions and 173 deletions
+25 -43
View File
@@ -1,47 +1,29 @@
<script type="text/javascript">
$(document).ready(function() {
loadTypingApp();
});
function loadTypingApp() {
let self = this;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/app/typing_app_list.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;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/app/typing_app_list.php",
"maestro_id=" + maestroID,
(jsonData) => {
makeTypingAppList(jsonData["appList"]);
activateTypingApp(jsonData["activatedAppList"]);
},
(errorMessage) => {
console.log(errorMessage);
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
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;
}
makeTypingAppList(replyJSON["List"]);
activateTypingApp(replyJSON["ActivatedList"]);
}
}
);
}
function makeTypingAppList(appList) {
@@ -53,28 +35,28 @@ function makeTypingAppList(appList) {
for(let i = 0; i < appList.length; i++) {
let appData = appList[i];
if(appData.KoreanName === "")
if(appData.koreanName === "")
continue;
let divTag = null;
if(appData.AppID <= 10)
if(appData.appID <= 10)
divTag = $("#typing_practice_kor");
else if(appData.AppID <= 20)
else if(appData.appID <= 20)
divTag = $("#typing_practice_eng");
else if(appData.AppID <= 30)
else if(appData.appID <= 30)
divTag = $("#typing_test_kor");
else if(appData.AppID <= 40)
else if(appData.appID <= 40)
divTag = $("#typing_test_eng");
else
divTag = $("#typing_app");
divTag.append(
"<span>"
+ "<input type='checkbox' id='checkbox" + appData.AppID + "' data-app-id='" + appData.AppID + "' />"
+ "<label for='checkbox" + appData.AppID + "'>" + appData.KoreanName + "</label>"
+ "<input type='checkbox' id='checkbox" + appData.appID + "' data-app-id='" + appData.appID + "' />"
+ "<label for='checkbox" + appData.appID + "'>" + appData.koreanName + "</label>"
+ "</span>"
);
$("#checkbox" + appData.AppID).change(function() {
$("#checkbox" + appData.appID).change(function() {
if($(this).is(":checked")) {
activateApp($(this).data("appId"));
} else {
@@ -86,7 +68,7 @@ function makeTypingAppList(appList) {
function activateTypingApp(activatedList) {
for(let i = 0; i < activatedList.length; i++) {
let activatedAppID = activatedList[i].AppID;
let activatedAppID = activatedList[i].appID;
let input = $("#checkbox" + activatedAppID);
input.prop("checked", true);