summaryrefslogtreecommitdiff
path: root/js/codeq/python.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq/python.js')
-rw-r--r--js/codeq/python.js87
1 files changed, 5 insertions, 82 deletions
diff --git a/js/codeq/python.js b/js/codeq/python.js
index 2ea960a..4109b62 100644
--- a/js/codeq/python.js
+++ b/js/codeq/python.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,20 +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 python 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.
- *
- * Currentyl it is mostly a copy of the prolog state (the exception is of course the makePythonTerminalHandler instead of makePrologTerminalHandler)
- */
-
(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_python'), // the screen container element
- //quadrants
+ var jqScreen = $('#screen_python'), // the screen container element
+ // quadrants
jqDescription = jqScreen.find('.block1'),
jqCode = jqScreen.find('.block2'),
jqConsole = jqScreen.find('.block3'),
@@ -40,54 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnStop = jqScreen.find('.btn-stop'),
jqInfoButtons = jqBtnPlan.add(jqBtnTest), // 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;
- }
- }
- };
- var pythonHandler; //created when we enter the python state and destroyed once we leave it
+ pythonHandler; // created when we enter the python state and destroyed once we leave it
- var enterFun = function(problemDef, commonDef, currentSolution){
+ var enterFun = function(problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
var navigationPhython = $("#navigation-python");
navigationPhython.addClass("active");
@@ -95,21 +40,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
pythonHandler = createPythonHandler(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));
- });
};
codeq.globalStateMachine.register('python', {
@@ -134,8 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', 'none');
pythonHandler.destroy();
pythonHandler = null;
- subScreens.destroy();
- subScreens = null;
jqScreen.addClass('block1');
$('#navigation-problem_list').css('display', 'none');
@@ -145,11 +73,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};