diff --git a/src/web/css/maestro_main.css b/src/web/css/maestro_main.css
index cac0b67..ec00711 100644
--- a/src/web/css/maestro_main.css
+++ b/src/web/css/maestro_main.css
@@ -111,9 +111,4 @@
*/
-.activate_app_checkbox {
- width: 200px;
- height: 200px;
-}
-
\ No newline at end of file
diff --git a/src/web/module/maestro_section_main.html b/src/web/module/maestro_section_main.html
index 4ce0859..fadb68b 100644
--- a/src/web/module/maestro_section_main.html
+++ b/src/web/module/maestro_section_main.html
@@ -3,6 +3,7 @@ $(document).ready(function() {
$("#section_add_player").load("./../module/maestro_section_add_player.html");
$("#search_player").load("./../module/maestro_section_search.html");
$("#mouse_app_list").load("./../module/maestro_section_mouse_app.html");
+ $("#typing_app_list").load("./../module/maestro_section_typing_app.html");
// loadPlayerList();
});
@@ -31,14 +32,6 @@ $(document).ready(function() {
-
-
diff --git a/src/web/module/maestro_section_mouse_app.html b/src/web/module/maestro_section_mouse_app.html
index a0c0834..a30c42a 100644
--- a/src/web/module/maestro_section_mouse_app.html
+++ b/src/web/module/maestro_section_mouse_app.html
@@ -21,7 +21,7 @@ function loadMouseApp() {
}
let replyJSON = JSON.parse(xhr.responseText);
- console.log(replyJSON);
+ // console.log(replyJSON);
if(replyJSON === null) {
console.log("no data from server");
@@ -40,31 +40,30 @@ function loadMouseApp() {
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) {
+function makeMouseAppList(appList) {
$("#mouse_app_content").empty();
- for(let i = 0; i < mouseAppList.length; i++) {
- let mouseApp = mouseAppList[i];
+ for(let i = 0; i < appList.length; i++) {
+ let appData = appList[i];
- let checkboxIndex = i + 1;
$("#mouse_app_content").append(
""
- + ""
- + ""
+ + ""
+ + ""
+ ""
);
+
+ $("#checkbox" + appData.AppID).change(function() {
+ if($(this).is(":checked")) {
+ activateApp($(this).data("appId"));
+ } else {
+ deactivateApp($(this).data("appId"));
+ }
+ });
}
}
@@ -74,13 +73,80 @@ function activateMouseApp(activatedList) {
let input = $("#checkbox" + activatedAppID);
input.prop("checked", true);
+ }
+}
- // let input = $("input").filter(function() {
- // return $(this).data("app_id") == activatedAppID;
- // });
+function activateApp(appID) {
- console.log(input);
- // input.checked = true;
+ 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;
+ }
+
+ 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) {
+
+ 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;
+ }
+
+ 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;
+ }
+
+ }
}
}
@@ -97,12 +163,12 @@ function activateMouseApp(activatedList) {
-
+
-
+
\ No newline at end of file
diff --git a/src/web/module/maestro_section_typing_app.html b/src/web/module/maestro_section_typing_app.html
new file mode 100644
index 0000000..08323d7
--- /dev/null
+++ b/src/web/module/maestro_section_typing_app.html
@@ -0,0 +1,119 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/web/server/app/activate_app.php b/src/web/server/app/activate_app.php
new file mode 100644
index 0000000..c257ce9
--- /dev/null
+++ b/src/web/server/app/activate_app.php
@@ -0,0 +1,30 @@
+close();
+
+
+function activate_app($maestroID, $appID) {
+ global $db_conn;
+
+ $query = "
+ INSERT INTO moty_active_app (MaestroID, AppID)
+ VALUES (?, ?);
+ ";
+ $stmt = $db_conn->prepare($query);
+ $stmt->bind_param('ii', $maestroID, $appID);
+ $stmt->execute();
+ $stmt->bind_result();
+}
+
+?>
\ No newline at end of file
diff --git a/src/web/server/app/deactivate_app.php b/src/web/server/app/deactivate_app.php
new file mode 100644
index 0000000..00ecb0e
--- /dev/null
+++ b/src/web/server/app/deactivate_app.php
@@ -0,0 +1,30 @@
+close();
+
+
+function deactivate_app($maestroID, $appID) {
+ global $db_conn;
+
+ $query = "
+ DELETE FROM moty_active_app
+ WHERE MaestroID = ? AND AppID = ?;
+ ";
+ $stmt = $db_conn->prepare($query);
+ $stmt->bind_param('ii', $maestroID, $appID);
+ $stmt->execute();
+ $stmt->bind_result();
+}
+
+?>
\ No newline at end of file
diff --git a/src/web/server/app/mouse_app_list.php b/src/web/server/app/mouse_app_list.php
index 92f151e..b35cb95 100644
--- a/src/web/server/app/mouse_app_list.php
+++ b/src/web/server/app/mouse_app_list.php
@@ -27,7 +27,7 @@ function get_mouse_app_list() {
$query = "
SELECT AppID, AppName, KoreanName FROM moty_app
WHERE AppType=100
- ORDER BY AppID DESC
+ ORDER BY AppID ASC
";
$stmt = $db_conn->prepare($query);
$stmt->execute();
diff --git a/src/web/server/app/typing_app_list.php b/src/web/server/app/typing_app_list.php
new file mode 100644
index 0000000..931b1ee
--- /dev/null
+++ b/src/web/server/app/typing_app_list.php
@@ -0,0 +1,69 @@
+close();
+ exit;
+}
+
+$activated_typing_app_list = get_activated_typing_app_list($maestroID);
+$replyJSON["List"] = $typing_app_list;
+$replyJSON["ActivatedList"] = $activated_typing_app_list;
+$replyJSON["RESULT"] = "ok";
+echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
+$db_conn->close();
+
+
+function get_typing_app_list() {
+ global $db_conn;
+
+ $query = "
+ SELECT AppID, AppName, KoreanName FROM moty_app
+ WHERE AppType < 100
+ ORDER BY AppID ASC
+ ";
+ $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_typing_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;
+}
+
+?>
\ No newline at end of file