Add: mouse_app_list

This commit is contained in:
2018-07-05 17:03:44 +09:00
parent eee26929db
commit ae523ea4ad
4 changed files with 196 additions and 6 deletions
+93 -6
View File
@@ -1,21 +1,108 @@
<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;
}
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"]);
/*
self.playerCount = replyJSON["Count"];
self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 );
self.activePageNo = 1;
self.loadAddPlayerListPage(self.activePageNo);
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo);
*/
}
}
}
function makeMouseAppList(mouseAppList) {
$("#mouse_app_content").empty();
for(let i = 0; i < mouseAppList.length; i++) {
let mouseApp = mouseAppList[i];
let checkboxIndex = i + 1;
$("#mouse_app_content").append(
"<span>"
+ "<input type='checkbox' id='checkbox" + mouseApp.AppID + "' class='activate_app_checkbox' />"
+ "<label for='checkbox" + mouseApp.AppID + "'>" + mouseApp.KoreanName + "</label>"
+ "</span>"
);
}
}
function activateMouseApp(activatedList) {
for(let i = 0; i < activatedList.length; i++) {
let activatedAppID = activatedList[i].AppID;
let input = $("#checkbox" + activatedAppID);
input.prop("checked", true);
// let input = $("input").filter(function() {
// return $(this).data("app_id") == activatedAppID;
// });
console.log(input);
// input.checked = true;
}
}
</script>
<div id="mouse_app_content">
<input type="checkbox" id="checkbox1" checked="checked" />
<label for="checkbox1">Option 1</label>
<span>
<input type="checkbox" id="checkbox1" checked="checked" />
<label for="checkbox1">Option 1</label>
</span>
<input type="checkbox" id="checkbox2" />
<label for="checkbox2">Option 2</label>
<span>
<input type="checkbox" id="checkbox2" checked="checked" />
<label for="checkbox2">Option 1</label>
</span>
<input type="checkbox" id="checkbox3" />
<label for="checkbox3">Option 3</label>
<span>
<input type="checkbox" id="checkbox3" checked="checked" />
<label for="checkbox3">Option 1</label>
</span>
</div>