From d788d3e7d03f86de03166c998f91f9eae4a033db 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 18:35:28 +0900 Subject: [PATCH] Add: start screen - chart, highest record --- src/game/start/start.js | 63 ++++++++++++++++++++--------- src/game/typing/examination/game.js | 10 ++--- 2 files changed, 47 insertions(+), 26 deletions(-) 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);