diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/core.js | 12 | ||||
-rw-r--r-- | js/codeq/navigation.js | 4 | ||||
-rw-r--r-- | js/codeq/robot.js | 20 |
3 files changed, 21 insertions, 15 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js index 28767f7..22f6a50 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -307,7 +307,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ traversedPath.push(fragment); if (branch[resourceName]) candidate = traversedPath.join('/') + '/' + resourceName; } - if (candidate) return candidate; + if (candidate) return codeq.ajaxPrefix + candidate; codeq.log.error('Resource ' + resourceName + ' was not found; path: "' + resourceBranches.join('/') + '"'); return null; }; @@ -610,9 +610,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ codeq.log.info('App reset: ' + (reason || 'no reason given')); codeq.globalStateMachine.transition('login'); codeq.wait( - codeq.comms.logout() - .finally(codeq.comms.disconnect) - .fail(function () {}) // ignore errors + codeq.comms.getSid() == null ? Q() : codeq.comms.logout() + .finally( + codeq.comms.disconnect + ) + .fail(function (e) { + codeq.log.debug(e) + }) // ignore errors ) .then(function () { if (reason) { diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js index cfff71b..d806eea 100644 --- a/js/codeq/navigation.js +++ b/js/codeq/navigation.js @@ -95,11 +95,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ name = 'login';//this will cause the following code to transition to the login state instead of the original one given } - var newState = def[name];//if the newState is not the same as the old or if it doesn't exist at all is already checked at this point -// if (currState) currState.exit(); -// currState = newState; -// currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); if (currState) { if (newState.isModal) { if (currState.isModal) currState.exit(); diff --git a/js/codeq/robot.js b/js/codeq/robot.js index cfff13d..32c3b35 100644 --- a/js/codeq/robot.js +++ b/js/codeq/robot.js @@ -136,13 +136,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ var makeRobotTerminalHandler = function (jqConsole, editor, problem_id, activityHandler) { var terminal = codeq.makeConsole(jqConsole, { - 'greeting': 'CodeQ Robot terminal proxy', - 'autoHistory': true + 'greeting': 'Robot messages\n--------------\n\n', }); - - terminal.onInput = function (text) { - terminal.append('Not implemented.\n', 'output'); - }; + terminal.inputDisable(); return terminal; }; @@ -153,7 +149,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ var createRobotHandler = function (problemDef, commonDef, currentSolution) { var jqDescriptionContent = jqDescription.find('.description'), jqEditor = jqCode.find('.code_editor'), + jqTerminal = jqConsole.find('.console'), jqHints = jqInfo.find('.hints'), + jqStatus = jqConsole.find('.status'), editor = codeq.makeEditor(jqEditor[0], { mode: 'python', @@ -164,6 +162,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqBtnRun.focus(); }), activityHandler = codeq.makeActivityHandler(editor, problemDef.id), + terminal = makeRobotTerminalHandler(jqTerminal, editor, problemDef.id, activityHandler), hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'robot_hints', problemDef, commonDef), commError = function (error) { alert(error); @@ -175,6 +174,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ // set up the websocket events socket.on('close', function (data) { console.log('websocket closed, trying to reopen in 1 s'); + jqStatus.html('Not connected.'); reconnectTimer = setTimeout(function () { reconnectTimer = null; socket.open(); @@ -190,7 +190,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ if (!sensors.hasOwnProperty(sensor)) continue; text += sensor + ': ' + sensors[sensor] + '<br />\n' } - $('div.console').html('<p style="color: lightgreen; font-family: monospace;">'+text+'</p>'); + jqStatus.html(text); + } + else if (json_obj.event == 'output') { + text = json_obj.text; + terminal.append(text, 'output'); } }); @@ -248,10 +252,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ var program = editor.getDoc().getValue(); activityHandler.queueTrace({'typ': 'robot_run', 'program': program}); socket.send(JSON.stringify({action: 'run', program: program})); + terminal.append('<run>\n', 'output'); }); jqBtnStop.on('click', function () { activityHandler.queueTrace({'typ': 'robot_stop'}); socket.send(JSON.stringify({action: 'stop'})); + terminal.append('<stop>\n', 'output'); }); codeq.comms.loadProblem(problemDef.id).done(); |