summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/codeq.js98
-rw-r--r--js/codeq/login.js94
2 files changed, 0 insertions, 192 deletions
diff --git a/js/codeq.js b/js/codeq.js
index f54b46e..e6a8a90 100644
--- a/js/codeq.js
+++ b/js/codeq.js
@@ -724,102 +724,4 @@ window.phandler = null; // TODO: this is for debug only
return n;
};
- codeq.urlPrefix = '/svc/';
-
-// $(document).ready
- var deprecated = (function () {
-// var s = location.hash;
-// if (s.length == 0) return; // empty hash
-// if (s.charAt(0) == '#') s = s.substring(1);
-// if (s.length == 0) return; // empty hash
-
-/* $('#console').terminal(function (command, term) {
- term.echo('Not implemented.');
- }, {
- prompt: '?- ',
- history: false,
- greetings: 'Prolog terminal',
- outputLimit: 7,
- exit: false,
- name: 'prolog_cmd',
- width: '100%'
- });*/
-
- var hash = location.hash,
- error = false,
- params, param, sid, lang, grp, prb, i, key, j;
-
- if (hash.length < 2) {
- error = 'No execution parameters were provided';
- }
- else {
- location.hash = '';
- if (hash.charAt(0) == '#') hash = hash.substring(1);
- params = hash.split('/');
- for (i = params.length - 1; i >= 0; i--) {
- param = params[i];
- j = param.indexOf('=');
- if (j < 0) continue;
- key = param.substring(0, j);
- switch (key) {
- case 'sid':
- sid = param.substring(j+1);
- break;
- case 'lang':
- lang = param.substring(j+1);
- break;
- case 'grp':
- grp = param.substring(j+1);
- break;
- case 'prb':
- prb = param.substring(j+1);
- break;
- }
- }
- if (!sid) error = 'No session ID provided';
- else if (!grp) error = 'No problem group provided';
- else if (!prb) error = 'No problem provided';
- }
-
- if (error) {
- alert(error);
- }
- else {
- codeq.sid = sid;
-/* codeq.system.load({
- type: 'text',
- url: '/prolog/problems/' + grp + '/' + prb + '/en.py',
- callback: function (data, status, url) {
- if (!data) return;
- var info = codeq.parseDefinition(data);
- window.phandler = codeq.createPrologHandler(info, grp, prb); // 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']}]);
- }
- });*/
- codeq.comms.getProblem(lang, grp, prb).then(
- function getProblemOK (data) {
- if (data.code == 0) {
- 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);
- }
- },
- function getProblemFail (error) {
- alert('' + error);
- }
- ).done();
- }
- });
})();
diff --git a/js/codeq/login.js b/js/codeq/login.js
deleted file mode 100644
index ef67304..0000000
--- a/js/codeq/login.js
+++ /dev/null
@@ -1,94 +0,0 @@
-(function(){
- var urlPrefix = '/svc/';
-
- $(document).ready(function () {
-
- $.ajax({
- 'type': 'POST',
- 'url': urlPrefix + 'list_problems',
- 'accepts': 'application/json',
- 'contentType': 'application/json; charset=UTF-8',
- 'data': JSON.stringify({}),
- 'processData': false,
- 'dataType': 'json',
- 'error': function loginErrorHandler(jqXHR, textStatus, errorThrown) {
- $('#disabled').css('cursor', '');
- alert('Request to obtain list of problems failed: ' + (errorThrown || textStatus));
- },
- 'success': function loginSuccessHandler(data, textStatus, jqXHR) {
- var i, groups, group, problems, problem, first_group,
- jqGroup = $('#problem_group'),
- jqProblems = $('#problems'),
- html = [],
- mapping = {},
- onGroupChange = function () {
- var problems = mapping[jqGroup.val()],
- html = [],
- i, p;
- if (problems) {
- for (i = 0; i < problems.length; i++) {
- p = problems[i];
- html.push('<option value="', p.identifier, '">', p.name, '</option>\n')
- }
- }
- jqProblems.html(html.join(''));
- };
-
- if (data && (data.code === 0)) {
- $('#disabled').css('display', 'none');
- groups = data.problems;
- for (i = 0; i < groups.length; i++) {
- group = groups[i];
- var identifier = group.identifier.language + '/' + group.identifier.group;
- var name = group.name.language + ': ' + group.name.group;
- html.push('<option value="', identifier, '">', name, '</option>\n');
- mapping[identifier] = group.problems;
- }
- jqGroup.html(html.join(''));
- first_group = html[1];
- html = null;
-
- jqGroup.on('click', onGroupChange);
- jqGroup.val(first_group);
- onGroupChange();
-
- $("#submit").on('click', function () {
- var identifier = $('#problem_group').val().split('/'),
- problem = $('#problems').val();
- if (identifier.length < 2) alert('Choose a problem group');
- else if (!problem) alert('Choose a problem');
- else {
- $.ajax({
- 'type': 'POST',
- 'url': urlPrefix + 'login',
- 'accepts': 'application/json',
- 'contentType': 'application/json; charset=UTF-8',
- 'data': JSON.stringify({
- 'username': $('#username').val(),
- 'password': $('#password').val()
- }),
- 'processData': false,
- 'dataType': 'json',
- 'error': function loginErrorHandler(jqXHR, textStatus, errorThrown) {
- alert('Request for login failed: ' + (errorThrown || textStatus));
- },
- 'success': function loginSuccessHandler(data, textStatus, jqXHR) {
- if (data && (data.code === 0)) {
- 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);
- }
- }
- });
- }
- });
- }
- else {
- $('#disabled').css('cursor', '');
- alert('Obtaining list of problems failed: code=' + data.code + ', reason=' + data.message);
- }
- }
- });
- });
-})();