}
var template = this.team.loadTemplate(this.config.template || "Ranking");
- console.log(output);
this.node.html(template(output));
});
}
for (var k in mkws.locale_lang) {
- if (toBeIncluded[k] || lang_options.length == 0)
- list.push(k);
+ if (toBeIncluded[k] || lang_options.length == 0) {
+ cur = {};
+ if (lang === k) cur.selected = true;
+ cur.code = k;
+ cur.url = lang_url(k);
+ list.push(cur);
+ }
}
// add english link
- if (lang_options.length == 0 || toBeIncluded[lang_default])
- list.push(lang_default);
+ if (lang_options.length == 0 || toBeIncluded[lang_default]) {
+ cur = {};
+ if (lang === lang_default) cur.selected = true;
+ cur.code = lang_default;
+ cur.url = lang_url(lang_default);
+ list.push(cur);
+ }
this.log("language menu: " + list.join(", "));
- /* the HTML part */
- var data = "";
- for (var i = 0; i < list.length; i++) {
- var l = list[i];
- if (data)
- data += ' | ';
-
- if (lang == l) {
- data += ' <span>' + l + '</span> ';
- } else {
- data += ' <a href="' + lang_url(l) + '">' + l + '</a> '
- }
- }
-
- this.node.html(data);
+ var template = this.team.loadTemplate(this.config.template || "Lang");
+ this.node.html(template({languages: list}));
this.hideWhenNarrow();
-
// set or re-set "lang" URL parameter
function lang_url(lang) {
var query = location.search;
--- /dev/null
+{{!
+Language selection widget
+
+languages
+ code - two character language identifier
+ selected - exists for the current language
+ url - url to switch to this language
+}}
+{{#each languages}}
+ {{~#if selected~}}
+ <span>{{code}}</span>
+ {{~else~}}
+ <a href="{{{url}}}">{{code}}</a>
+ {{~/if~}}
+ {{#unless last}}
+ |
+ {{/unless}}
+{{/each}}
+