From 1dbb01a159d646a59f4e79277edd864a18570c0e Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 28 Aug 2015 17:45:35 +0200 Subject: Add initial support for hints --- js/codeq/comms.js | 5 +++++ js/prolog.js | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'js') 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); } -- cgit v1.2.1