From 6893733a646d9e697b85feef39dc047c70dd601c Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 18 Nov 2015 19:28:03 +0100 Subject: Add support for tabkey and accesskey navigation --- js/codeq/language.js | 13 +++++++------ js/codeq/problem_list.js | 9 ++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/language.js b/js/codeq/language.js index b861560..e86b09e 100644 --- a/js/codeq/language.js +++ b/js/codeq/language.js @@ -7,16 +7,17 @@ jqProlog = $('#choose-prolog'), jqPython = $('#choose-python'), jqRobot = $('#choose-robot'), - chooseProlog = function () {codeq.globalStateMachine.transition('problem_list', 'prolog');}, - choosePython = function () {codeq.globalStateMachine.transition('problem_list', 'python');}, - chooseRobot = function () {codeq.globalStateMachine.transition('problem_list', 'robot');}; + choose = function (language) { + codeq.globalStateMachine.transition('problem_list', language); + return false; + }; codeq.globalStateMachine.register('language',{ 'enter': function(){ jqScreen.css('display', ''); - jqProlog.on('click', chooseProlog); - jqPython.on('click', choosePython); - jqRobot.on('click', chooseRobot); + jqProlog.on('click', function () { return choose('prolog') }); + jqPython.on('click', function () { return choose('python') }); + jqRobot.on('click', function () { return choose('robot') }); }, 'exit' : function(){ jqProlog.off(); diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js index 853c8cb..cc9e716 100644 --- a/js/codeq/problem_list.js +++ b/js/codeq/problem_list.js @@ -200,7 +200,8 @@ Ngroups = groups.length, html = [], problemReferences = [], - group, problems, Nproblems, problem, i, j; + group, problems, Nproblems, problem, i, j, nrefs, + baseTabIndex = 200; // tabindex attribute of the first problem link var langDict = convertTranslations(rawTranslations, 'name', 'description'), // this will be the resulting dictionary: multi-level keys that lead up to the lang-dict groupDict, problemDict; // title: HTML structure for "name" and "desc" @@ -218,9 +219,10 @@ problems = group.problems || []; Nproblems = problems.length; for (j = 0; j < Nproblems; j++) { + nrefs = problemReferences.length; problem = problems[j] || {}; problemDict = convertTranslations(problem.translations, 'name'); - html.push('
  • '); + html.push('
  • '); problemReferences.push({'g': group.identifier || 'nogroup', 'p': problem.identifier || 'noproblem', 'id': problem.id}); } html.push(''); @@ -254,7 +256,7 @@ ref = data.refs[index]; if (!ref) { codeq.log.error('Clicked on a problem link having erroneous index: ' + index); - return; + return false; } codeq.wait( Q.all([ @@ -272,6 +274,7 @@ alert('Failed to obtain the problem definition: ' + reason); }) .done(); + return false; }); }, -- cgit v1.2.1