summaryrefslogtreecommitdiff
path: root/js/codeq/prolog.js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-18 16:24:32 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-18 16:24:32 +0200
commitffeb1a12491780d489d96dd7159a09b5fd16090c (patch)
treefc3e83f2c56799d6855d05b91c49574cdaf3c6ff /js/codeq/prolog.js
parentb9ff4650857cc34a795613281d576196345359ee (diff)
Add "Plan" button to display next "planning" hint
Diffstat (limited to 'js/codeq/prolog.js')
-rw-r--r--js/codeq/prolog.js15
1 files changed, 13 insertions, 2 deletions
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
+})();