summaryrefslogtreecommitdiff
path: root/js/codeq.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq.js')
-rw-r--r--js/codeq.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/js/codeq.js b/js/codeq.js
index 770153e..e867ffd 100644
--- a/js/codeq.js
+++ b/js/codeq.js
@@ -1,6 +1,17 @@
// introduce the namespace object for codeq
window.codeq = {};
window.siteDefinition = { logLevel: 'debug' }; // for debug purposes
+window.phandler = null; // TODO: this is for debug only
+
+// type definitions, so the IDE and coders have easier work
+/**
+ * @typedef {Object} ServerHint a hint sent by the server
+ * @property {string} id the hint ID
+ * @property {Object} args optional arguments for the hint in case of a pop-up or static hint
+ * @property {string[]} choices array of choices in case of a drop-down hint
+ * @property {number} start the starting position of the highlighted code, in case of a pop-up or drop-down hint
+ * @property {number} end the ending position of the highlighted code, in case of a pop-up or drop-down hint
+ */
(function () {
@@ -700,8 +711,6 @@ window.siteDefinition = { logLevel: 'debug' }; // for debug purposes
// if (s.length == 0) return; // empty hash
// if (s.charAt(0) == '#') s = s.substring(1);
// if (s.length == 0) return; // empty hash
- var editor = CodeMirror(document.getElementById('code_editor'), { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true });
- editor.setValue('sister(X, Y) :-\n female(X),\n parent(Z, X),\n parent(Z, Y),\n X \\== Y.');
/* $('#console').terminal(function (command, term) {
term.echo('Not implemented.');
@@ -715,27 +724,16 @@ window.siteDefinition = { logLevel: 'debug' }; // for debug purposes
width: '100%'
});*/
- var controller = $('#console').console({
- promptLabel: '?- ',
- commandValidate: function (line) {
- return !!line;
- },
- commandHandle: function (line) {
- return [{msg:'Not implemented.', className:'console-response'}];
- },
- autofocus: false,
- animateScroll: false,
- promptHistory: false,
- welcomeMessage: 'Prolog REPL.'
- });
-
codeq.system.load({
type: 'text',
url: 'sister.py',
callback: function (data, status, url) {
if (!data) return;
var info = codeq.parseDefinition(data);
- $('#description').html(info.description);
+ window.phandler = codeq.createPrologHandler(info); // TODO: for debug only
+ // DEBUG: phandler.processServerHints([{id:'x_must_be_female'}]);
+ // DEBUG: phandler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]);
+ // DEBUG: phandler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]);
}
});
};