summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-15 12:29:12 +0200
committerAleš Smodiš <aless@guru.si>2015-09-15 12:29:12 +0200
commit39fa66c8602bad9278d6683b35e0be6cc1ab92cc (patch)
treec66b74a946f51527fc051f33c102ea1affdbe5d4 /js/codeq
parent43b3578dd8bf93cbfca7f5203175ac6dda6ec412 (diff)
Remove the old code: old communication, separate prolog and python pages.
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/login.js94
1 files changed, 0 insertions, 94 deletions
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);
- }
- }
- });
- });
-})();