diff --git a/src/game/lib/db_service.js b/src/game/lib/db_service.js index c17d14f..9056e8f 100644 --- a/src/game/lib/db_service.js +++ b/src/game/lib/db_service.js @@ -91,6 +91,27 @@ DBService.prototype.tddRun = function(command, onSucceededListener, onFailedList xhr.send("command=" + command); } + +// allow edit setting for play enter code +DBService.prototype.requestAllowEditEnterCode = function(onSucceededListener, onFailedListener) { + var xhr = this.makeXhr( + "php/menu/allow_edit_entercode.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("maestroID=" + this.maestroID); +} + + + // writing DBService.prototype.requestWritingPlayerList = function(onSucceededListener, onFailedListener) { var xhr = this.makeXhr( diff --git a/src/game/main_menu/main_menu.js b/src/game/main_menu/main_menu.js index 77b2d3b..3932d84 100644 --- a/src/game/main_menu/main_menu.js +++ b/src/game/main_menu/main_menu.js @@ -72,9 +72,10 @@ MainMenu.prototype.fontLoaded = function() { ); // top UI - this.makeButtons(); + this.backButton = new BackButton( + (function() { console.log("back"); }).bind(this) + ); this.backButton.applyLoadedFont(); - this.settingButton.applyLoadedFont(); this.makeAppGroupTab(); this.makeLanguageTab(); @@ -100,6 +101,8 @@ MainMenu.prototype.fontLoaded = function() { this.activeSavedAppGroupTab(); this.activeSavedLanguageTab(); // this.loadAppData(); + + this.loadAllowEditEnterCode(); } @@ -109,26 +112,14 @@ MainMenu.prototype.back = function() { location.href = '../../web/client/login.html'; } -MainMenu.prototype.loadAllowEditEnterCode = function(screenTopUI) { - /* - var dbConnectManager = new DBConnectManager(); - dbConnectManager.requestAllowEditEnterCode( - sessionStorageManager.getMaestroID(), - +MainMenu.prototype.loadAllowEditEnterCode = function() { + this.dbService.requestAllowEditEnterCode( (function(replyJSON) { - if(replyJSON["AllowEditEnterCode"] == "1") { - screenTopUI.makeSetupButton( (function() { - console.log("setup"); - location.href = '../../web/client/setup.html'; - }).bind(this) ); - } + if(parseInt(replyJSON.allowEditEntercode) === 1) + this.makeSettingButton(); }).bind(this), - - (function(replyJSON) { - this.loadFailed(replyJSON); - }).bind(this) + (function(replyJSON) { console.log(replyJSON); }).bind(this) ); - */ } MainMenu.prototype.loadAppData = function() { @@ -140,9 +131,7 @@ MainMenu.prototype.loadAppData = function() { this.updateAppButtons(replyJSON.appGroup, replyJSON.appData); // this.updateLanguageTab(replyJSON.appGroup); }).bind(this), - (function(replyJSON) { - console.log(replyJSON); - }).bind(this) + (function(replyJSON) { console.log(replyJSON); }).bind(this) ); } @@ -420,14 +409,11 @@ MainMenu.prototype.updatePlayAppButtons = function(appData) { } -MainMenu.prototype.makeButtons = function() { - this.backButton = new BackButton( - (function() { console.log("back"); }).bind(this) - ); - +MainMenu.prototype.makeSettingButton = function() { this.settingButton = new SettingButton( - (function() { console.log("setting"); }).bind(this) + (function() { location.href = '../../web/client/setup.html'; }).bind(this) ); + this.settingButton.applyLoadedFont(); } MainMenu.prototype.activeSavedAppGroupTab = function() { diff --git a/src/game/setup/setup.js b/src/game/setup/setup.js index b3d2d77..0fe14e3 100644 --- a/src/game/setup/setup.js +++ b/src/game/setup/setup.js @@ -54,9 +54,8 @@ var Setup = { }, back: function() { - // sessionStorageManager.clear(); - // location.href = '../../web/main/index.html'; - location.href = '../../web/client/menu_app.html'; + // location.href = '../../web/client/menu_app.html'; + location.href = '../../web/client/main_menu.html'; }, makePrevEnterCodeText: function(x, y) { diff --git a/src/web/php/db/menu_collection.php b/src/web/php/db/menu_collection.php index aea61e7..df31f91 100644 --- a/src/web/php/db/menu_collection.php +++ b/src/web/php/db/menu_collection.php @@ -319,5 +319,17 @@ class MenuCollection extends DBMethodContainer } */ + public function getAllowEditEntercode($maestroID) { + $query = "SELECT AllowEditEnterCode FROM maestro WHERE MaestroID = ?"; + $stmt = $this->mysqli->prepare($query); + $stmt->bind_param("i", $maestroID); + $stmt->execute(); + $stmt->bind_result($allowEditEntercode); + + $stmt->fetch(); + $stmt->close(); + + return $allowEditEntercode; + } } ?> \ No newline at end of file