From f79040fed41df7fd9fbc9be7dcb0153c9e7838ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 18 Jul 2019 16:23:07 +0900 Subject: [PATCH] Add: typing exam start --- src/game/lib/button/typing_exam_button.js | 6 +- src/game/lib/db_connect_manager.js | 20 +++--- src/game/start/start.js | 81 +++++++++++++++-------- src/web/client/start.html | 1 + 4 files changed, 71 insertions(+), 37 deletions(-) diff --git a/src/game/lib/button/typing_exam_button.js b/src/game/lib/button/typing_exam_button.js index 23a635e..924d86b 100644 --- a/src/game/lib/button/typing_exam_button.js +++ b/src/game/lib/button/typing_exam_button.js @@ -36,8 +36,12 @@ function TypingExamButton(x, y, iconName, buttonText, writingID) { TypingExamButton.prototype.onClick = function() { + sessionStorageManager.setPlayingAppID(200); + sessionStorageManager.setPlayingAppName("typing_exam"); + sessionStorageManager.setPlayingAppKoreanName("타자검정"); sessionStorageManager.setWritingID(this.writingID); - location.href = '../../web/client/typing_exam.html'; + // location.href = '../../web/client/typing_exam.html'; + location.href = '../../web/client/start.html'; // printSessionStorage(); } diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js index 8ffdd81..2401f60 100644 --- a/src/game/lib/db_connect_manager.js +++ b/src/game/lib/db_connect_manager.js @@ -200,15 +200,15 @@ DBConnectManager.prototype.requestTypingTestAppList = function(maestroID, player xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID); } -DBConnectManager.prototype.requestPlayerHistory = function(date, listener) { +DBConnectManager.prototype.requestPlayerHistory = function(date, onSucceededListener, onFailedListener) { var historyRecordManager = new HistoryRecordManager(); /* if(isDebugMode()) { this.loadTempPlayerHistory(historyRecordManager); - if(listener !== null) - listener(historyRecordManager); + if(onSucceededListener !== null) + onSucceededListener(historyRecordManager); return; } @@ -224,9 +224,9 @@ DBConnectManager.prototype.requestPlayerHistory = function(date, listener) { var replyJSON = JSON.parse(xhr.responseText); if(replyJSON != null) - listener(self.parseJSONtoHistoryRecord(replyJSON)); - // else - // onFailedListener(replyJSON); + onSucceededListener(self.parseJSONtoHistoryRecord(replyJSON)); + else + onFailedListener(replyJSON); } }; var params = "MaestroID=" + sessionStorageManager.getMaestroID() @@ -258,15 +258,15 @@ DBConnectManager.prototype.parseJSONtoHistoryRecord = function(json) { return historyRecordManager; } -DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) { +DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, onSucceededListener, onFailedListener) { var rankingRecordManager = new RankingRecordManager(); /* if(isDebugMode()) { this.loadTempRanking(rankingRecordManager); - if(listener !== null) - listener(rankingRecordManager); + if(onSucceededListener !== null) + onSucceededListener(rankingRecordManager); return; } @@ -282,7 +282,7 @@ DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time var replyJSON = JSON.parse(xhr.responseText); if(replyJSON != null) { - listener(type, self.parseJSONtoRankingRecord(type, replyJSON)); + onSucceededListener(type, self.parseJSONtoRankingRecord(type, replyJSON)); } else onFailedListener(replyJSON); diff --git a/src/game/start/start.js b/src/game/start/start.js index e7bc553..eb73266 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -7,6 +7,10 @@ var Start = { create: function() { this.dbConnectManager = new DBConnectManager(); + this.dbService = new DBService(); + this.dbService.setMaestroID(sessionStorageManager.getMaestroID()); + this.dbService.setPlayerID(sessionStorageManager.getPlayerID()); + this.game.stage.backgroundColor = '#4d4d4d'; this.howToPlay = new HowToPlay(); this.chart = new Chart(); @@ -98,37 +102,62 @@ var Start = { loadChart: function() { var today = new Date(); var date = DateUtil.getYYYYMMDD(today); - this.dbConnectManager.requestPlayerHistory( - date, - (function(historyRecordManager) { - if(historyRecordManager.count == 0) { - console.log("start - history record : no data"); - return; - } - var underValue = historyRecordManager.underValueForGraph(); - var upperValue = historyRecordManager.upperValueForGraph(); + if(isTypingExamApp()) { + this.dbService.requestTypingExamPlayerHistory( + sessionStorageManager.getWritingID(), + date, - var minValue = underValue - (upperValue - underValue) / 10; - var maxValue = upperValue;// + (upperValue - underValue) / 10; + (function(historyRecordManager) { + this.onReceiveHistoryRecordManager(historyRecordManager); + }).bind(this), - var countRecord = historyRecordManager.count; - for(var i = 0; i < Chart.CHART_COUNT; i++) { - // if(i > 6) - // break; + (function(jsonData) { + console.log(jsonData); + }).bind(this) + ); + } else { + this.dbConnectManager.requestPlayerHistory( + date, - var historyRecord = historyRecordManager.getAt(i); - this.chart.drawRecordGraph( - i, - historyRecord === undefined ? "-" : historyRecord.date, - historyRecord === undefined ? "" : historyRecord.bestRecord, - minValue, maxValue - ); - } + (function(historyRecordManager) { + this.onReceiveHistoryRecordManager(historyRecordManager); + }).bind(this), - this.chart.printChartBaseLine(); - }).bind(this) - ); + (function(jsonData) { + console.log(jsonData); + }).bind(this) + ); + } + }, + + onReceiveHistoryRecordManager: function(historyRecordManager) { + if(historyRecordManager.count == 0) { + console.log("start - history record : no data"); + return; + } + + var underValue = historyRecordManager.underValueForGraph(); + var upperValue = historyRecordManager.upperValueForGraph(); + + var minValue = underValue - (upperValue - underValue) / 10; + var maxValue = upperValue;// + (upperValue - underValue) / 10; + + var countRecord = historyRecordManager.count; + for(var i = 0; i < Chart.CHART_COUNT; i++) { + // if(i > 6) + // break; + + var historyRecord = historyRecordManager.getAt(i); + this.chart.drawRecordGraph( + i, + historyRecord === undefined ? "-" : historyRecord.date, + historyRecord === undefined ? "" : historyRecord.bestRecord, + minValue, maxValue + ); + } + + this.chart.printChartBaseLine(); }, calcDate: function(daysBefore) { diff --git a/src/web/client/start.html b/src/web/client/start.html index f4c61dc..6cd15f5 100644 --- a/src/web/client/start.html +++ b/src/web/client/start.html @@ -33,6 +33,7 @@ +