summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/codeq/comms.js5
-rw-r--r--js/prolog.js21
2 files changed, 25 insertions, 1 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js
index c2ad715..8b89cde 100644
--- a/js/codeq/comms.js
+++ b/js/codeq/comms.js
@@ -121,6 +121,11 @@
return send('query', query);
},
+ sendHint: function commsSendHint (json) {
+ json['sid'] = codeq.sid;
+ return send('hint', json);
+ },
+
sendTest: function commsSendTest (json) {
json['sid'] = codeq.sid;
return send('test', json);
diff --git a/js/prolog.js b/js/prolog.js
index 089f63e..a377cc9 100644
--- a/js/prolog.js
+++ b/js/prolog.js
@@ -353,6 +353,25 @@
});
$('#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({
+ '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();
});
$('#btn_code_test').on('click', function () {
jqConsole.echo('?- test.');
@@ -376,7 +395,7 @@
jqConsole.error(data.message);
}
},
- tf = function testFailed (error) {
+ function testFailed (error) {
jqConsole.resume();
jqConsole.exception(error);
}