diff options
| author | Alex Yatskov <alex@foosoft.net> | 2017-03-02 20:23:56 -0800 | 
|---|---|---|
| committer | Alex Yatskov <alex@foosoft.net> | 2017-03-02 20:23:56 -0800 | 
| commit | 5ecca4627e4edd54b8af606c69aa51e4b659deef (patch) | |
| tree | 3ef86e9408c6050a895c966704bd17b307e1ce55 /ext/bg/js/util.js | |
| parent | b9c849a02078a5d6b99a0650b1ef3373232dc0c4 (diff) | |
enable and disable via toggle switch
Diffstat (limited to 'ext/bg/js/util.js')
| -rw-r--r-- | ext/bg/js/util.js | 38 | 
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; |