function HistoryBoard(dataType) { if(dataType === RecordBoard.TYPE_SAMPLE) { this.printSample(); return; } this.todayBestRecord = 0; this.dbConnectManager = new DBConnectManager(); var arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] }; var posX = 40; var posY = game.world.height / 2 - 10; this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); setTimeout( (function() { var today = new Date(); var date = DateUtil.getYYYYMMDD(today); this.dbConnectManager.requestPlayerHistory( sessionStorageManager.getMaestroID(), date, (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(date == data.date) this.todayBestRecord = data.bestRecord; } }).bind(this) ); }).bind(this), RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS ); } HistoryBoard.prototype.calcDate = function(daysBefore) { var date = new Date(); date.setDate(date.getDate() - daysBefore); return date; } HistoryBoard.prototype.printRecord = function(index, date, bestRecord) { var posX = 130; var posY = game.world.height / 2 + 90 + 30 * index; var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" }; var dateText = game.add.text(posX, posY, StringUtil.printMonthDay(date), style); dateText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); dateText.anchor.set(1, 0); var recordText = game.add.text( posX + 120, posY, RecordUtil.getRecordValueWithUnit(bestRecord, sessionStorageManager.getPlayingAppID()), style ); recordText.anchor.set(1, 0); recordText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); } HistoryBoard.prototype.printSample = function() { this.printRecord(0, DateUtil.getYYYYMMDD(this.calcDate(2)), 1270); this.printRecord(1, DateUtil.getYYYYMMDD(this.calcDate(3)), 1150); this.printRecord(2, DateUtil.getYYYYMMDD(this.calcDate(5)), 1080); this.printRecord(3, DateUtil.getYYYYMMDD(this.calcDate(7)), 960); this.printRecord(4, DateUtil.getYYYYMMDD(this.calcDate(10)), 1020); this.printRecord(5, DateUtil.getYYYYMMDD(this.calcDate(15)), 840); this.printRecord(6, DateUtil.getYYYYMMDD(this.calcDate(20)), 760); } HistoryBoard.prototype.todayBestRecord = function() { return this.todayBestRecord; }