From 540d0e239c9b7dc5bee8a3e53bcf6ec0767ee80b Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 12 Sep 2016 22:14:58 -0700 Subject: [PATCH] Cleanup --- ext/bg/js/util.js | 13 +++++++++++++ ext/bg/js/yomichan.js | 13 +------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 97906eda..5583502d 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -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) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index d9d4234d..26b28138 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -20,18 +20,7 @@ class Yomichan { constructor() { Handlebars.partials = Handlebars.templates; - Handlebars.registerHelper('kanjiLinks', function(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; - }); + Handlebars.registerHelper('kanjiLinks', kanjiLinks); this.translator = new Translator(); this.asyncPools = {};