summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/codeq/problem_list.js9
-rw-r--r--js/codeq/prolog.js2
-rw-r--r--js/codeq/python.js2
-rw-r--r--js/codeq/robot.js2
-rw-r--r--js/codeq/template.js10
5 files changed, 23 insertions, 2 deletions
diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js
index 1384066..e28e672 100644
--- a/js/codeq/problem_list.js
+++ b/js/codeq/problem_list.js
@@ -221,6 +221,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
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;
+
+ codeq.template.processDictionary(langDict.description, [languageIdentifier]);
+
// title: HTML structure for "name" and "desc"
html.push('<h1 class="language-title" ', ta(langDict.name), '></h1><hr>');
html.push('<p class="language-description" ', ta(langDict.description), '></p>');
@@ -228,9 +231,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
for (i = 0; i < Ngroups; i++) {
group = groups[i] || {};
groupDict = convertTranslations(group.translations, 'name', 'description'); // the group-level translations, added will
+ codeq.template.processDictionary(groupDict.description,
+ [languageIdentifier, group.identifier]);
// group content
html.push('<h2 class="group-title" ', ta(groupDict.name), '></h2>');
- html.push('<p class="group-description" ', ta(groupDict.description), '></p>');
+ html.push('<div class="group-description" ', ta(groupDict.description), '></div>');
html.push('<ul class="group-problems">');
// problem content
problems = group.problems || [];
@@ -268,7 +273,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
var language = data.language;
jqScreen.html(data.html);
codeq.tr.translateDom(jqScreen);
- jqScreen.find('a').on('click', function (e) {
+ jqScreen.find('.group-problems a').on('click', function (e) {
var index = +$(this).attr('class').split(' ')[0].split('-')[1],
ref = data.refs[index];
e.preventDefault();
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index 1d2f92e..a3779d7 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -275,6 +275,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
alert(error);
};
+ codeq.template.processDictionary(problemDef.translations.description,
+ [problemDef.language, problemDef.group, problemDef.problem]);
codeq.tr.registerDictionary('prolog', problemDef.translations);
codeq.tr.translateDom(jqScreen);
jqBtnPlan.prop('disabled', !hinter.hasNextPlan());
diff --git a/js/codeq/python.js b/js/codeq/python.js
index d688c7c..c28ee53 100644
--- a/js/codeq/python.js
+++ b/js/codeq/python.js
@@ -239,6 +239,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
alert(error);
};
+ codeq.template.processDictionary(problemDef.translations.description,
+ [problemDef.language, problemDef.group, problemDef.problem]);
codeq.tr.registerDictionary('python', problemDef.translations);
codeq.tr.translateDom(jqScreen);
jqBtnPlan.prop('disabled', !hinter.hasNextPlan());
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index 15067b1..7f67025 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -239,6 +239,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
});
+ codeq.template.processDictionary(problemDef.translations.description,
+ [problemDef.language, problemDef.group, problemDef.problem]);
codeq.tr.registerDictionary('robot', problemDef.translations);
codeq.tr.translateDom(jqScreen);
jqBtnPlan.prop('disabled', !hinter.hasNextPlan());
diff --git a/js/codeq/template.js b/js/codeq/template.js
index 361811b..90b4db3 100644
--- a/js/codeq/template.js
+++ b/js/codeq/template.js
@@ -276,9 +276,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
resources = newResources;
},
+ // instantiate a template
'process': function (template, templatePath, args) {
var fn = templator(template, templatePath);
return fn(args);
+ },
+
+ // instantiate templates in a lang→template dictionary
+ 'processDictionary': function (dict, templatePath, args) {
+ var lang;
+ for (lang in dict) {
+ if (!dict.hasOwnProperty(lang)) continue;
+ dict[lang] = codeq.template.process(dict[lang], templatePath, args);
+ }
}
};
})();