diff --git a/src/game/ranking/ranking.js b/src/game/ranking/ranking.js
index 3e58795..2825fd3 100644
--- a/src/game/ranking/ranking.js
+++ b/src/game/ranking/ranking.js
@@ -8,12 +8,17 @@ var Ranking = {
this.dbConnectManager = new DBConnectManager();
this.jsonData = null;
- this.mode = Ranking.MODE_HOUR;
+ this.timeType = Ranking.MODE_HOUR;
this.refreshTimeSec = Ranking.REFRESH_TIME_SEC;
this.showingPageIndex = 0;
+ this.dateTime = null;
+ this.date = "";
+ this.time = "";
this.recordArray = null;
+ this.getDateTimeNow();
+
// bg
this.game.stage.backgroundColor = '#4d4d4d';
@@ -53,7 +58,7 @@ var Ranking = {
// date time
this.textDateTime = game.add.text(
GAME_SCREEN_SIZE.x / 2, 104,
- "2019년 06월 05일, 14시",
+ this.getYYYYMMDDHHText(),
resultTextStyle
);
this.textDateTime.fontSize = 34;
@@ -245,39 +250,60 @@ var Ranking = {
return new RoundRectButton(setting, RoundRectButton.NONE_ICON, buttonText, eventListener);
},
+ getDateTimeType: function() {
+ var dateTimeType = -1;
+ switch(this.timeType) {
+ case Ranking.MODE_HOUR:
+ dateTimeType = DBConnectManager.TYPE_MY_RANKING_HOUR;
+ break;
+
+ case Ranking.MODE_DAY:
+ dateTimeType = DBConnectManager.TYPE_MY_RANKING_DAY;
+ break;
+
+ case Ranking.MODE_MONTH:
+ dateTimeType = DBConnectManager.TYPE_MY_RANKING_MONTH;
+ break;
+ }
+
+ return dateTimeType;
+ },
+
getRecordToRankingServer: function() {
- // console.log("getRecordToRankingServer : " + this.mode);
- this.dbConnectManager.requestAppRanking(
+ this.dbConnectManager.requestRanking(
+ this.getDateTimeType(),
sessionStorageManager.getMaestroID(),
- sessionStorageManager.getPlayingAppID(),
- (function(jsonData) { this.showRanking(jsonData); }).bind(this),
- (function(jsonData) { this.showRanking(null); }).bind(this)
+ this.date,
+ this.time,
+ (type, rankingRecordManager) => {
+ this.showRanking(rankingRecordManager);
+ }
);
},
showRankingHour: function() {
- this.mode = Ranking.MODE_HOUR;
+ this.timeType = Ranking.MODE_HOUR;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 수업시간 순위";
this.textTitle.addColor("#ff6666", 0);
this.getRecordToRankingServer();
},
showRankingDay: function() {
- this.mode = Ranking.MODE_DAY;
+ this.timeType = Ranking.MODE_DAY;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 오늘의 순위";
this.textTitle.addColor("#9999ff", 0);
this.getRecordToRankingServer();
},
showRankingMonth: function() {
- this.mode = Ranking.MODE_MONTH;
+ this.timeType = Ranking.MODE_MONTH;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 이달의 순위";
this.textTitle.addColor("#99ff99", 0);
this.getRecordToRankingServer();
},
- showRanking: function(jsonRankingData) {
- // console.log(jsonRankingData);
+ showRanking: function(rankingRecordManager) {
+ // console.log(rankingRecordManager);
if(sessionStorageManager.getMaestroAccountType() == 101) {
this.recordArray = this.getDummyRankList();
@@ -286,7 +312,7 @@ var Ranking = {
return;
}
- if(jsonRankingData === null) {
+ if(rankingRecordManager.rankingRecords.length === 0) {
var rankEmpty = [ ];
this.textRanking1to10.parseList(rankEmpty);
this.textRanking11to20.parseList(rankEmpty);
@@ -294,23 +320,22 @@ var Ranking = {
return;
}
- var jsonRankingList = null;
- if(this.mode === Ranking.MODE_HOUR)
- jsonRankingList = jsonRankingData.rankingHour;
- else if(this.mode === Ranking.MODE_DAY)
- jsonRankingList = jsonRankingData.rankingDay;
- else if(this.mode === Ranking.MODE_MONTH)
- jsonRankingList = jsonRankingData.rankingMonth;
+ var rankingListCount = rankingRecordManager.rankingRecords.length;
+ this.recordArray = [];
+ for(var i = 0; i < rankingListCount; i++) {
+ var bestRecordRow = [];
+ // bestRecordRow[0] = jsonRankingList[i]['UserID'];
+ bestRecordRow[0] = i + 1;
+ bestRecordRow[1] = rankingRecordManager.rankingRecords[i]['playerName'];
+ bestRecordRow[2] = RecordUtil.getRecordValueWithUnit(
+ rankingRecordManager.rankingRecords[i]['bestRecord'],
+ sessionStorageManager.getPlayingAppID()
+ );
+ // console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
- if(jsonRankingList === null) {
- var rankEmpty = [ ];
- this.textRanking1to10.parseList(rankEmpty);
- this.textRanking11to20.parseList(rankEmpty);
-
- return;
+ this.recordArray.push(bestRecordRow);
}
- this.recordArray = this.getRankingArrayFromJSON(jsonRankingList);
this.printRanking();
},
@@ -323,6 +348,7 @@ var Ranking = {
if(this.showingPageIndex * 20 > this.recordArray.length)
this.showingPageIndex = 0;
+ // prepare ranking list - top10 / top20
for(var i = 0; i < 10; i++) {
var index = this.showingPageIndex * 20 + i;
if(index < this.recordArray.length)
@@ -330,9 +356,22 @@ var Ranking = {
if(index + 10 < this.recordArray.length)
recordTop20.push(this.recordArray[index + 10]);
}
+
+ // print
this.textRanking1to10.parseList(recordTop10);
this.textRanking11to20.parseList(recordTop20);
+ this.updateRankingNavigationButtons();
+ },
+
+ updateRankingNavigationButtons: function() {
+ // console.log(this.recordArray);
+
+ if(this.recordArray == null) {
+ this.buttonPrevRanking.text.text = "X";
+ this.buttonNextRanking.text.text = "X";
+ return;
+ }
if(this.showingPageIndex > 0)
this.buttonPrevRanking.text.text = "<";
else
@@ -344,69 +383,83 @@ var Ranking = {
this.buttonNextRanking.text.text = "X";
},
- getRankingArrayFromJSON: function(jsonRankingList) {
- if(isDebugMode())
- return this.getDummyRankList();
-
- var rankingListCount = jsonRankingList.length;
-
- var recordArray = [];
- for(var i = 0; i < rankingListCount; i++) {
- var bestRecordRow = [];
- // bestRecordRow[0] = jsonRankingList[i]['UserID'];
- bestRecordRow[0] = i + 1;
- bestRecordRow[1] = jsonRankingList[i]['Name'];
- bestRecordRow[2] = RecordUtil.getRecordValueWithUnit(
- jsonRankingList[i]['BestRecord'],
- sessionStorageManager.getPlayingAppID()
- );
- // console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
-
- recordArray.push(bestRecordRow);
- }
-
- return recordArray;
- },
-
getDummyRankList: function() {
var dummyRankList = [
- [ '1', 'test1', '400' ],
- [ '2', 'test2', '300' ],
- [ '3', 'test3', '200' ],
- [ '4', 'test4', '100' ],
- [ '5', 'test5', '90' ],
- [ '6', 'test6', '80' ],
- [ '7', 'test7', '70' ],
- [ '8', 'test8', '60' ],
- [ '9', 'test9', '50' ],
- [ '10', 'test10', '40' ],
- [ '11', 'test11', '30' ],
- [ '12', 'test12', '20' ],
- [ '13', 'test13', '10' ],
- [ '14', 'test14', '9' ],
- [ '15', 'test15', '8' ],
- [ '16', 'test16', '7' ],
- [ '17', 'test17', '6' ],
- [ '18', 'test18', '5' ],
- [ '19', 'test19', '4' ],
- [ '20', 'test20', '3' ],
- [ '21', 'test21', '2' ],
- [ '22', 'test22', '1' ],
- [ '23', 'test23', '1' ],
- [ '24', 'test24', '1' ],
- [ '25', 'test25', '1' ],
- [ '26', 'test26', '1' ],
- [ '27', 'test27', '1' ],
- [ '28', 'test28', '1' ],
- [ '29', 'test29', '1' ],
- [ '30', 'test30', '1' ],
- [ '31', 'test31', '1' ],
+ [ '1', 'test1', '600' ],
+ [ '2', 'test2', '500' ],
+ [ '3', 'test3', '450' ],
+ [ '4', 'test4', '400' ],
+ [ '5', 'test5', '350' ],
+ [ '6', 'test6', '300' ],
+ [ '7', 'test7', '250' ],
+ [ '8', 'test8', '200' ],
+ [ '9', 'test9', '150' ],
+ [ '10', 'test10', '100' ],
+ [ '11', 'test11', '90' ],
+ [ '12', 'test12', '80' ],
+ [ '13', 'test13', '70' ],
+ [ '14', 'test14', '60' ],
+ [ '15', 'test15', '50' ],
+ [ '16', 'test16', '45' ],
+ [ '17', 'test17', '40' ],
+ [ '18', 'test18', '35' ],
+ [ '19', 'test19', '30' ],
+ [ '20', 'test20', '25' ],
+ [ '21', 'test21', '20' ],
+ [ '22', 'test22', '15' ],
+ [ '23', 'test23', '10' ],
+ [ '24', 'test24', '9' ],
+ [ '25', 'test25', '8' ],
+ [ '26', 'test26', '7' ],
+ [ '27', 'test27', '6' ],
+ [ '28', 'test28', '5' ],
+ [ '29', 'test29', '4' ],
+ [ '30', 'test30', '3' ],
+ [ '31', 'test31', '2' ],
[ '32', 'test32', '1' ],
];
return dummyRankList;
},
+ getDateTimeNow: function() {
+ var now = new Date();
+ var hourTimeText = DateUtil.getYYYYMMDD(now) + "T" + now.getHours() + ":00:00";
+ this.dateTime = new Date(hourTimeText);
+ this.date = DateUtil.getYYYYMMDD(this.dateTime);
+ this.time = DateUtil.getHHMMSS(this.dateTime);
+
+ if(runMode == MODE_DEBUG) {
+ this.date = "2018-08-23";
+ this.time = "15:53:00";
+ this.dateTime = new Date(this.date + "T" + this.time);
+ }
+ },
+
+ increaseDateTime: function() {
+ },
+
+ decreaseDateTime: function() {
+ },
+
+ getDatetimeHour: function() {
+ return this.dateTime.getHours();
+ },
+
+ getDatetimeHourWith2Digits: function() {
+ return ("0" + this.dateTime.getHours()).slice(-2);
+ },
+
+ getYYYYMMDDHHText: function() {
+ return DateUtil.getFullYear(this.dateTime) + "년 "
+ + DateUtil.getFullMonth(this.dateTime) + "월 "
+ + DateUtil.getFullDate(this.dateTime) + "일, "
+ + DateUtil.getFullHours(this.dateTime) + "시"
+ },
+
onClickPrevRanking: function() {
+ if(this.recordArray == null)
+ return;
+
this.showingPageIndex--;
if(this.showingPageIndex < 0)
this.showingPageIndex = 0;
@@ -415,6 +468,9 @@ var Ranking = {
},
onClickNextRanking: function() {
+ if(this.recordArray == null)
+ return;
+
if((this.showingPageIndex + 1) * 20 < this.recordArray.length)
this.showingPageIndex++;
this.printRanking();
diff --git a/src/web/client/ranking.html b/src/web/client/ranking.html
index 057ce0b..c05559f 100644
--- a/src/web/client/ranking.html
+++ b/src/web/client/ranking.html
@@ -40,6 +40,7 @@
+
@@ -50,12 +51,13 @@
-
+
+
-
+