summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-01 16:34:23 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-01 16:34:23 +0200
commit52d9ebc1b0d7b46d19cf1a59b39c52f80a3285d7 (patch)
tree9ceb4d83b22095350d8861c26234c563bb3be82d /js
parent63ed43e8a0fbe5f8d17fe67b2b262356eeb5c47c (diff)
Send the language as a request parameter
Diffstat (limited to 'js')
-rw-r--r--js/codeq.js18
-rw-r--r--js/codeq/login.js2
-rw-r--r--js/prolog.js2
3 files changed, 18 insertions, 4 deletions
diff --git a/js/codeq.js b/js/codeq.js
index a08d207..ed59e4e 100644
--- a/js/codeq.js
+++ b/js/codeq.js
@@ -746,7 +746,7 @@ window.phandler = null; // TODO: this is for debug only
var hash = location.hash,
error = false,
- params, param, sid, grp, prb, i, key, j;
+ params, param, sid, lang, grp, prb, i, key, j;
if (hash.length < 2) {
error = 'No execution parameters were provided';
@@ -764,6 +764,9 @@ window.phandler = null; // TODO: this is for debug only
case 'sid':
sid = param.substring(j+1);
break;
+ case 'lang':
+ lang = param.substring(j+1);
+ break;
case 'grp':
grp = param.substring(j+1);
break;
@@ -794,10 +797,19 @@ window.phandler = null; // TODO: this is for debug only
// DEBUG: phandler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]);
}
});*/
- codeq.comms.getProblem('prolog', grp, prb).then(
+ codeq.comms.getProblem(lang, grp, prb).then(
function getProblemOK (data) {
if (data.code == 0) {
- window.phandler = codeq.createPrologHandler(data.data, grp, prb); // TODO: assignment to window for debug only
+ switch (lang) {
+ case 'prolog':
+ // TODO: assignment to window for debug only
+ window.phandler = codeq.createPrologHandler(data.data, grp, prb);
+ break;
+ case 'python':
+ // TODO: assignment to window for debug only
+ window.phandler = codeq.createPythonHandler(data.data, grp, prb);
+ break;
+ }
}
else {
alert(data.message);
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 8135506..e1daadf 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -74,7 +74,7 @@
},
'success': function loginSuccessHandler(data, textStatus, jqXHR) {
if (data && (data.code === 0)) {
- window.location = identifier[0] + '.html#sid=' + data.sid + '/grp=' + identifier[1] + '/prb=' + problem;
+ window.location = identifier[0] + '.html#sid=' + data.sid + '/lang=' + identifier[0] + '/grp=' + identifier[1] + '/prb=' + problem;
}
else {
alert('Login failed: code=' + data.code + ', reason=' + data.message);
diff --git a/js/prolog.js b/js/prolog.js
index 72687c3..7fe73fd 100644
--- a/js/prolog.js
+++ b/js/prolog.js
@@ -362,6 +362,7 @@
jqConsole.pause();
var doc = editor.getDoc();
codeq.comms.sendHint({
+ 'language': 'prolog',
'program': editor.getDoc().getValue(),
'problem_id': problem.id
}).then(
@@ -383,6 +384,7 @@
jqConsole.pause();
var doc = editor.getDoc();
codeq.comms.sendTest({
+ 'language': 'prolog',
'program': editor.getDoc().getValue(),
'problem_id': problem.id
}).then(