1f5f87c361
Fix: ranking.js, result.js
70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
function HistoryBoard(dataType) {
|
|
if(dataType === RecordBoard.TYPE_SAMPLE) {
|
|
this.printSample();
|
|
return;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
this.todayBestRecord = 0;
|
|
|
|
this.dbConnectManager = new DBConnectManager();
|
|
|
|
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) {
|
|
this.historyTexts[index].setContents(date, bestRecord);
|
|
}
|
|
|
|
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;
|
|
} |