function HistoryBoard(dataType) { var rankingTextOffsetY = game.world.height / 2 + 105; this.historyTexts = new Array(); for(var i = 0; i < RankingBoard.RANK_COUNT; i++) { var posY = rankingTextOffsetY + (i % 10) * 30; this.historyTexts[i] = new HistoryText(80, posY); } if(dataType === RecordBoard.TYPE_SAMPLE) { this.printSample(); return; } this.date = null; this.todayBestRecord = 0; this.dbConnectManager = new DBConnectManager(); this.dbService = new DBService(); this.dbService.setMaestroID(sessionStorageManager.getMaestroID()); this.dbService.setPlayerID(sessionStorageManager.getPlayerID()); setTimeout( (function() { var today = new Date(); this.date = DateUtil.getYYYYMMDD(today); if(isTypingExamApp()) { this.dbService.requestTypingExamPlayerHistory( sessionStorageManager.getWritingID(), this.date, (function(historyRecordManager) { this.parseHistoryRecordManagerData(historyRecordManager); }).bind(this), (function() { console.log("player history board - no data"); }) ); } else { this.dbConnectManager.requestPlayerHistory( this.date, (function(historyRecordManager) { this.parseHistoryRecordManagerData(historyRecordManager); }).bind(this), (function() { console.log("player history board - no data"); }) ); } }).bind(this), RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS ); } HistoryBoard.prototype.parseHistoryRecordManagerData = function(historyRecordManager) { if(historyRecordManager.getCount() == 0) { console.log("history board - no data"); return; } for(var i = 0; i < historyRecordManager.getCount(); i++) { var data = historyRecordManager.getAt(i); this.printRecord(i, data.date, data.bestRecord); if(this.date == data.date) this.todayBestRecord = data.bestRecord; } } HistoryBoard.prototype.daySubtract = function(daysBefore) { var date = new Date(); date.setDate(date.getDate() - daysBefore); return date; } HistoryBoard.prototype.printRecord = function(index, date, bestRecord) { this.historyTexts[index].setContents(date, bestRecord); } HistoryBoard.prototype.printSample = function() { this.printRecord(0, DateUtil.getYYYYMMDD(this.daySubtract(2)), 1270); this.printRecord(1, DateUtil.getYYYYMMDD(this.daySubtract(3)), 1150); this.printRecord(2, DateUtil.getYYYYMMDD(this.daySubtract(5)), 1080); this.printRecord(3, DateUtil.getYYYYMMDD(this.daySubtract(7)), 960); this.printRecord(4, DateUtil.getYYYYMMDD(this.daySubtract(10)), 1020); this.printRecord(5, DateUtil.getYYYYMMDD(this.daySubtract(15)), 840); this.printRecord(6, DateUtil.getYYYYMMDD(this.daySubtract(20)), 760); } HistoryBoard.prototype.todayBestRecord = function() { return this.todayBestRecord; }