From ffeb1a12491780d489d96dd7159a09b5fd16090c Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 18 Sep 2015 16:24:32 +0200 Subject: Add "Plan" button to display next "planning" hint --- js/codeq/prolog.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'js/codeq/prolog.js') diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index 96c3077..4eed354 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -95,9 +95,11 @@ * add the above function to the buttons */ addClickListenerTranstions = function(){ + $('#btn_code_plan').on('click',clickListenerTransitionFun); $('#btn_code_hint').on('click',clickListenerTransitionFun); $('#btn_code_test').on('click',clickListenerTransitionFun); + $('#btn_code_plan').on(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_hint').on(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_test').on(transitionEventName,mouseDownEventIgnoreFun); }, @@ -105,9 +107,11 @@ * and a function to remove it */ removeClickListenerTransition = function(){ + $('#btn_code_plan').off('click',clickListenerTransitionFun); $('#btn_code_hint').off('click',clickListenerTransitionFun); $('#btn_code_test').off('click',clickListenerTransitionFun); + $('#btn_code_plan').off(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_hint').off(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_test').off(transitionEventName,mouseDownEventIgnoreFun); }, @@ -362,11 +366,12 @@ editor = CodeMirror(jqEditor[0], { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true }), activityHandler = makeActivityHandler(editor, problem.id), terminal = makePrologTerminalHandler(jqConsole, editor, problem.id, activityHandler), - hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint); + hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint, problem.plan); editor.setValue(info.solution); $('#title').text(problem.slug); jqDescription.html(problem.description); + $('#btn_code_plan').prop('disabled', problem.plan.length == 0); editor.on('change', function (instance, changeObj) { var doc = editor.getDoc(), @@ -381,6 +386,12 @@ } }); + $('#btn_code_plan').on('click', function () { + if (!hinter.planNext()) { + $('#btn_code_plan').prop('disabled', true); + $('#btn_code_plan').blur(); + } + }); $('#btn_code_hint').on('click', function () { terminal.append('hint.\n', 'input'); terminal.inputDisable(); @@ -451,4 +462,4 @@ } }; }; -})(); \ No newline at end of file +})(); -- cgit v1.2.1 From da92df9761b52f6d24d2241080121cc5bef5e932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 16:41:12 +0200 Subject: Don't crash loading a prolog problem, if the problem has no plan set. --- js/codeq/prolog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/codeq/prolog.js') diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index 4eed354..be4791a 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -371,7 +371,7 @@ editor.setValue(info.solution); $('#title').text(problem.slug); jqDescription.html(problem.description); - $('#btn_code_plan').prop('disabled', problem.plan.length == 0); + $('#btn_code_plan').prop('disabled', (problem.plan || '').length == 0); editor.on('change', function (instance, changeObj) { var doc = editor.getDoc(), -- cgit v1.2.1 From 45e1dc64a3f36222eb775a00157f587ebdaabd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 16:41:40 +0200 Subject: Enable auto-history in prolog console. --- js/codeq/prolog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/codeq/prolog.js') diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index be4791a..e411bc4 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -227,7 +227,8 @@ var promptMode = true, // default: query composition; alternative: query result browsing manualStop = false,// if the user stopped showing next answers (false) or if there are no more answers (true) terminal = codeq.makeConsole(jqConsole, { - 'greeting': 'CodeQ Prolog terminal proxy' + 'greeting': 'CodeQ Prolog terminal proxy', + 'autoHistory': true }), tcs = function terminalCommandSuccess (data) { var t, lines, i; -- cgit v1.2.1