summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-29 14:13:38 +0200
committerAleš Smodiš <aless@guru.si>2015-09-29 14:13:38 +0200
commit22cb497f9ed19548e30a4c86dd99aaa91fd4b344 (patch)
treef2413a8dd5ef820939ef6d5643ee5c2b2da18e4b /js
parent99961c6b5d72f516061e4f8b3dc31e3fccc827ee (diff)
Changes to process language.js files with ordered problems (arrays instead of dictionaries).
Diffstat (limited to 'js')
-rw-r--r--js/codeq/problem.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/js/codeq/problem.js b/js/codeq/problem.js
index 464dc12..7ae54d8 100644
--- a/js/codeq/problem.js
+++ b/js/codeq/problem.js
@@ -151,10 +151,11 @@
createLanguageData = function (data, languageIdentifier) { // data is the content of language.json
var li = languageIdentifier, // a shorthand
rawTranslations = data.translations || {},
- groups = data.groups || {},
+ groups = data.groups || [],
+ Ngroups = groups.length,
html = [],
problemReferences = [],
- groupIdentifier, group, problems, problemIdentifier, problem;
+ group, problems, Nproblems, problem, i, j;
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"
@@ -162,22 +163,21 @@
html.push('<div class="language-description translatable" ', ta(langDict.description), '></div>');
// content: problem directory
html.push('<ul class="language-problems">');
- for (groupIdentifier in groups) {
- if (!groups.hasOwnProperty(groupIdentifier)) continue;
- group = groups[groupIdentifier] || {};
+ for (i = 0; i < Ngroups; i++) {
+ group = groups[i] || {};
groupDict = convertTranslations(group.translations, 'name', 'description'); // the group-level translations, added will
// group content
html.push('<li><div class="group-title translatable" ', ta(groupDict.name), '></div>');
html.push('<div class="group-description translatable" ', ta(groupDict.description), '></div>');
html.push('<ul class="group-problems">');
// problem content
- problems = group.problems || {};
- for (problemIdentifier in problems) {
- if (!problems.hasOwnProperty(problemIdentifier)) continue;
- problem = problems[problemIdentifier] || {};
+ problems = group.problems || [];
+ Nproblems = problems.length;
+ for (j = 0; j < Nproblems; j++) {
+ problem = problems[j] || {};
problemDict = convertTranslations(problem.translations, 'name');
html.push('<li><a class="problem-', '' + problemReferences.length, ' translatable" ', ta(problemDict.name), '></a></li>');
- problemReferences.push({'g': groupIdentifier, 'p': problemIdentifier, 'id': problem.id});
+ problemReferences.push({'g': group.identifier || 'nogroup', 'p': problem.identifier || 'noproblem', 'id': problem.id});
}
html.push('</ul></li>');
}