From 5d08e67fe3afb64365766899da4cbce4debfa086 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 24 Feb 2016 16:39:36 +0100 Subject: Remove substate machines from {prolog,python,robot}.js Unused code is unused. --- js/codeq/robot.js | 82 ++++--------------------------------------------------- 1 file changed, 5 insertions(+), 77 deletions(-) (limited to 'js/codeq/robot.js') diff --git a/js/codeq/robot.js b/js/codeq/robot.js index 42f336c..8754c82 100644 --- a/js/codeq/robot.js +++ b/js/codeq/robot.js @@ -1,5 +1,5 @@ /* CodeQ: an online programming tutor. - Copyright (C) 2015 UL FRI + Copyright (C) 2015,2016 UL FRI This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,16 +14,10 @@ details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -/** - * The robot state of the state machine. When it is entered it'll prepare the code editor and load a sub-state machine which represents the 3 different parts of the screen. - */ - (function() { "use strict"; - var subScreens, //this will be the actual (sub)state machine - stateNameTag = 'stateName', //a tag for data which is added to some html elements - jqScreen = $('#screen_robot'), // the screen container element - //quadrants + var jqScreen = $('#screen_robot'), // the screen container element + // quadrants jqDescription = jqScreen.find('.block1'), jqCode = jqScreen.find('.block2'), jqConsole = jqScreen.find('.block3'), @@ -36,53 +30,9 @@ along with this program. If not, see . */ jqBtnStop = jqScreen.find('.btn-stop'), jqInfoButtons = jqBtnPlan.add(jqBtnHint), // all info-focusing buttons jqAllButtons = jqInfoButtons.add(jqBtnRun).add(jqBtnStop), // all buttons - // misc - currentSubState = null, - transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below) - substates = { - 'description': { - 'enter': function () { - currentSubState = 'block1'; - jqScreen.addClass(currentSubState); - }, - 'exit': function () { - jqScreen.removeClass(currentSubState); - currentSubState = null; - } - }, - 'code': { - 'enter': function () { - currentSubState = 'block2'; - jqScreen.addClass(currentSubState); - }, - 'exit': function () { - jqScreen.removeClass(currentSubState); - currentSubState = null; - } - }, - 'info': { - 'enter': function () { - currentSubState = 'block4'; - jqScreen.addClass(currentSubState); - }, - 'exit': function () { - jqScreen.removeClass(currentSubState); - currentSubState = null; - } - }, - 'console': { - 'enter': function () { - currentSubState = 'block3'; - jqScreen.addClass(currentSubState); - }, - 'exit': function () { - jqScreen.removeClass(currentSubState); - currentSubState = null; - } - } - }; + robotHandler; - var enterFun = function(problemDef, commonDef, currentSolution){ + var enterFun = function(problemDef, commonDef, currentSolution) { $('#navigation-problem_list').css('display', ''); var navigationRobot = $("#navigation-robot"); navigationRobot.addClass("active"); @@ -90,21 +40,6 @@ along with this program. If not, see . */ 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 @@ -130,8 +65,6 @@ along with this program. If not, see . */ jqScreen.css('display', 'none'); robotHandler.destroy(); robotHandler = null; - subScreens.destroy(); - subScreens = null; jqScreen.addClass('block1'); $('#navigation-problem_list').css('display', 'none'); @@ -141,11 +74,6 @@ along with this program. If not, see . */ } }); - jqDescription.data(stateNameTag, 'description'); - jqCode.data(stateNameTag, 'code'); - jqConsole.data(stateNameTag, 'console'); - jqInfo.data(stateNameTag, 'info'); - // a constant var firstCharacterPos = {'line': 0, 'ch': 0}; -- cgit v1.2.1