This commit is contained in:
Alex Yatskov 2016-09-12 22:14:58 -07:00
parent 4241b4f859
commit 540d0e239c
2 changed files with 14 additions and 12 deletions

View File

@ -17,6 +17,19 @@
*/ */
function kanjiLinks(options) {
let result = '';
for (const c of options.fn(this)) {
if (isKanji(c)) {
result += Handlebars.templates['kanji-link.html']({kanji: c}).trim();
} else {
result += c;
}
}
return result;
}
function loadJson(url) { function loadJson(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();

View File

@ -20,18 +20,7 @@
class Yomichan { class Yomichan {
constructor() { constructor() {
Handlebars.partials = Handlebars.templates; Handlebars.partials = Handlebars.templates;
Handlebars.registerHelper('kanjiLinks', function(options) { Handlebars.registerHelper('kanjiLinks', kanjiLinks);
let result = '';
for (const c of options.fn(this)) {
if (isKanji(c)) {
result += Handlebars.templates['kanji-link.html']({kanji: c}).trim();
} else {
result += c;
}
}
return result;
});
this.translator = new Translator(); this.translator = new Translator();
this.asyncPools = {}; this.asyncPools = {};