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
+44 -100
View File
@@ -1,47 +1,28 @@
<script type="text/javascript">
$(document).ready(function() {
loadMouseApp();
});
function loadMouseApp() {
let self = this;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/app/mouse_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/mouse_app_list.php",
"maestro_id=" + maestroID,
(jsonData) => {
makeMouseAppList(jsonData["appList"]);
activateMouseApp(jsonData["activatedAppList"]);
},
(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;
}
makeMouseAppList(replyJSON["List"]);
activateMouseApp(replyJSON["ActivatedList"]);
}
}
);
}
function makeMouseAppList(appList) {
@@ -52,12 +33,12 @@ function makeMouseAppList(appList) {
$("#mouse_app_content").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 {
@@ -69,7 +50,7 @@ function makeMouseAppList(appList) {
function activateMouseApp(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);
@@ -78,76 +59,39 @@ function activateMouseApp(activatedList) {
function activateApp(appID) {
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/app/activate_app.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&app_id=" + appID);
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/activate_app.php",
"maestro_id=" + maestroID + "&app_id=" + appID,
(jsonData) => {
// addPlayerListManager.updateAddPlayerListPage(1);
},
(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;
}
}
}
);
}
function deactivateApp(appID) {
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/app/deactivate_app.php",
"maestro_id=" + maestroID + "&app_id=" + appID,
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/app/deactivate_app.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&app_id=" + appID);
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;
(jsonData) => {
// addPlayerListManager.updateAddPlayerListPage(1);
},
(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;
}
}
}
);
}
</script>