diff options
Diffstat (limited to 'js/codeq/prolog.js')
-rw-r--r-- | js/codeq/prolog.js | 79 |
1 files changed, 5 insertions, 74 deletions
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index ea4c9b2..9a674e8 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.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,18 +14,10 @@ details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/** - * Created by robert on 9/17/15. - * - * The prolog state of the state machine. When it is entered it'll prepare the console and code editor and load a sub-state machine which represents the 4 different parts fo 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_prolog'), // the screen container element - //quadrants + var jqScreen = $('#screen_prolog'), // the screen container element + // quadrants jqDescription = jqScreen.find('.block1'), jqCode = jqScreen.find('.block2'), jqConsole = jqScreen.find('.block3'), @@ -35,53 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqBtnPlan = jqScreen.find('.btn-plan'), jqBtnTest = jqScreen.find('.btn-test').ladda(), jqAllButtons = jqBtnPlan.add(jqBtnTest), // all the 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; - } - } - }; + prologHandler; - var enterFun = function(problemDef, commonDef, currentSolution){ + var enterFun = function(problemDef, commonDef, currentSolution) { $('#navigation-problem_list').css('display', ''); var navigationProlog = $("#navigation-prolog"); navigationProlog.addClass("active"); @@ -89,16 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly prologHandler = createPrologHandler(problemDef, commonDef, currentSolution); - subScreens = codeq.makeStateMachine(substates); - subScreens.transition(jqDescription.data(stateNameTag)); - - jqAllButtons.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 - }); - jqAllQuadrants.on(transitionEventName, function () { - subScreens.transition($(this).data(stateNameTag)); - }); }; var prologHandler; //created when we enter the prolog state and destroyed once we leave it @@ -123,8 +61,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqScreen.css('display', 'none'); prologHandler.destroy(); prologHandler = null; - subScreens.destroy(); - subScreens = null; jqScreen.addClass('block1'); $('#navigation-problem_list').css('display', 'none'); @@ -134,11 +70,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } }); - jqDescription.data(stateNameTag, 'description'); - jqCode.data(stateNameTag, 'code'); - jqConsole.data(stateNameTag, 'console'); - jqInfo.data(stateNameTag, 'info'); - // a constant var firstCharacterPos = {'line': 0, 'ch': 0}; |