diff --git a/src/game/start/start.js b/src/game/start/start.js index eb73266..d14afad 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -53,29 +53,54 @@ var Start = { // bottom ui - var screenBottomUI = new ScreenBottomUI(); - screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); - screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); - screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); + this.screenBottomUI = new ScreenBottomUI(); + this.screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); + this.screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); + this.screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); - this.dbConnectManager.requestAppHighestRecord( - sessionStorageManager.getMaestroID(), - sessionStorageManager.getPlayerID(), - sessionStorageManager.getPlayingAppID(), - (function(replyJSON) { - var appHighestRecord = replyJSON["AppHighestRecord"]; - sessionStorageManager.setAppHighestRecord(Number(appHighestRecord)); - screenBottomUI.printLeftTextWithAppHighestRecord(appHighestRecord); - }).bind(this), - (function(replyJSON) { // no data - sessionStorageManager.setAppHighestRecord(0); - screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); - }).bind(this) - ); + if(isTypingExamApp()) { + this.dbService.getTypingExamHighestRecord( + sessionStorageManager.getWritingID(), + + (function(replyJSON) { + console.log(replyJSON); + var highestRecordData = replyJSON["highestRecordData"]; + var highestRecord = highestRecordData["highestRecord"]; + this.onReceiveAppHighestRecord(highestRecord); + }).bind(this), + + (function(replyJSON) { // no data + this.onReceiveAppHighestRecord(0); + }).bind(this) + ); + } else { + this.dbConnectManager.requestAppHighestRecord( + sessionStorageManager.getMaestroID(), + sessionStorageManager.getPlayerID(), + sessionStorageManager.getPlayingAppID(), + + (function(replyJSON) { + var highestRecord = replyJSON["AppHighestRecord"]; + this.onReceiveAppHighestRecord(highestRecord); + }).bind(this), + + (function(replyJSON) { // no data + this.onReceiveAppHighestRecord(0); + }).bind(this) + ); + } }, + onReceiveAppHighestRecord: function(highestRecord) { + sessionStorageManager.setAppHighestRecord(Number(highestRecord)); + this.screenBottomUI.printLeftTextWithAppHighestRecord(highestRecord); + }, + + back: function() { - if(isTypingPracticeApp()) + if(isTypingExamApp()) + location.href = '../../web/client/menu_typing_exam.html'; + else if(isTypingPracticeApp()) location.href = '../../web/client/menu_typing_practice.html'; else if(isTypingTestApp()) location.href = '../../web/client/menu_typing_test.html'; diff --git a/src/game/typing/examination/game.js b/src/game/typing/examination/game.js index fe24c93..5ab1452 100644 --- a/src/game/typing/examination/game.js +++ b/src/game/typing/examination/game.js @@ -1,7 +1,6 @@ var TypingExamination = { create: function() { - // for developing // sessionStorageManager.setMaestroName("삼화초"); // sessionStorageManager.setMaestroID(3); @@ -14,9 +13,6 @@ var TypingExamination = { // sessionStorageManager.setPlayingAppKoreanName("타자 검정"); // sessionStorageManager.setRecord(0); // sessionStorageManager.setAppHighestRecord(100.123); - sessionStorageManager.setPlayingAppName("typing_exam"); - sessionStorageManager.setPlayingAppKoreanName("타자 검정"); - this.dbService = new DBService(); this.dbService.setMaestroID(sessionStorageManager.getMaestroID()); @@ -220,11 +216,11 @@ var TypingExamination = { this.inputTextContent.canvasInput.placeHolder(""); // inputTextContent.canvasInput._onkeydown = this.checkInputText; // inputTextContent.canvasInput._onkeyup = function() { - this.inputTextContent.canvasInput._onkeyup = function() { - self.checkTypingContents(event); + this.inputTextContent.canvasInput._onkeyup = (function() { + this.checkTypingContents(event); // warning // : checkTypingContents is called onkeyup and onkeydown - } + }).bind(this);