diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js index 86cf52d..a9953a8 100644 --- a/src/game/lib/db_connect_manager.js +++ b/src/game/lib/db_connect_manager.js @@ -79,7 +79,7 @@ DBConnectManager.prototype.requestPlayerEnterCode = function(maestroID, playerID xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID); } -DBConnectManager.prototype.requestEditPlayerEnterCode = function(maestroID, playerID, enterCode, onSucceededListener, onFailedListener) { +DBConnectManager.prototype.updatePlayerEnterCode = function(maestroID, playerID, enterCode, onSucceededListener, onFailedListener) { var xhr = new XMLHttpRequest(); xhr.open("POST", this.phpPath + "server/player/edit_entercode.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -96,6 +96,23 @@ DBConnectManager.prototype.requestEditPlayerEnterCode = function(maestroID, play xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID + "&enter_code=" + enterCode); } +DBConnectManager.prototype.requestAllowEditEnterCode = function(maestroID, onSucceededListener, onFailedListener) { + var xhr = new XMLHttpRequest(); + xhr.open("POST", this.phpPath + "server/maestro/get_allow_edit_entercode.php", true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.onreadystatechange = function() { + if(xhr.readyState == 4 && xhr.status == 200) { + var replyJSON = JSON.parse(xhr.responseText); + + if(replyJSON != null && replyJSON["AllowEditEnterCode"] != null) + onSucceededListener(replyJSON); + else + onFailedListener(replyJSON); + } + }; + xhr.send("maestro_id=" + maestroID); +} + /* DBConnectManager.prototype.requestAppList = function(maestroID, onSucceededListener, onFailedListener) { var xhr = new XMLHttpRequest(); diff --git a/src/game/menu/menu_app.js b/src/game/menu/menu_app.js index 3d70a4b..4ce4489 100644 --- a/src/game/menu/menu_app.js +++ b/src/game/menu/menu_app.js @@ -44,11 +44,8 @@ var MenuApp = { // top ui var screenTopUI = new ScreenTopUI(); screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) ); - screenTopUI.makeSetupButton( (function() { - console.log("setup"); - location.href = '../../web/client/setup.html'; - }).bind(this) ); screenTopUI.makeFullScreenButton(); + this.loadAllowEditEnterCode(screenTopUI); // bottom ui @@ -77,6 +74,26 @@ var MenuApp = { location.href = '../../web/client/login.html'; }, + loadAllowEditEnterCode: function(screenTopUI) { + var dbConnectManager = new DBConnectManager(); + dbConnectManager.requestAllowEditEnterCode( + sessionStorageManager.getMaestroID(), + + (function(replyJSON) { + if(replyJSON["AllowEditEnterCode"] == "1") { + screenTopUI.makeSetupButton( (function() { + console.log("setup"); + location.href = '../../web/client/setup.html'; + }).bind(this) ); + } + }).bind(this), + + (function(replyJSON) { + this.loadFailed(replyJSON); + }).bind(this) + ); + }, + loadAppData: function() { var dbConnectManager = new DBConnectManager(); dbConnectManager.requestMenuAppList( diff --git a/src/game/setup/setup.js b/src/game/setup/setup.js index 8339c94..e25bd0e 100644 --- a/src/game/setup/setup.js +++ b/src/game/setup/setup.js @@ -151,7 +151,7 @@ var Setup = { this.showInfoText("입장번호를 바꾸겠습니다."); var dbConnectManager = new DBConnectManager(); - dbConnectManager.requestEditPlayerEnterCode( + dbConnectManager.updateEditPlayerEnterCode( sessionStorageManager.getMaestroID(), sessionStorageManager.getPlayerID(), newEnterCode,