Fix: restructing sessionManager (incompleted)
This commit is contained in:
@@ -3,7 +3,7 @@ const LANGUAGE_ENGLISH = "english";
|
|||||||
|
|
||||||
const MODE_RELEASE = "release";
|
const MODE_RELEASE = "release";
|
||||||
const MODE_DEBUG = "debug";
|
const MODE_DEBUG = "debug";
|
||||||
const runMode = MODE_DEBUG;
|
const runMode = MODE_RELEASE;
|
||||||
|
|
||||||
function isDebugMode() {
|
function isDebugMode() {
|
||||||
// console.log("debug mode ? " + runMode);
|
// console.log("debug mode ? " + runMode);
|
||||||
@@ -23,19 +23,19 @@ const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
|||||||
let sessionStorageManager = new SessionStorageManager();
|
let sessionStorageManager = new SessionStorageManager();
|
||||||
{
|
{
|
||||||
if(isDebugMode()) {
|
if(isDebugMode()) {
|
||||||
console.log("maestroID : " + sessionStorageManager.maestroID);
|
console.log("maestroID : " + sessionStorageManager.getMaestroID());
|
||||||
console.log("maestroAccountType : " + sessionStorageManager.maestroAccountType);
|
console.log("maestroAccountType : " + sessionStorageManager.getMaestroAccountType());
|
||||||
console.log("playerName : " + sessionStorageManager.playerName);
|
console.log("playerName : " + sessionStorageManager.getPlayerName());
|
||||||
console.log("playerID : " + sessionStorageManager.playerID);
|
console.log("playerID : " + sessionStorageManager.getPlayerID());
|
||||||
console.log("playerAccountType : " + sessionStorageManager.playerAccountType);
|
console.log("playerAccountType : " + sessionStorageManager.getPlayerAccountType());
|
||||||
console.log("playingAppID : " + sessionStorageManager.playingAppID);
|
console.log("playingAppID : " + sessionStorageManager.getPlayingAppID());
|
||||||
console.log("playingAppName : " + sessionStorageManager.playingAppName);
|
console.log("playingAppName : " + sessionStorageManager.getPlayingAppName());
|
||||||
console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName);
|
console.log("playingAppKoreanName : " + sessionStorageManager.getPlayingAppKoreanName());
|
||||||
console.log("record : " + sessionStorageManager.record);
|
console.log("record : " + sessionStorageManager.getRecord());
|
||||||
console.log("bestRecord : " + sessionStorageManager.bestRecord);
|
console.log("bestRecord : " + sessionStorageManager.getBestRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sessionStorageManager.maestroID === null && !isLogin()) {
|
if(sessionStorageManager.getMaestroID() === null && !isLogin()) {
|
||||||
goLogin();
|
goLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,17 +52,17 @@ function goLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTypingGame() {
|
function isTypingGame() {
|
||||||
if(sessionStorageManager.playingAppName === null)
|
if(sessionStorageManager.getPlayingAppName() === null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
if(sessionStorageManager.getPlayingAppName().indexOf("typing") < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTypingPracticeStage() {
|
function isTypingPracticeStage() {
|
||||||
let appName = sessionStorageManager.playingAppName;
|
let appName = sessionStorageManager.getPlayingAppName();
|
||||||
|
|
||||||
if(appName.indexOf("practice_") > -1)
|
if(appName.indexOf("practice_") > -1)
|
||||||
return true;
|
return true;
|
||||||
@@ -71,7 +71,7 @@ function isTypingPracticeStage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTypingTestStage() {
|
function isTypingTestStage() {
|
||||||
let appName = sessionStorageManager.playingAppName;
|
let appName = sessionStorageManager.getPlayingAppName();
|
||||||
|
|
||||||
if(appName.indexOf("test_") > -1)
|
if(appName.indexOf("test_") > -1)
|
||||||
return true;
|
return true;
|
||||||
@@ -80,21 +80,21 @@ function isTypingTestStage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isEnglishTypingStage() {
|
function isEnglishTypingStage() {
|
||||||
if(sessionStorageManager.playingAppName.indexOf("english") > -1)
|
if(sessionStorageManager.getPlayingAppName().indexOf("english") > -1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isKoreanTypingStage() {
|
function isKoreanTypingStage() {
|
||||||
if(sessionStorageManager.playingAppName.indexOf("korean") > -1)
|
if(sessionStorageManager.getPlayingAppName().indexOf("korean") > -1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTypingWordStage() {
|
function isTypingWordStage() {
|
||||||
let appName = sessionStorageManager.playingAppName;
|
let appName = sessionStorageManager.getPlayingAppName();
|
||||||
|
|
||||||
if(appName.indexOf("_word") > -1)
|
if(appName.indexOf("_word") > -1)
|
||||||
return true;
|
return true;
|
||||||
@@ -106,7 +106,7 @@ function isTypingWordStage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTypingSentenceStage() {
|
function isTypingSentenceStage() {
|
||||||
let appName = sessionStorageManager.playingAppName;
|
let appName = sessionStorageManager.getPlayingAppName();
|
||||||
|
|
||||||
if(appName.indexOf("_sentence") > -1)
|
if(appName.indexOf("_sentence") > -1)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ function GameAppButton(x, y, type, iconName, buttonText, appInfo) {
|
|||||||
|
|
||||||
|
|
||||||
GameAppButton.prototype.clickEvent = function() {
|
GameAppButton.prototype.clickEvent = function() {
|
||||||
sessionStorageManager.playingAppID = this.appInfo.AppID;
|
sessionStorageManager.getPlayingAppID() = this.appInfo.AppID;
|
||||||
sessionStorageManager.playingAppName = this.appInfo.AppName;
|
sessionStorageManager.getPlayingAppName() = this.appInfo.AppName;
|
||||||
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
|
sessionStorageManager.getPlayingAppKoreanName() = this.appInfo.KoreanName;
|
||||||
|
|
||||||
location.href = '../../web/client/start.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ function TypingAppButton(type, x, y, iconName, buttonText, appInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypingAppButton.prototype.clickEvent = function() {
|
TypingAppButton.prototype.clickEvent = function() {
|
||||||
sessionStorageManager.playingAppID = this.appInfo.AppID;
|
sessionStorageManager.setPlayingAppID(this.appInfo.AppID);
|
||||||
sessionStorageManager.playingAppName = this.appInfo.AppName;
|
sessionStorageManager.setPlayingAppName(this.appInfo.AppName);
|
||||||
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
|
sessionStorageManager.setPlayingAppKoreanName(this.appInfo.KoreanName);
|
||||||
|
|
||||||
location.href = '../../web/client/start.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,114 @@
|
|||||||
|
function SessionStorageManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SessionStorageManager.prototype.clear = function() {
|
||||||
|
sessionStorage.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionStorageManager.prototype.removeItem = function(key) {
|
||||||
|
return sessionStorage.removeItem(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// maestro ID
|
||||||
|
SessionStorageManager.prototype.setMaestroID = function(value) {
|
||||||
|
sessionStorage.setItem("maestroID", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getMaestroID = function() {
|
||||||
|
return sessionStorage.getItem("maestroID");
|
||||||
|
}
|
||||||
|
|
||||||
|
// maestro account type
|
||||||
|
SessionStorageManager.prototype.setMaestroAccountType = function(value) {
|
||||||
|
sessionStorage.setItem("maestroAccountType", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getMaestroAccountType = function() {
|
||||||
|
return sessionStorage.getItem("maestroAccountType");
|
||||||
|
}
|
||||||
|
|
||||||
|
// player name
|
||||||
|
SessionStorageManager.prototype.setPlayerName = function(value) {
|
||||||
|
sessionStorage.setItem("playerName", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayerName = function() {
|
||||||
|
return sessionStorage.getItem("playerName");
|
||||||
|
}
|
||||||
|
|
||||||
|
// player player ID
|
||||||
|
SessionStorageManager.prototype.setPlayerID = function(value) {
|
||||||
|
sessionStorage.setItem("playerID", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayerID = function() {
|
||||||
|
return sessionStorage.getItem("playerID");
|
||||||
|
}
|
||||||
|
|
||||||
|
// player account type
|
||||||
|
SessionStorageManager.prototype.setPlayerAccountType = function(value) {
|
||||||
|
sessionStorage.setItem("playerAccountType", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayerAccountType = function() {
|
||||||
|
return sessionStorage.getItem("playerAccountType");
|
||||||
|
}
|
||||||
|
|
||||||
|
// playing app id
|
||||||
|
SessionStorageManager.prototype.setPlayingAppID = function(value) {
|
||||||
|
sessionStorage.setItem("playingAppID", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayingAppID = function() {
|
||||||
|
return sessionStorage.getItem("playingAppID");
|
||||||
|
}
|
||||||
|
|
||||||
|
// playing app name
|
||||||
|
SessionStorageManager.prototype.setPlayingAppName = function(value) {
|
||||||
|
sessionStorage.setItem("playingAppName", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayingAppName = function() {
|
||||||
|
return sessionStorage.getItem("playingAppName");
|
||||||
|
}
|
||||||
|
|
||||||
|
// playing app korean name
|
||||||
|
SessionStorageManager.prototype.setPlayingAppKoreanName = function(value) {
|
||||||
|
sessionStorage.setItem("playingAppKoreanName", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getPlayingAppKoreanName = function() {
|
||||||
|
return sessionStorage.getItem("playingAppKoreanName");
|
||||||
|
}
|
||||||
|
|
||||||
|
// record
|
||||||
|
SessionStorageManager.prototype.setRecord = function(value) {
|
||||||
|
sessionStorage.setItem("record", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getRecord = function() {
|
||||||
|
return sessionStorage.getItem("record");
|
||||||
|
}
|
||||||
|
|
||||||
|
// best record
|
||||||
|
SessionStorageManager.prototype.setBestRecord = function(value) {
|
||||||
|
sessionStorage.setItem("bestRecord", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getBestRecord = function() {
|
||||||
|
return sessionStorage.getItem("bestRecord");
|
||||||
|
}
|
||||||
|
|
||||||
|
// best record
|
||||||
|
SessionStorageManager.prototype.setIsNewBestRecord = function(value) {
|
||||||
|
sessionStorage.setItem("isNewBestRecord", value);
|
||||||
|
}
|
||||||
|
SessionStorageManager.prototype.getIsNewBestRecord = function() {
|
||||||
|
return sessionStorage.getItem("isNewBestRecord");
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionStorageManager.prototype.resetPlayingAppData = function() {
|
||||||
|
this.removeItem(playingAppID);
|
||||||
|
this.removeItem(playingAppName);
|
||||||
|
this.removeItem(playingAppKoreanName);
|
||||||
|
this.removeItem(record);
|
||||||
|
this.removeItem(bestRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
class SessionStorageManager {
|
class SessionStorageManager {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -109,3 +220,4 @@ class SessionStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -47,9 +47,9 @@ var MenuApp = {
|
|||||||
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
|
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
|
||||||
// ScreenBottomUI.printCenterText(playingAppName);
|
// ScreenBottomUI.printCenterText(playingAppName);
|
||||||
screenBottomUI.printCenterText("메뉴");
|
screenBottomUI.printCenterText("메뉴");
|
||||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||||
|
|
||||||
new WelcomePlayerText(sessionStorageManager.playerName);
|
new WelcomePlayerText(sessionStorageManager.getPlayerName());
|
||||||
|
|
||||||
|
|
||||||
this.loadAppData();
|
this.loadAppData();
|
||||||
@@ -60,7 +60,7 @@ var MenuApp = {
|
|||||||
loadAppData: function() {
|
loadAppData: function() {
|
||||||
var dbConnectManager = new DBConnectManager();
|
var dbConnectManager = new DBConnectManager();
|
||||||
dbConnectManager.requestMenuAppList(
|
dbConnectManager.requestMenuAppList(
|
||||||
sessionStorageManager.maestroID,
|
sessionStorageManager.getMaestroID(),
|
||||||
(function(replyJSON) {
|
(function(replyJSON) {
|
||||||
this.loadSucceeded(replyJSON);
|
this.loadSucceeded(replyJSON);
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
|
|||||||
+15
-15
@@ -31,11 +31,11 @@ class Start {
|
|||||||
|
|
||||||
|
|
||||||
// contents
|
// contents
|
||||||
this.loadHowToPlay(sessionStorageManager.playingAppID);
|
this.loadHowToPlay(sessionStorageManager.getPlayingAppID());
|
||||||
this.makeStartButton();
|
this.makeStartButton();
|
||||||
this.makeRankingButton();
|
this.makeRankingButton();
|
||||||
|
|
||||||
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
|
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||||
this.printSampleChart();
|
this.printSampleChart();
|
||||||
this.announceBox = new AnnounceBox(50, 648);
|
this.announceBox = new AnnounceBox(50, 648);
|
||||||
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
||||||
@@ -47,27 +47,27 @@ class Start {
|
|||||||
// bottom ui
|
// bottom ui
|
||||||
var screenBottomUI = new ScreenBottomUI();
|
var screenBottomUI = new ScreenBottomUI();
|
||||||
screenBottomUI.printLeftText("오늘의 최고 기록 : ");
|
screenBottomUI.printLeftText("오늘의 최고 기록 : ");
|
||||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||||
|
|
||||||
this.dbConnectManager.requestTodayBestRecord(
|
this.dbConnectManager.requestTodayBestRecord(
|
||||||
sessionStorageManager.maestroID,
|
sessionStorageManager.getMaestroID(),
|
||||||
sessionStorageManager.playerID,
|
sessionStorageManager.getPlayerID(),
|
||||||
sessionStorageManager.playingAppID,
|
sessionStorageManager.getPlayingAppID(),
|
||||||
(function(replyJSON) {
|
(function(replyJSON) {
|
||||||
sessionStorageManager.bestRecord = Number(replyJSON["BestRecord"]);
|
sessionStorageManager.getBestRecord() = Number(replyJSON["BestRecord"]);
|
||||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
(function(replyJSON) { // no data
|
(function(replyJSON) { // no data
|
||||||
sessionStorageManager.bestRecord = 0;
|
sessionStorageManager.getBestRecord() = 0;
|
||||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHowToPlay(appID) {
|
loadHowToPlay(appID) {
|
||||||
this.dbConnectManager.requestHowToPlay(
|
this.dbConnectManager.requestHowToPlay(
|
||||||
sessionStorageManager.playingAppID, // space_invaders app ID
|
sessionStorageManager.getPlayingAppID(), // space_invaders app ID
|
||||||
(function(jsonData) {
|
(function(jsonData) {
|
||||||
var howToPlayText = jsonData["HowToPlay"].replace(/\\n/g, "\n");
|
var howToPlayText = jsonData["HowToPlay"].replace(/\\n/g, "\n");
|
||||||
this.howToPlay.printHowToPlay(howToPlayText);
|
this.howToPlay.printHowToPlay(howToPlayText);
|
||||||
@@ -83,7 +83,7 @@ class Start {
|
|||||||
var today = new Date();
|
var today = new Date();
|
||||||
var date = DateUtil.getYYYYMMDD(today);
|
var date = DateUtil.getYYYYMMDD(today);
|
||||||
this.dbConnectManager.requestPlayerHistory(
|
this.dbConnectManager.requestPlayerHistory(
|
||||||
sessionStorageManager.maestroID,
|
sessionStorageManager.getMaestroID(),
|
||||||
date,
|
date,
|
||||||
(function(historyRecordManager) {
|
(function(historyRecordManager) {
|
||||||
if(historyRecordManager.count == 0) {
|
if(historyRecordManager.count == 0) {
|
||||||
@@ -158,7 +158,7 @@ class Start {
|
|||||||
location.href = '../../web/client/ranking.html';
|
location.href = '../../web/client/ranking.html';
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if(sessionStorageManager.maestroAccountType == 100)
|
if(sessionStorageManager.getMaestroAccountType() == 100)
|
||||||
rankingButton.inputEnabled = false;
|
rankingButton.inputEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ class Start {
|
|||||||
else if(isTypingTestStage())
|
else if(isTypingTestStage())
|
||||||
location.href = "../../web/client/typing_test.html";
|
location.href = "../../web/client/typing_test.html";
|
||||||
else
|
else
|
||||||
location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html";
|
location.href = "../../web/client/" + sessionStorageManager.getPlayingAppName() + ".html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user