Fix: restructing session manager, ES6 -> ES5
This commit is contained in:
+53
-56
@@ -1,13 +1,10 @@
|
||||
/////////////////////////////
|
||||
// Ranking
|
||||
var Ranking = {
|
||||
|
||||
class Ranking {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
self = this;
|
||||
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
@@ -17,20 +14,20 @@ class Ranking {
|
||||
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// let phaser = game.add.image(game.world.centerX, game.world.centerY, 'phaser');
|
||||
// var phaser = game.add.image(game.world.centerX, game.world.centerY, 'phaser');
|
||||
// phaser.anchor.set(0.5);
|
||||
// phaser.alpha = 0.1;
|
||||
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
location.href = '../../web/client/start.html';
|
||||
});
|
||||
screenTopUI.makeFullScreenButton();
|
||||
|
||||
|
||||
let resultTextStyle = textStyleBasic;
|
||||
var resultTextStyle = textStyleBasic;
|
||||
resultTextStyle.font = "bold 42px Arial";
|
||||
|
||||
this.textTitle = game.add.text(GAME_SCREEN_SIZE.x / 2, 32, "수업시간 순위", resultTextStyle)
|
||||
@@ -42,38 +39,38 @@ class Ranking {
|
||||
// contents
|
||||
|
||||
// rank
|
||||
let rankAreaPositionX = 160;
|
||||
let rankAreaPositionY = 90;
|
||||
let style = { font: "34px Arial", fill: "#fff", tabs: [ 60, 160, 160 ] };
|
||||
var rankAreaPositionX = 160;
|
||||
var rankAreaPositionY = 90;
|
||||
var style = { font: "34px Arial", fill: "#fff", tabs: [ 60, 160, 160 ] };
|
||||
this.textRanking1to10 = game.add.text(rankAreaPositionX, rankAreaPositionY , '', style)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.textRanking11to20 = game.add.text(rankAreaPositionX + 420, rankAreaPositionY, '', style)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
|
||||
let buttonPositionY = 640;
|
||||
let buttonHour = this.makeTextButton(game.world.centerX - 220, buttonPositionY, "수업시간 순위", this.showRankingHour);
|
||||
var buttonPositionY = 640;
|
||||
var buttonHour = this.makeTextButton(game.world.centerX - 220, buttonPositionY, "수업시간 순위", this.showRankingHour);
|
||||
// buttonHour.inputEnabled = false;
|
||||
let buttonDay = this.makeTextButton(game.world.centerX, buttonPositionY, "오늘의 순위", this.showRankingDay);
|
||||
var buttonDay = this.makeTextButton(game.world.centerX, buttonPositionY, "오늘의 순위", this.showRankingDay);
|
||||
// buttonDay.inputEnabled = false;
|
||||
let buttonMonth = this.makeTextButton(game.world.centerX + 220, buttonPositionY, "이달의 순위", this.showRankingMonth);
|
||||
var buttonMonth = this.makeTextButton(game.world.centerX + 220, buttonPositionY, "이달의 순위", this.showRankingMonth);
|
||||
// buttonMonth.inputEnabled = false;
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// ScreenBottomUI.printLeftText("게임 진행 정보");
|
||||
// let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
|
||||
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.getPlayingAppName());
|
||||
// ScreenBottomUI.printCenterText(playingAppName);
|
||||
screenBottomUI.printCenterText("랭킹");
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
this.getRecordToRankingServer();
|
||||
game.time.events.loop(Phaser.Timer.SECOND * 10, this.getRecordToRankingServer, this);
|
||||
}
|
||||
},
|
||||
|
||||
makeTextButton(x, y, buttonText, eventListener) {
|
||||
let setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
makeTextButton: function(x, y, buttonText, eventListener) {
|
||||
var setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
switch(buttonText) {
|
||||
case "수업시간 순위":
|
||||
@@ -142,15 +139,15 @@ class Ranking {
|
||||
}
|
||||
|
||||
return new RoundRectButton(setting, RoundRectButton.NONE_ICON, buttonText, eventListener);
|
||||
}
|
||||
},
|
||||
|
||||
getRecordToRankingServer() {
|
||||
getRecordToRankingServer: function() {
|
||||
// console.log("getRecordToRankingServer : " + this.mode);
|
||||
let self = this;
|
||||
var self = this;
|
||||
|
||||
this.dbConnectManager.requestAppRanking(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playingAppID,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayingAppID(),
|
||||
(function(jsonData) {
|
||||
self.showRanking(jsonData);
|
||||
}),
|
||||
@@ -158,48 +155,48 @@ class Ranking {
|
||||
self.showRanking(null);
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
showRankingHour() {
|
||||
showRankingHour: function() {
|
||||
self.mode = Ranking.MODE_HOUR;
|
||||
self.textTitle.text = "수업시간 순위";
|
||||
self.textTitle.addColor("#ff6666", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRankingDay() {
|
||||
showRankingDay: function() {
|
||||
self.mode = Ranking.MODE_DAY;
|
||||
self.textTitle.text = "오늘의 순위";
|
||||
self.textTitle.addColor("#9999ff", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRankingMonth() {
|
||||
showRankingMonth: function() {
|
||||
self.mode = Ranking.MODE_MONTH;
|
||||
self.textTitle.text = "이달의 순위";
|
||||
self.textTitle.addColor("#99ff99", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRanking(jsonRankingData) {
|
||||
showRanking: function(jsonRankingData) {
|
||||
// console.log(jsonRankingData);
|
||||
|
||||
if(sessionStorageManager.maestroAccountType == 101) {
|
||||
let recordArray = this.getDummyRankList();
|
||||
if(sessionStorageManager.getMaestroAccountType() == 101) {
|
||||
var recordArray = this.getDummyRankList();
|
||||
this.printRanking(recordArray);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(jsonRankingData === null) {
|
||||
let rankEmpty = [ ];
|
||||
var rankEmpty = [ ];
|
||||
this.textRanking1to10.parseList(rankEmpty);
|
||||
this.textRanking11to20.parseList(rankEmpty);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let jsonRankingList = null;
|
||||
var jsonRankingList = null;
|
||||
if(this.mode === Ranking.MODE_HOUR)
|
||||
jsonRankingList = jsonRankingData.rankingHour;
|
||||
else if(this.mode === Ranking.MODE_DAY)
|
||||
@@ -208,22 +205,22 @@ class Ranking {
|
||||
jsonRankingList = jsonRankingData.rankingMonth;
|
||||
|
||||
if(jsonRankingList === null) {
|
||||
let rankEmpty = [ ];
|
||||
var rankEmpty = [ ];
|
||||
this.textRanking1to10.parseList(rankEmpty);
|
||||
this.textRanking11to20.parseList(rankEmpty);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let recordArray = this.getRankingArrayFromJSON(jsonRankingList);
|
||||
var recordArray = this.getRankingArrayFromJSON(jsonRankingList);
|
||||
this.printRanking(recordArray);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
printRanking(recordArray) {
|
||||
let recordTop10 = [];
|
||||
let recordTop20 = [];
|
||||
for(let i = 0; i < 10; i++) {
|
||||
printRanking: function(recordArray) {
|
||||
var recordTop10 = [];
|
||||
var recordTop20 = [];
|
||||
for(var i = 0; i < 10; i++) {
|
||||
if(i < recordArray.length)
|
||||
recordTop10.push(recordArray[i]);
|
||||
if(i + 10 < recordArray.length)
|
||||
@@ -231,17 +228,17 @@ class Ranking {
|
||||
}
|
||||
this.textRanking1to10.parseList(recordTop10);
|
||||
this.textRanking11to20.parseList(recordTop20);
|
||||
}
|
||||
},
|
||||
|
||||
getRankingArrayFromJSON(jsonRankingList) {
|
||||
getRankingArrayFromJSON: function(jsonRankingList) {
|
||||
// if(isDebugMode())
|
||||
// return this.getDummyRankList();
|
||||
|
||||
let rankingListCount = jsonRankingList.length;
|
||||
var rankingListCount = jsonRankingList.length;
|
||||
|
||||
let recordArray = [];
|
||||
for(let i = 0; i < rankingListCount; i++) {
|
||||
let bestRecordRow = [];
|
||||
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'];
|
||||
@@ -252,10 +249,10 @@ class Ranking {
|
||||
}
|
||||
|
||||
return recordArray;
|
||||
}
|
||||
},
|
||||
|
||||
getDummyRankList() {
|
||||
let dummyRankList = [
|
||||
getDummyRankList: function() {
|
||||
var dummyRankList = [
|
||||
[ '1', 'test1', '400' ],
|
||||
[ '2', 'test2', '300' ],
|
||||
[ '3', 'test3', '200' ],
|
||||
|
||||
Reference in New Issue
Block a user