diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-28 17:45:35 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-28 17:45:35 +0200 |
commit | 1dbb01a159d646a59f4e79277edd864a18570c0e (patch) | |
tree | 9131e9ccba0e1c4eef81282124d2a8852b850854 /js | |
parent | 44e18811b945ecac5f2b4ed1613ce4d974473e16 (diff) |
Add initial support for hints
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/comms.js | 5 | ||||
-rw-r--r-- | js/prolog.js | 21 |
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); } |