diff options
Diffstat (limited to 'js/codeq/robot.js')
-rw-r--r-- | js/codeq/robot.js | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/js/codeq/robot.js b/js/codeq/robot.js index 32c3b35..ee6eda6 100644 --- a/js/codeq/robot.js +++ b/js/codeq/robot.js @@ -80,12 +80,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } } }; + + var enterFun = function(problemDef, commonDef, currentSolution){ + $('#navigation-problem_list').css('display', ''); + var navigationRobot = $("#navigation-robot"); + navigationRobot.addClass("active"); + navigationRobot.css('display', ''); + + jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly + robotHandler = createRobotHandler(problemDef, commonDef, currentSolution); + subScreens = codeq.makeStateMachine(substates); + subScreens.transition(jqDescription.data(stateNameTag)); + + jqInfoButtons.on(transitionEventName, function (event) { + subScreens.transition('info'); // set focus on the hints quadrant + event.stopPropagation(); // don't allow the event to go on and trigger further transition + }); + jqBtnRun.on(transitionEventName, function (event) { + subScreens.transition('console'); // set focus on the hints quadrant + event.stopPropagation(); // don't allow the event to go on and trigger further transition + }); + + jqAllQuadrants.on(transitionEventName, function () { + subScreens.transition($(this).data(stateNameTag)); + }); + }; + var robotHandler; //created when we enter the robot state and destroyed once we leave it codeq.globalStateMachine.register('robot', { 'jqScreen': jqScreen, - 'enter': function (problemDef, commonDef, currentSolution) { - $('#navigation-problem_list').css('display', ''); + //'enter': function (problemDef, commonDef, currentSolution) { + 'enter': function (ref, data) {//function (problemDef, commonDef, currentSolution) {// + + codeq.loadProblemData(ref,data).then(function(problem){ + //codeq.log.debug("then:"+JSON.stringify(problem)); + enterFun(problem.generalProblemData,data.commonDef,problem.solution); + }) + .fail(function (reason) { + codeq.log.error('Failed to obtain the problem definition: ' + reason, reason); + alert('Failed to obtain the problem definition: ' + reason); + + history.back();//TODO test + }) + .done(); + + + /*$('#navigation-problem_list').css('display', ''); $("#navigation-robot").addClass("active"); $('#navigation-robot').css('display', ''); @@ -93,9 +134,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ robotHandler = createRobotHandler(problemDef, commonDef, currentSolution); subScreens = codeq.makeStateMachine(substates); subScreens.transition(jqDescription.data(stateNameTag)); -/* Q.delay(100).then(function(){ - jqAllQuadrants.addClass('transition');//for smooth animations - need to be delayed, because otherwise we get some weird "animations" while the page is loading - }).done();*/ + jqInfoButtons.on(transitionEventName, function (event) { subScreens.transition('info'); // set focus on the hints quadrant event.stopPropagation(); // don't allow the event to go on and trigger further transition @@ -107,7 +146,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqAllQuadrants.on(transitionEventName, function () { subScreens.transition($(this).data(stateNameTag)); - }); + });*/ }, 'exit': function () { jqAllButtons.off(); // unregister all event handlers @@ -121,8 +160,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqScreen.addClass('block1'); $('#navigation-problem_list').css('display', 'none'); - $("#navigation-robot").removeClass("active"); - $('#navigation-robot').css('display', 'none'); + var navigationRobot = $("#navigation-robot"); + navigationRobot.removeClass("active"); + navigationRobot.css('display', 'none'); } }); |