Add: mouse_app_list
This commit is contained in:
@@ -110,4 +110,10 @@
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
.activate_app_checkbox {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -80,4 +80,32 @@ footer {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
|
||||
input[type="checkbox"]{
|
||||
width:1px;
|
||||
height:1px;
|
||||
padding:0;
|
||||
border:0 none;
|
||||
margin:0;
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
overflow:hidden;
|
||||
clip:rect(0 0 0 0);
|
||||
}
|
||||
|
||||
label{
|
||||
height:15px;
|
||||
line-height:15px;
|
||||
padding-left:20px;
|
||||
display:inline-block;
|
||||
background:url(http://hcs1105.com/wp/wp-content/themes/hcs1105/images/checkbox1.png) no-repeat 0 0;
|
||||
font-size:15px;
|
||||
vertical-align:middle;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked + label{
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
</style>
|
||||
@@ -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">
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$maestroID = $_POST["maestro_id"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$mouse_app_list = get_mouse_app_list();
|
||||
if($mouse_app_list.length === 0) {
|
||||
send_error_message($replyJSON, "등록된 마우스 앱 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$activated_mouse_app_list = get_activated_mouse_app_list($maestroID);
|
||||
$replyJSON["List"] = $mouse_app_list;
|
||||
$replyJSON["ActivatedList"] = $activated_mouse_app_list;
|
||||
$replyJSON["RESULT"] = "ok";
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_mouse_app_list() {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT AppID, AppName, KoreanName FROM moty_app
|
||||
WHERE AppType=100
|
||||
ORDER BY AppID DESC
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($appID, $appName, $koreanName);
|
||||
|
||||
$playerList = array();
|
||||
while($stmt->fetch()) {
|
||||
$player['AppID'] = $appID;
|
||||
$player['AppName'] = $appName;
|
||||
$player['KoreanName'] = $koreanName;
|
||||
array_push($playerList, $player);
|
||||
}
|
||||
|
||||
return $playerList;
|
||||
}
|
||||
|
||||
function get_activated_mouse_app_list($maestroID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT A.AppID
|
||||
FROM moty_app AS A
|
||||
INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND A.AppType = 100 AND AA.MaestroID=?"
|
||||
;
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $maestroID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($appID);
|
||||
|
||||
$playerList = array();
|
||||
while($stmt->fetch()) {
|
||||
$player['AppID'] = $appID;
|
||||
array_push($playerList, $player);
|
||||
}
|
||||
|
||||
return $playerList;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user