From d10866be04d45fc73eddce0ec7005161e69e97a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Wed, 16 Sep 2015 11:37:52 +0200 Subject: Removed the "run" and "break" buttons. Removed commented-out code from prolog and python handlers. --- js/prolog.js | 154 ++--------------------------------------------------------- js/python.js | 18 +------ 2 files changed, 4 insertions(+), 168 deletions(-) (limited to 'js') diff --git a/js/prolog.js b/js/prolog.js index 730e740..ebce9bf 100644 --- a/js/prolog.js +++ b/js/prolog.js @@ -6,84 +6,6 @@ // a constant var firstCharacterPos = {'line': 0, 'ch': 0}; -/* var makePrologTerminalHandler = function (jqConsole, editor, problem_id, activityHandler) { - var promptMode = true, // default: query composition; alternative: query result browsing - tcs = function terminalCommandSuccess (data) { - var t, lines, i; - terminal.resume(); - if (data.code === 0) { - t = data.terminal; - lines = t.messages; - for (i = 0; i < lines.length; i++) { - terminal.echo(lines[i]); - } - promptMode = !t.have_more; - } - else { - terminal.error(data.message); - promptMode = true; - } - }, - tcf = function terminalCommandFailed (error) { - terminal.resume(); - terminal.exception(error); - promptMode = true; - }, - terminal = jqConsole.terminal(function (command, terminal) { - if (promptMode) { - terminal.pause(); - codeq.comms.sendQuery({ - 'problem_id': problem_id, - 'step': 'run', - 'program': editor.getDoc().getValue(), - 'query': command, - 'trace': activityHandler.addAndPurge({'typ': 'slv', 'qry': command}) - }, problem_id).then(tcs, tcf).done(); - } - else { - // not in prompt mode -- we should never land here, but handle it anyway - codeq.comms.sendQuery({ - 'problem_id': problem_id, - 'step': 'end', - 'trace': activityHandler.addAndPurge({'typ': 'stp'}) - }, problem_id).then(tcs, tcf).done(); - } - }, { - 'history': true, - 'prompt': '?- ', - 'greetings': 'CodeQ prolog terminal proxy', - 'exit': false, - 'clear': false, - 'keypress': function (event, terminal) { - if (promptMode) return true; - setTimeout(function () { - terminal.echo(''); // send newline after semicolon or full-stop - terminal.pause(); - }, 0); - if ((event.which == 32) || (event.which == 59) || (event.which == 110)) { - // space or semicolon or n -> show next answer - event.which = 59; // semicolon - codeq.comms.sendQuery({ - 'problem_id': problem_id, - 'step': 'next', - 'trace': activityHandler.addAndPurge({'typ': 'nxt'}) - }, problem_id).then(tcs, tcf).done(); - } - else { - // everything else: stop searching for answers - event.which = 46; // full stop - codeq.comms.sendQuery({ - 'problem_id': problem_id, - 'step': 'end', - 'trace': activityHandler.addAndPurge({'typ': 'stp'}) - }, problem_id).then(tcs, tcf).done(); - } - } - }); - - return {}; - };*/ - var makePrologTerminalHandler = function (jqConsole, editor, problem_id, activityHandler) { var promptMode = true, // default: query composition; alternative: query result browsing terminal = codeq.makeConsole(jqConsole, { @@ -188,16 +110,11 @@ }; return { - "trace": function (trace) { + 'queueTrace': function (trace) { trace['dt'] = deltaActivityMillis(); - return trace; - }, - 'queue': function (trace) { queue.push(trace); - if (ts === null) setTimeout(timer, 10000); // flush every 10 seconds - }, - 'queueTrace': function (trace) { - this.queue(this.trace(trace)); + if (ts === null) ts = setTimeout(timer, 10000); // flush every 10 seconds + return this; }, 'flush': flush, 'addAndPurge': function (trace) { @@ -228,21 +145,7 @@ jqHints = $('#info'), editor = CodeMirror(jqEditor[0], { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true }), activityHandler = makeActivityHandler(editor, problem.id), -/* controller = jqConsole.console({ - promptLabel: '?- ', - commandValidate: function (line) { - return !!line; - }, - commandHandle: function (line) { - return [{msg:'Not implemented.', className:'console-response'}]; - }, - autofocus: false, - animateScroll: false, - promptHistory: false, - welcomeMessage: 'Prolog REPL.' - }),*/ terminal = makePrologTerminalHandler(jqConsole, editor, problem.id, activityHandler), - /** Object. */ hintDefs = problem.hint, hintCounter = 0, // for generating unique class-names hintCleaners = [], @@ -441,37 +344,7 @@ // $(jqButtons.get(1)).on('click', function () { handler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]); }); // $(jqButtons.get(2)).on('click', function () { handler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]); }); - $('#btn_code_run').on('click', function () { - var doc = editor.getDoc(); -// codeq.comms.sendActivity({'typ': 'slv', 'dt': dt, 'qry': }); -// handler.processServerHints([{id:'list_empty'}]); - }); - $('#btn_code_break').on('click', function () { -// handler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]); - }); $('#btn_code_hint').on('click', function () { -// handler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]); -/* jqConsole.echo('?- hint.'); - jqConsole.pause(); - var doc = editor.getDoc(); - codeq.comms.sendHint({ - 'language': 'prolog', - 'program': editor.getDoc().getValue(), - 'problem_id': problem.id - }).then( - function hintSuccess(data) { - jqConsole.resume(); - if (data.code === 0) - handler.processServerHints(data.hints); - else - jqConsole.error(data.message); - }, - function hintFailed (error) { - jqConsole.resume(); - jqConsole.exception(error); - } - ).done();*/ - terminal.append('hint.\n', 'input'); terminal.inputDisable(); var doc = editor.getDoc(); @@ -498,27 +371,6 @@ .done(); }); $('#btn_code_test').on('click', function () { -/* jqConsole.echo('?- test.'); - jqConsole.pause(); - var doc = editor.getDoc(); - codeq.comms.sendTest({ - 'language': 'prolog', - 'program': editor.getDoc().getValue(), - 'problem_id': problem.id - }).then( - function testSuccess(data) { - jqConsole.resume(); - if (data.code === 0) - handler.processServerHints(data.hints); - else - jqConsole.error(data.message); - }, - function testFailed (error) { - jqConsole.resume(); - jqConsole.exception(error); - } - ).done();*/ - terminal.append('test.\n', 'input'); terminal.inputDisable(); var doc = editor.getDoc(); diff --git a/js/python.js b/js/python.js index 82423c6..11e8a2b 100644 --- a/js/python.js +++ b/js/python.js @@ -72,17 +72,11 @@ }; return { - "trace": function (trace) { + 'queueTrace': function (trace) { trace['dt'] = deltaActivityMillis(); - return trace; - }, - 'queue': function (trace) { queue.push(trace); if (ts === null) setTimeout(timer, 10000); // flush every 10 seconds }, - 'queueTrace': function (trace) { - this.queue(this.trace(trace)); - }, 'flush': flush, 'addAndPurge': function (trace) { var accumulatedTrace = queue; @@ -113,8 +107,6 @@ editor = CodeMirror(jqEditor[0], { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true, mode: 'python' }), activityHandler = makeActivityHandler(editor, problem.id), terminal = makePythonTerminalHandler(jqConsole, editor, problem.id, activityHandler), - - /** Object. */ hintDefs = problem.hint, hintCounter = 0, // for generating unique class-names hintCleaners = [], @@ -313,14 +305,6 @@ // $(jqButtons.get(1)).on('click', function () { handler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]); }); // $(jqButtons.get(2)).on('click', function () { handler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]); }); - $('#btn_code_run').on('click', function () { - var doc = editor.getDoc(); -// codeq.comms.sendActivity({'typ': 'slv', 'dt': dt, 'qry': }); -// handler.processServerHints([{id:'list_empty'}]); - }); - $('#btn_code_break').on('click', function () { -// handler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]); - }); $('#btn_code_hint').on('click', function () { // handler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]); terminal.append('>>> hint\n'); -- cgit v1.2.1