diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/problem.js | 20 |
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>'); } |