summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html2
-rw-r--r--js/prolog.js154
-rw-r--r--js/python.js18
3 files changed, 4 insertions, 170 deletions
diff --git a/index.html b/index.html
index fb8342a..0f5105d 100644
--- a/index.html
+++ b/index.html
@@ -89,8 +89,6 @@
<div class="col-lg-3 col-md-6 col-sm-12 block">
<nav class="navbar navbar-default" id="block-toolbar">
<div class="container-fluid">
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_run">Run</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_break">Break</button>
<button type="button" class="btn btn-default navbar-btn" id="btn_code_hint">Hint</button>
<button type="button" class="btn btn-default navbar-btn" id="btn_code_test">Test</button>
</div>
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.<string, HintDefinition> */
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.<string, HintDefinition> */
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');