Add: test_db_connect_manager
This commit is contained in:
@@ -22,13 +22,13 @@ const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||
|
||||
let sessionStorageManager = new SessionStorageManager();
|
||||
{
|
||||
if(isDebugMode()) {
|
||||
sessionStorageManager.playerName = "부현율";
|
||||
sessionStorageManager.playerUserID = 8;
|
||||
sessionStorageManager.playingAppName = "space_invaders";
|
||||
sessionStorageManager.score = 1000;
|
||||
sessionStorageManager.highScore = 2000;
|
||||
}
|
||||
// if(isDebugMode()) {
|
||||
// sessionStorageManager.playerName = "부현율";
|
||||
// sessionStorageManager.playerUserID = 8;
|
||||
// sessionStorageManager.playingAppName = "space_invaders";
|
||||
// sessionStorageManager.score = 1000;
|
||||
// sessionStorageManager.highScore = 2000;
|
||||
// }
|
||||
|
||||
console.log("maestroID : " + sessionStorageManager.maestroID);
|
||||
console.log("playerName : " + sessionStorageManager.playerName);
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
class DBConnectManager {
|
||||
|
||||
constructor() {
|
||||
this.path = this.getPath();
|
||||
this.directoryName = this.getDirectoryName(this.path);
|
||||
this.phpPath = this.getPHPPath(this.directoryName);
|
||||
|
||||
this.maestroID = 0;
|
||||
this.playerUserID = 0;
|
||||
this.appName = "";
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
setMaestro(maestroID) {
|
||||
setMaestroID(maestroID) {
|
||||
this.maestroID = maestroID;
|
||||
}
|
||||
|
||||
setPlayer(userID) {
|
||||
setPlayerID(userID) {
|
||||
this.playerUserID = userID;
|
||||
}
|
||||
|
||||
@@ -18,9 +23,33 @@ class DBConnectManager {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
setDateTime(date, time) {
|
||||
this.dateAndTime = date + time;
|
||||
}
|
||||
|
||||
resetDateTime() {
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
getPath() {
|
||||
return window.location.pathname;
|
||||
}
|
||||
|
||||
getDirectoryName(path) {
|
||||
let pathAndFileNames = path.split("/");
|
||||
return pathAndFileNames[pathAndFileNames.length - 2];
|
||||
}
|
||||
|
||||
getPHPPath(directoryName) {
|
||||
if(directoryName === "test") // mouse_typing/test/
|
||||
return "../src/web/";
|
||||
else // mousetyping/src/web/client/
|
||||
return "../";
|
||||
}
|
||||
|
||||
requestCheckUserLogin(userName, enterCode, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/server/user/login.php", true);
|
||||
xhr.open("POST", this.phpPath + "server/user/login.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
@@ -32,7 +61,7 @@ class DBConnectManager {
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
};
|
||||
xhr.send("name=" + sessionStorageManager.playerName + "&enter_code=" + enterCode);
|
||||
xhr.send("name=" + userName + "&enter_code=" + enterCode);
|
||||
}
|
||||
|
||||
requestPlayerHistory(listener) {
|
||||
@@ -52,7 +81,7 @@ class DBConnectManager {
|
||||
let self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/server/record/history_record.php", true);
|
||||
xhr.open("POST", this.phpPath + "server/record/history_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
@@ -128,7 +157,7 @@ class DBConnectManager {
|
||||
let self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.getPHPUrl(type), true);
|
||||
xhr.open("POST", this.getRankingRecordUrl(type), true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
@@ -146,22 +175,27 @@ class DBConnectManager {
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
getPHPUrl(type) {
|
||||
getRankingRecordUrl(type) {
|
||||
let rankingRecordURL = this.phpPath;
|
||||
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
return "../../web/server/record/ranking_hour_record.php";
|
||||
rankingRecordURL += "server/record/ranking_record_hour.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||
return "../../web/server/record/ranking_day_record.php";
|
||||
rankingRecordURL += "server/record/ranking_record_day.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||
return "../../web/server/record/ranking_month_record.php";
|
||||
rankingRecordURL += "server/record/ranking_record_month.php";
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
return rankingRecordURL;
|
||||
}
|
||||
|
||||
parseJSONtoRankingRecord(type, json) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class HistoryBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
this.dbConnectManager.requestPlayerHistory( historyRecordManager => {
|
||||
let maxIndex = historyRecordManager.count;
|
||||
let maxIndex = historyRecordManager.count - 1;
|
||||
if(maxIndex > 6)
|
||||
maxIndex = 6;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user