aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js38
1 files changed, 19 insertions, 19 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index ec562f9f..852dfac7 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -17,7 +17,12 @@
*/
-function kanjiLinks(options) {
+function helperKanjiLinks(options) {
+ const isKanji = c => {
+ const code = c.charCodeAt(0);
+ return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;
+ };
+
let result = '';
for (const c of options.fn(this)) {
if (isKanji(c)) {
@@ -30,27 +35,10 @@ function kanjiLinks(options) {
return result;
}
-function multiLine(options) {
+function helperMultiLine(options) {
return options.fn(this).split('\n').join('<br>');
}
-function isKanji(c) {
- const code = c.charCodeAt(0);
- return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;
-}
-
-function enabledDicts(options) {
- const dictionaries = {};
- for (const title in options.dictionaries) {
- const dictionary = options.dictionaries[title];
- if (dictionary.enabled) {
- dictionaries[title] = dictionary;
- }
- }
-
- return dictionaries;
-}
-
function promiseCallback(promise, callback) {
return promise.then(result => {
callback({result});
@@ -62,6 +50,18 @@ function promiseCallback(promise, callback) {
});
}
+function getYomichan() {
+ return chrome.extension.getBackgroundPage().yomichan;
+}
+
+function getDatabase() {
+ return getYomichan().translator.database;
+}
+
+function getAnki() {
+ return getYomichan().anki;
+}
+
function sortTermDefs(definitions, dictionaries=null) {
return definitions.sort((v1, v2) => {
const sl1 = v1.source.length;