Add: sql - login, history_record
This commit is contained in:
@@ -18,30 +18,127 @@ class DBConnectManager {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
requestCheckUserLogin(userName, enterCode, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/server/user/login.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null && jsonData["UserID"] != null)
|
||||
onSucceededListener(jsonData);
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
};
|
||||
xhr.send("name=" + sessionStorageManager.playerName + "&enter_code=" + enterCode);
|
||||
}
|
||||
|
||||
requestPlayerHistory(listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
if(isDebugMode())
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(listener === null)
|
||||
return;
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
listener(historyRecordManager);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
let self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/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) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null) {
|
||||
listener(self.parseJSONtoHistoryRecord(jsonData));
|
||||
}
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
};
|
||||
xhr.send("UserID=" + sessionStorageManager.playerUserID + "&AppName=" + sessionStorageManager.playingAppName);
|
||||
}
|
||||
|
||||
parseJSONtoHistoryRecord(json) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
let count = json.history.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new HistoryRecord(
|
||||
json.history[i]["Date"],
|
||||
json.history[i]["AppName"],
|
||||
json.history[i]["HighScore"]
|
||||
);
|
||||
historyRecordManager.push(record);
|
||||
}
|
||||
|
||||
return historyRecordManager;
|
||||
|
||||
/*
|
||||
var startIndex = 0;
|
||||
var endIndex = jsonRankingList.length;
|
||||
|
||||
var recordArray = [];
|
||||
for(var i = startIndex; i < endIndex; i++) {
|
||||
var bestRecordRow = [];
|
||||
var strDate = jsonRankingList[i]['Date'];
|
||||
var dateArray = strDate.split("-");
|
||||
var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]);
|
||||
bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일";
|
||||
bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']);
|
||||
bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']);
|
||||
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
|
||||
|
||||
recordArray.push(bestRecordRow);
|
||||
}
|
||||
|
||||
return recordArray;
|
||||
*/
|
||||
}
|
||||
|
||||
requestRanking(type, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
if(isDebugMode())
|
||||
this.loadTempRanking(rankingRecordManager);
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
if(listener === null)
|
||||
return;
|
||||
|
||||
listener(rankingRecordManager);
|
||||
}
|
||||
}
|
||||
|
||||
onFailed(errorMessage) {
|
||||
console.log("failed : " + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
makeXHRWithParam(url, param, onSucceededListener, onFailedListener) {
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null && jsonData["UserID"] != null)
|
||||
onSucceededListener(jsonData);
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
return xhr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
loadTempPlayerHistory(historyRecordManager) {
|
||||
historyRecordManager.push(new HistoryRecord("05/14", "space_invaders", 14460));
|
||||
|
||||
Reference in New Issue
Block a user