Add: typing practice app button
This commit is contained in:
@@ -20,9 +20,29 @@ class AppInfoManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerAppInfoList() {
|
registerAppInfoList() {
|
||||||
|
// menu
|
||||||
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
||||||
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
||||||
this.registerAppInfo(new AppInfo("menu", "메뉴", ""));
|
this.registerAppInfo(new AppInfo("menu", "메뉴", ""));
|
||||||
|
|
||||||
|
// typing
|
||||||
|
this.registerAppInfo(new AppInfo("korean_basic", "기본 자리", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_left_upper", "왼손 윗글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_second_finger", "검지 글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_right_upper", "오른손 윗글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_left_lower", "왼손 밑글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_right_lower", "오른손 밑글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_left_upper_double", "쌍자음", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("korean_right_upper_double", "쌍모음", ""));
|
||||||
|
|
||||||
|
this.registerAppInfo(new AppInfo("english_basic", "기본 자리", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("english_left_upper", "왼손 윗글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("english_second_finger", "검지 글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("english_right_upper", "오른손 윗글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("english_left_lower", "왼손 밑글쇠", ""));
|
||||||
|
this.registerAppInfo(new AppInfo("english_right_lower", "오른손 밑글쇠", ""));
|
||||||
|
|
||||||
|
// mouse
|
||||||
this.registerAppInfo(new AppInfo("space_invaders", "외계인 침공",
|
this.registerAppInfo(new AppInfo("space_invaders", "외계인 침공",
|
||||||
"외계인이 나타났다!\n마우스 왼쪽 버튼으로\n외계인을 클릭해서 물리쳐 주세요."
|
"외계인이 나타났다!\n마우스 왼쪽 버튼으로\n외계인을 클릭해서 물리쳐 주세요."
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -81,6 +81,23 @@ class DBConnectManager {
|
|||||||
xhr.send("maestro_id=" + maestroID);
|
xhr.send("maestro_id=" + maestroID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app.php", true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||||
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
|
||||||
|
if(replyJSON != null && replyJSON.length > 0)
|
||||||
|
onSucceededListener(replyJSON);
|
||||||
|
else
|
||||||
|
onFailedListener(replyJSON);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send("maestro_id=" + maestroID);
|
||||||
|
}
|
||||||
|
|
||||||
requestPlayerHistory(maestroID, date, listener) {
|
requestPlayerHistory(maestroID, date, listener) {
|
||||||
let historyRecordManager = new HistoryRecordManager();
|
let historyRecordManager = new HistoryRecordManager();
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ class MenuTypingPractice {
|
|||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
|
|
||||||
|
|
||||||
this.makeActiveAppButtons();
|
this.makeActiveTypingPracticeAppButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
makeActiveAppButtons() {
|
makeActiveTypingPracticeAppButtons() {
|
||||||
let dbConnectManager = new DBConnectManager();
|
let dbConnectManager = new DBConnectManager();
|
||||||
dbConnectManager.requestActiveAppList(
|
dbConnectManager.requestTypingPracticeAppList(
|
||||||
sessionStorageManager.maestroID,
|
sessionStorageManager.maestroID,
|
||||||
self.loginSucceeded,
|
self.loginSucceeded,
|
||||||
self.loginFailed
|
self.loginFailed
|
||||||
@@ -43,19 +43,25 @@ class MenuTypingPractice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginSucceeded(replyJSON) {
|
loginSucceeded(replyJSON) {
|
||||||
// console.log(replyJSON);
|
console.log(replyJSON);
|
||||||
|
|
||||||
let koreanTypingPracticeAppCount = 1; // self.getAppCount(replyJSON, AppButton.TYPE_MOUSE);
|
let buttonWidthGap = MenuTypingPractice.BUTTON_WIDTH + MenuTypingPractice.BUTTON_GAP;
|
||||||
let englishTypingPracticeAppCount = 1; // self.getAppCount(replyJSON, AppButton.TYPE_TYPING);
|
|
||||||
|
|
||||||
let startX = game.world.width / 2 - (150 * koreanTypingPracticeAppCount / 2) - (150 / 2);
|
let koreanTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_KOREAN);
|
||||||
|
let englishTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_ENGLISH);
|
||||||
|
|
||||||
|
let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||||
let koreanTypingPracticeAppIndex = 0;
|
let koreanTypingPracticeAppIndex = 0;
|
||||||
for(let i = 0; i < replyJSON.length; i++) {
|
for(let i = 0; i < replyJSON.length; i++) {
|
||||||
let activeApp = replyJSON[i];
|
let activeApp = replyJSON[i];
|
||||||
if(self.isMouseApp(activeApp)) {
|
if(self.isKoreanApp(activeApp)) {
|
||||||
koreanTypingPracticeAppIndex++;
|
koreanTypingPracticeAppIndex++;
|
||||||
new TypingPracticeButton(startX + 150 * koreanTypingPracticeAppIndex, 300, TypingPracticeButton.TYPE_ENGLISH,
|
console.log(activeApp);
|
||||||
TypingPracticeButton.NONE_ICON, "양손 기본",
|
new TypingPracticeButton(
|
||||||
|
startX + buttonWidthGap * koreanTypingPracticeAppIndex, 300,
|
||||||
|
TypingPracticeButton.TYPE_KOREAN,
|
||||||
|
TypingPracticeButton.NONE_ICON,
|
||||||
|
appInfoManager.getAppNameKorean(activeApp.AppName),
|
||||||
() => {
|
() => {
|
||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
@@ -65,6 +71,28 @@ class MenuTypingPractice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||||
|
let englishTypingPracticeAppIndex = 0;
|
||||||
|
for(let i = 0; i < replyJSON.length; i++) {
|
||||||
|
let activeApp = replyJSON[i];
|
||||||
|
if(!self.isKoreanApp(activeApp)) {
|
||||||
|
englishTypingPracticeAppIndex++;
|
||||||
|
console.log(activeApp);
|
||||||
|
new TypingPracticeButton(
|
||||||
|
startX + buttonWidthGap * englishTypingPracticeAppIndex, 500,
|
||||||
|
TypingPracticeButton.TYPE_ENGLISH,
|
||||||
|
TypingPracticeButton.NONE_ICON,
|
||||||
|
appInfoManager.getAppNameKorean(activeApp.AppName),
|
||||||
|
() => {
|
||||||
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
|
location.href = '../../web/client/start.html';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(englishTypingPracticeAppCount > 0) {
|
if(englishTypingPracticeAppCount > 0) {
|
||||||
new TypingPracticeButton(game.world.width / 2, 500, TypingPracticeButton.TYPE_KOREAN,
|
new TypingPracticeButton(game.world.width / 2, 500, TypingPracticeButton.TYPE_KOREAN,
|
||||||
TypingPracticeButton.NONE_ICON, "검지 글쇠",
|
TypingPracticeButton.NONE_ICON, "검지 글쇠",
|
||||||
@@ -75,10 +103,11 @@ class MenuTypingPractice {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
isMouseApp(app) {
|
isKoreanApp(app) {
|
||||||
if(app.AppType > 100)
|
if(app.AppType === MenuTypingPractice.TYPE_KOREAN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -88,9 +117,7 @@ class MenuTypingPractice {
|
|||||||
let appCount = 0;
|
let appCount = 0;
|
||||||
for(let i = 0; i < replyJSON.length; i++) {
|
for(let i = 0; i < replyJSON.length; i++) {
|
||||||
let activeApp = replyJSON[i];
|
let activeApp = replyJSON[i];
|
||||||
if(type == AppButton.TYPE_TYPING && activeApp.AppType <= 100)
|
if(activeApp.AppType === type)
|
||||||
appCount++;
|
|
||||||
else if(type == AppButton.TYPE_MOUSE && activeApp.AppType > 100)
|
|
||||||
appCount++;
|
appCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,3 +129,10 @@ class MenuTypingPractice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MenuTypingPractice.TYPE_KOREAN = 10;
|
||||||
|
MenuTypingPractice.TYPE_ENGLISH = 20;
|
||||||
|
|
||||||
|
MenuTypingPractice.BUTTON_WIDTH = 200;
|
||||||
|
MenuTypingPractice.BUTTON_GAP = 20;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
include "./../send_error_code.php";
|
||||||
|
|
||||||
|
$maestro_id = $_POST["maestro_id"];
|
||||||
|
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
|
||||||
|
$replyJSON = get_active_typing_practice_app_list($maestro_id);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
if($replyJSON.length === 0) {
|
||||||
|
send_error_message($replyJSON, "앱 목록 가져오기 실패");
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_active_typing_practice_app_list($maestro_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT A.AppID, A.AppName, A.AppType
|
||||||
|
FROM moty_app AS A
|
||||||
|
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID=?";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('i', $maestro_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($app_id, $app_name, $app_type);
|
||||||
|
|
||||||
|
$return_array = array();
|
||||||
|
while($stmt->fetch()) {
|
||||||
|
$row_array['AppID'] = $app_id;
|
||||||
|
$row_array['AppName'] = $app_name;
|
||||||
|
$row_array['AppType'] = $app_type;
|
||||||
|
array_push($return_array, $row_array);
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $return_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user