Add: writing_info.php

This commit is contained in:
2019-07-11 21:57:05 +09:00
parent 33ac149831
commit 5d1090e652
8 changed files with 112 additions and 127 deletions
+2 -2
View File
@@ -37,8 +37,8 @@ function TypingExamButton(x, y, iconName, buttonText, writingID) {
TypingExamButton.prototype.onClick = function() {
sessionStorageManager.setWritingID(this.writingID);
// location.href = '../../web/client/typing_examination.html';
printSessionStorage();
location.href = '../../web/client/typing_examination.html';
// printSessionStorage();
}
+17
View File
@@ -71,4 +71,21 @@ DBService.prototype.requestWritingPlayerList = function(onSucceededListener, onF
}).bind(this)
);
xhr.send("maestroID=" + this.maestroID + "&playerID=" + this.playerID);
}
DBService.prototype.requestWritingInfo = function(writingID, onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/writing/writing_info.php",
(function() { // onreadystatechange
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
}).bind(this)
);
xhr.send("writingID=" + writingID);
}
-113
View File
@@ -109,23 +109,6 @@ var MenuTypingExam = {
this.downloadListFailed(jsonData);
}
);
/*
var dbConnectManager = new DBConnectManager();
dbConnectManager.requestTypingTestAppList(
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
// self.downloadListSucceeded,
// self.downloadListFailed
(function(replyJSON) {
this.downloadListSucceeded(replyJSON);
}).bind(this),
(function(replyJSON) {
this.downloadListFailed(replyJSON);
}).bind(this)
);
*/
},
hasApp: function(appID, appList) {
@@ -190,104 +173,8 @@ var MenuTypingExam = {
indexEnglishWriting++;
}
}
/*
var buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingExam.BUTTON_GAP;
var koreanTypingPracticeAppCount = replyJSON.KoreanAppList.length; // Object.keys(replyJSON.KoreanAppList).length;
var englishTypingPracticeAppCount = replyJSON.EnglishAppList.length; // Object.keys(replyJSON.EnglishAppList).length;
for(var i = 0; i < koreanTypingPracticeAppCount; i++) {
var activeApp = replyJSON.KoreanAppList[i];
var posX = this.getButtonPosX(i, koreanTypingPracticeAppCount);
var posY = this.getButtonPosY(i, koreanTypingPracticeAppCount,
TypingAppButton.BUTTON_UPPER_POS_Y
);
var typingTestButton = new TypingAppButton(
TypingAppButton.TYPE_TEST_KOREAN,
posX, posY,
this.getAnimalSprite(replyJSON.KoreanHighScoreList, activeApp.AppID),
activeApp.KoreanName,
{
AppID: activeApp.AppID,
AppName: activeApp.AppName,
KoreanName: activeApp.KoreanName
}
);
if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
typingTestButton.setInputEnabled(false);
}
for(var i = 0; i < englishTypingPracticeAppCount; i++) {
var activeApp = replyJSON.EnglishAppList[i];
var posX = this.getButtonPosX(i, englishTypingPracticeAppCount);
var posY = this.getButtonPosY(i, englishTypingPracticeAppCount,
TypingAppButton.BUTTON_LOWER_POS_Y
);
var typingTestButton = new TypingAppButton(
TypingAppButton.TYPE_TEST_ENGLISH,
posX, posY,
this.getAnimalSprite(replyJSON.EnglishHighScoreList, activeApp.AppID),
activeApp.KoreanName,
{
AppID: activeApp.AppID,
AppName: activeApp.AppName,
KoreanName: activeApp.KoreanName
}
);
if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
typingTestButton.setInputEnabled(false);
}
*/
},
getButtonPosX: function(index, buttonCount) {
var gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum);
var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount);
var columnIndex = index % maxColumnNum;
// console.log("columnIndex : " + columnIndex);
var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex);
var columnCountForThisRow = 0;
if(rowIndex < rowCount - 1)
columnCountForThisRow = maxColumnNum;
else
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
// console.log("columnCountForThisRow : " + columnCountForThisRow);
var startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
return startX + gap * columnIndex;
},
getButtonPosY: function(index, buttonCount, startPosY) {
var rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
var columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
// console.log("maxColumnNum : " + maxColumnNum);
// console.log("buttonCount : " + buttonCount);
var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount);
var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex);
var startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
return startY + rowGap * rowIndex;
},
downloadListFailed: function(replyJSON) {
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
}
+28 -6
View File
@@ -272,7 +272,7 @@ var TypingExamination = {
back: function() {
sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/menu_typing_test.html';
location.href = '../../web/client/menu_typing_exam.html';
},
startGame: function() {
@@ -333,15 +333,33 @@ var TypingExamination = {
loadExaminationContent: function() {
var path = "./../../../resources/file/typing_exam/";
var dbService = new DBService();
dbService.setMaestroID(sessionStorageManager.getMaestroID());
dbService.setPlayerID(sessionStorageManager.getPlayerID());
// get the writing data from session storage
// get the writing data from DB
dbService.requestWritingInfo(
sessionStorageManager.getWritingID(),
(function(jsonData) { // onSucceeded
this.downloadListSucceeded(jsonData);
}).bind(this),
(function(jsonData) { // onFailed
this.downloadListFailed(jsonData);
}).bind(this)
);
},
var filename = "korean_heoseng.txt";
var writer = "system";
downloadListSucceeded: function(jsonData) {
console.log(jsonData);
var writingInfo = jsonData["writingInfo"];
console.log(writingInfo);
var writer = writingInfo["writer"];
var writerID = "";
writingInfo["writerID"] == null ? writerID = "" : writerID = writingInfo["writerID"];
var path = "./../../../resources/file/typing_exam/";
var directory = writer + writerID + "/";
var filename = writingInfo["filename"];
var url = path + directory + filename;
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
@@ -351,6 +369,10 @@ var TypingExamination = {
game.load.start();
},
downloadListFailed: function(jsonData) {
console.log(jsonData);
},
completeLoadingWriting: function() {
game.load.onFileComplete.remove(this.loadExaminationContent, this);
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);