diff options
89 files changed, 438 insertions, 375 deletions
| diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1d7e60d4..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "ext/bg/lang/data"] -	path = ext/bg/lang/data -	url = https://FooSoft@bitbucket.org/FooSoft/yomichan-data.git @@ -1,4 +1,4 @@ -Copyright 2016-2020 Alex Yatskov +Copyright 2016-2020  Yomichan Authors  This program is free software: you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by @@ -81,6 +81,8 @@ primary language is not English, you may consider also importing the English ver      *   [kanjidic\_spanish.zip](https://foosoft.net/projects/yomichan/dl/dict/kanjidic_spanish.zip)  *   **[Innocent Corpus](https://forum.koohii.com/post-168613.html#pid168613)** (Term and Kanji frequencies across 5000+ novels)      *   [innocent\_corpus.zip](https://foosoft.net/projects/yomichan/dl/dict/innocent_corpus.zip) +*   **[Kanjium](https://github.com/mifunetoshiro/kanjium)** (Pitch dictionary, see [related project page](https://github.com/toasted-nutbread/yomichan-pitch-accent-dictionary) for details) +    *   [kanjium_pitch_accents.zip](https://foosoft.net/projects/yomichan/dl/dict/kanjium_pitch_accents.zip)  ## Basic Usage ## @@ -322,6 +324,22 @@ Developing Yomichan requires a significant understanding of Japanese sentence st  to invest in learning yet another language; therefore other languages will not be supported. I will also not accept  pull request containing this functionality, as I will ultimately be the one maintaining your code. +## Legal ## + +Required licensing notices for this project follow below: + +*   **EDRDG License** + +    This package uses the [EDICT](https://www.edrdg.org/jmdict/edict.html) and +    [KANJIDIC](https://www.edrdg.org/wiki/index.php/KANJIDIC_Project) dictionary files. These files are the property of +    the [Electronic Dictionary Research and Development Group](https://www.edrdg.org/), and are used in conformance with +    the Group's [license](https://www.edrdg.org/edrdg/licence.html). + +*   **Kanjium License** + +    The pitch accent notation, verb particle data, phonetics, homonyms and other additions or modifications to EDICT, +    KANJIDIC or KRADFILE were provided by Uros Ozvatic through his free database. +  ## Screenshots ##  [](https://foosoft.net/projects/yomichan/img/ss-terms.png) diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css index 6344bd38..f55082e7 100644 --- a/ext/bg/css/settings.css +++ b/ext/bg/css/settings.css @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index da1f1ce0..4f9e694d 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -388,7 +388,8 @@                                      "convertNumericCharacters",                                      "convertAlphabeticCharacters",                                      "convertHiraganaToKatakana", -                                    "convertKatakanaToHiragana" +                                    "convertKatakanaToHiragana", +                                    "collapseEmphaticSequences"                                  ],                                  "properties": {                                      "convertHalfWidthCharacters": { @@ -415,6 +416,11 @@                                          "type": "string",                                          "enum": ["false", "true", "variant"],                                          "default": "variant" +                                    }, +                                    "collapseEmphaticSequences": { +                                        "type": "string", +                                        "enum": ["false", "true", "full"], +                                        "default": "false"                                      }                                  }                              }, diff --git a/ext/bg/js/anki-note-builder.js b/ext/bg/js/anki-note-builder.js index 244aaab8..8a707006 100644 --- a/ext/bg/js/anki-note-builder.js +++ b/ext/bg/js/anki-note-builder.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index a70388bd..c7f7c0cc 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/audio-uri-builder.js b/ext/bg/js/audio-uri-builder.js index 158006bb..dfd195d8 100644 --- a/ext/bg/js/audio-uri-builder.js +++ b/ext/bg/js/audio-uri-builder.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2017-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2017-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/backend-api-forwarder.js b/ext/bg/js/backend-api-forwarder.js index 170a6b32..93db77d7 100644 --- a/ext/bg/js/backend-api-forwarder.js +++ b/ext/bg/js/backend-api-forwarder.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 1fa7ede1..be8ea322 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -77,33 +76,33 @@ class Backend {          this.messageToken = yomichan.generateId(16);          this._messageHandlers = new Map([ -            ['yomichanCoreReady', this._onApiYomichanCoreReady.bind(this)], -            ['optionsSchemaGet', this._onApiOptionsSchemaGet.bind(this)], -            ['optionsGet', this._onApiOptionsGet.bind(this)], -            ['optionsGetFull', this._onApiOptionsGetFull.bind(this)], -            ['optionsSet', this._onApiOptionsSet.bind(this)], -            ['optionsSave', this._onApiOptionsSave.bind(this)], -            ['kanjiFind', this._onApiKanjiFind.bind(this)], -            ['termsFind', this._onApiTermsFind.bind(this)], -            ['textParse', this._onApiTextParse.bind(this)], -            ['textParseMecab', this._onApiTextParseMecab.bind(this)], -            ['definitionAdd', this._onApiDefinitionAdd.bind(this)], -            ['definitionsAddable', this._onApiDefinitionsAddable.bind(this)], -            ['noteView', this._onApiNoteView.bind(this)], -            ['templateRender', this._onApiTemplateRender.bind(this)], -            ['commandExec', this._onApiCommandExec.bind(this)], -            ['audioGetUri', this._onApiAudioGetUri.bind(this)], -            ['screenshotGet', this._onApiScreenshotGet.bind(this)], -            ['forward', this._onApiForward.bind(this)], -            ['frameInformationGet', this._onApiFrameInformationGet.bind(this)], -            ['injectStylesheet', this._onApiInjectStylesheet.bind(this)], -            ['getEnvironmentInfo', this._onApiGetEnvironmentInfo.bind(this)], -            ['clipboardGet', this._onApiClipboardGet.bind(this)], -            ['getDisplayTemplatesHtml', this._onApiGetDisplayTemplatesHtml.bind(this)], -            ['getQueryParserTemplatesHtml', this._onApiGetQueryParserTemplatesHtml.bind(this)], -            ['getZoom', this._onApiGetZoom.bind(this)], -            ['getMessageToken', this._onApiGetMessageToken.bind(this)], -            ['getDefaultAnkiFieldTemplates', this._onApiGetDefaultAnkiFieldTemplates.bind(this)] +            ['yomichanCoreReady', {handler: this._onApiYomichanCoreReady.bind(this), async: false}], +            ['optionsSchemaGet', {handler: this._onApiOptionsSchemaGet.bind(this), async: false}], +            ['optionsGet', {handler: this._onApiOptionsGet.bind(this), async: false}], +            ['optionsGetFull', {handler: this._onApiOptionsGetFull.bind(this), async: false}], +            ['optionsSet', {handler: this._onApiOptionsSet.bind(this), async: true}], +            ['optionsSave', {handler: this._onApiOptionsSave.bind(this), async: true}], +            ['kanjiFind', {handler: this._onApiKanjiFind.bind(this), async: true}], +            ['termsFind', {handler: this._onApiTermsFind.bind(this), async: true}], +            ['textParse', {handler: this._onApiTextParse.bind(this), async: true}], +            ['textParseMecab', {handler: this._onApiTextParseMecab.bind(this), async: true}], +            ['definitionAdd', {handler: this._onApiDefinitionAdd.bind(this), async: true}], +            ['definitionsAddable', {handler: this._onApiDefinitionsAddable.bind(this), async: true}], +            ['noteView', {handler: this._onApiNoteView.bind(this), async: true}], +            ['templateRender', {handler: this._onApiTemplateRender.bind(this), async: true}], +            ['commandExec', {handler: this._onApiCommandExec.bind(this), async: false}], +            ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], +            ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], +            ['broadcastTab', {handler: this._onApiBroadcastTab.bind(this), async: false}], +            ['frameInformationGet', {handler: this._onApiFrameInformationGet.bind(this), async: true}], +            ['injectStylesheet', {handler: this._onApiInjectStylesheet.bind(this), async: true}], +            ['getEnvironmentInfo', {handler: this._onApiGetEnvironmentInfo.bind(this), async: true}], +            ['clipboardGet', {handler: this._onApiClipboardGet.bind(this), async: true}], +            ['getDisplayTemplatesHtml', {handler: this._onApiGetDisplayTemplatesHtml.bind(this), async: true}], +            ['getQueryParserTemplatesHtml', {handler: this._onApiGetQueryParserTemplatesHtml.bind(this), async: true}], +            ['getZoom', {handler: this._onApiGetZoom.bind(this), async: true}], +            ['getMessageToken', {handler: this._onApiGetMessageToken.bind(this), async: false}], +            ['getDefaultAnkiFieldTemplates', {handler: this._onApiGetDefaultAnkiFieldTemplates.bind(this), async: false}]          ]);          this._commandHandlers = new Map([ @@ -167,16 +166,23 @@ class Backend {      }      onMessage({action, params}, sender, callback) { -        const handler = this._messageHandlers.get(action); -        if (typeof handler !== 'function') { return false; } +        const messageHandler = this._messageHandlers.get(action); +        if (typeof messageHandler === 'undefined') { return false; } + +        const {handler, async} = messageHandler;          try { -            const promise = handler(params, sender); -            promise.then( -                (result) => callback({result}), -                (error) => callback({error: errorToJson(error)}) -            ); -            return true; +            const promiseOrResult = handler(params, sender); +            if (async) { +                promiseOrResult.then( +                    (result) => callback({result}), +                    (error) => callback({error: errorToJson(error)}) +                ); +                return true; +            } else { +                callback({result: promiseOrResult}); +                return false; +            }          } catch (error) {              callback({error: errorToJson(error)});              return false; @@ -313,27 +319,26 @@ class Backend {      _onApiYomichanCoreReady(_params, sender) {          // tab ID isn't set in background (e.g. browser_action) +        const callback = () => this.checkLastError(chrome.runtime.lastError); +        const data = {action: 'backendPrepared'};          if (typeof sender.tab === 'undefined') { -            const callback = () => this.checkLastError(chrome.runtime.lastError); -            chrome.runtime.sendMessage({action: 'backendPrepared'}, callback); -            return Promise.resolve(); +            chrome.runtime.sendMessage(data, callback); +            return false; +        } else { +            chrome.tabs.sendMessage(sender.tab.id, data, callback); +            return true;          } - -        const tabId = sender.tab.id; -        return new Promise((resolve) => { -            chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve); -        });      } -    async _onApiOptionsSchemaGet() { +    _onApiOptionsSchemaGet() {          return this.getOptionsSchema();      } -    async _onApiOptionsGet({optionsContext}) { +    _onApiOptionsGet({optionsContext}) {          return this.getOptions(optionsContext);      } -    async _onApiOptionsGetFull() { +    _onApiOptionsGetFull() {          return this.getFullOptions();      } @@ -540,7 +545,7 @@ class Backend {          return this._renderTemplate(template, data);      } -    async _onApiCommandExec({command, params}) { +    _onApiCommandExec({command, params}) {          return this._runCommand(command, params);      } @@ -560,15 +565,15 @@ class Backend {          });      } -    _onApiForward({action, params}, sender) { +    _onApiBroadcastTab({action, params}, sender) {          if (!(sender && sender.tab)) { -            return Promise.resolve(); +            return false;          }          const tabId = sender.tab.id; -        return new Promise((resolve) => { -            chrome.tabs.sendMessage(tabId, {action, params}, (response) => resolve(response)); -        }); +        const callback = () => this.checkLastError(chrome.runtime.lastError); +        chrome.tabs.sendMessage(tabId, {action, params}, callback); +        return true;      }      _onApiFrameInformationGet(params, sender) { @@ -691,11 +696,11 @@ class Backend {          });      } -    async _onApiGetMessageToken() { +    _onApiGetMessageToken() {          return this.messageToken;      } -    async _onApiGetDefaultAnkiFieldTemplates() { +    _onApiGetDefaultAnkiFieldTemplates() {          return this.defaultAnkiFieldTemplates;      } diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index c67525fc..e7e7378c 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/conditions.js b/ext/bg/js/conditions.js index d4d1c0e0..eb9582df 100644 --- a/ext/bg/js/conditions.js +++ b/ext/bg/js/conditions.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index c3e74656..e3d4ad4a 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2017-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2017-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 4a677fea..ad4e3bad 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js index d548d271..6ec6e899 100644 --- a/ext/bg/js/deinflector.js +++ b/ext/bg/js/deinflector.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js index 254fde4f..bf6809ec 100644 --- a/ext/bg/js/dictionary-importer.js +++ b/ext/bg/js/dictionary-importer.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 74bd5a64..15cc7615 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index 5fda5baa..860acb14 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index 2a2b39fd..5fef27a7 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -83,6 +82,9 @@      const ITERATION_MARK_CODE_POINT = 0x3005; +    const HIRAGANA_SMALL_TSU_CODE_POINT = 0x3063; +    const KATAKANA_SMALL_TSU_CODE_POINT = 0x30c3; +    const KANA_PROLONGED_SOUND_MARK_CODE_POINT = 0x30fc;      // Existing functions @@ -373,6 +375,40 @@      } +    // Miscellaneous + +    function collapseEmphaticSequences(text, fullCollapse, sourceMap=null) { +        let result = ''; +        let collapseCodePoint = -1; +        const hasSourceMap = (sourceMap !== null); +        for (const char of text) { +            const c = char.codePointAt(0); +            if ( +                c === HIRAGANA_SMALL_TSU_CODE_POINT || +                c === KATAKANA_SMALL_TSU_CODE_POINT || +                c === KANA_PROLONGED_SOUND_MARK_CODE_POINT +            ) { +                if (collapseCodePoint !== c) { +                    collapseCodePoint = c; +                    if (!fullCollapse) { +                        result += char; +                        continue; +                    } +                } +            } else { +                collapseCodePoint = -1; +                result += char; +                continue; +            } + +            if (hasSourceMap) { +                sourceMap.combine(Math.max(0, result.length - 1), 1); +            } +        } +        return result; +    } + +      // Exports      Object.assign(jp, { @@ -384,6 +420,7 @@          convertHalfWidthKanaToFullWidth,          convertAlphabeticToKana,          distributeFurigana, -        distributeFuriganaInflected +        distributeFuriganaInflected, +        collapseEmphaticSequences      });  })(); diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index 58f804fd..f62402f9 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js index 34ecd728..cd6e6c57 100644 --- a/ext/bg/js/mecab.js +++ b/ext/bg/js/mecab.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index abb054d4..f3e5f60d 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -171,7 +170,8 @@ function profileOptionsCreateDefaults() {              convertNumericCharacters: 'false',              convertAlphabeticCharacters: 'false',              convertHiraganaToKatakana: 'false', -            convertKatakanaToHiragana: 'variant' +            convertKatakanaToHiragana: 'variant', +            collapseEmphaticSequences: 'false'          },          dictionaries: {}, diff --git a/ext/bg/js/page-exit-prevention.js b/ext/bg/js/page-exit-prevention.js index be06c495..f55cf024 100644 --- a/ext/bg/js/page-exit-prevention.js +++ b/ext/bg/js/page-exit-prevention.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/profile-conditions.js b/ext/bg/js/profile-conditions.js index 1fd78e5d..a0710bd1 100644 --- a/ext/bg/js/profile-conditions.js +++ b/ext/bg/js/profile-conditions.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index 02eed6fb..957ac0f5 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2017-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2017-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index f130a6fa..9cc1436f 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 664858a4..390841c1 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 9f59f2e5..01a0ace5 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 5d04c6e4..871c576b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index e3852eb4..d5b6e677 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index f2e1ca76..b32a9517 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js index 206539a4..73c64227 100644 --- a/ext/bg/js/settings/audio-ui.js +++ b/ext/bg/js/settings/audio-ui.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index 38dd6349..3c6e126c 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index 21417dfb..bdfef658 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index 9d61d25e..84498b42 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 33ced3b9..1a6d452b 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 1653ee35..308e92eb 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -119,6 +118,7 @@ async function formRead(options) {      options.translation.convertAlphabeticCharacters = $('#translation-convert-alphabetic-characters').val();      options.translation.convertHiraganaToKatakana = $('#translation-convert-hiragana-to-katakana').val();      options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val(); +    options.translation.collapseEmphaticSequences = $('#translation-collapse-emphatic-sequences').val();      options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked');      options.parsing.enableMecabParser = $('#parsing-mecab-enable').prop('checked'); @@ -200,6 +200,7 @@ async function formWrite(options) {      $('#translation-convert-alphabetic-characters').val(options.translation.convertAlphabeticCharacters);      $('#translation-convert-hiragana-to-katakana').val(options.translation.convertHiraganaToKatakana);      $('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana); +    $('#translation-collapse-emphatic-sequences').val(options.translation.collapseEmphaticSequences);      $('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser);      $('#parsing-mecab-enable').prop('checked', options.parsing.enableMecabParser); diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 6a149841..fba114e2 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/popup-preview.js b/ext/bg/js/settings/popup-preview.js index d1d2ff5e..091872be 100644 --- a/ext/bg/js/settings/popup-preview.js +++ b/ext/bg/js/settings/popup-preview.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index b35b6309..867b17aa 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index ae305e22..d754a109 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/text-source-map.js b/ext/bg/js/text-source-map.js index 24970978..1776ae07 100644 --- a/ext/bg/js/text-source-map.js +++ b/ext/bg/js/text-source-map.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 27f91c05..aaa1a0ec 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -348,17 +347,27 @@ class Translator {      getAllDeinflections(text, options) {          const translationOptions = options.translation; +        const collapseEmphaticOptions = [[false, false]]; +        switch (translationOptions.collapseEmphaticSequences) { +            case 'true': +                collapseEmphaticOptions.push([true, false]); +                break; +            case 'full': +                collapseEmphaticOptions.push([true, false], [true, true]); +                break; +        }          const textOptionVariantArray = [              Translator.getTextOptionEntryVariants(translationOptions.convertHalfWidthCharacters),              Translator.getTextOptionEntryVariants(translationOptions.convertNumericCharacters),              Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters),              Translator.getTextOptionEntryVariants(translationOptions.convertHiraganaToKatakana), -            Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana) +            Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana), +            collapseEmphaticOptions          ];          const deinflections = [];          const used = new Set(); -        for (const [halfWidth, numeric, alphabetic, katakana, hiragana] of Translator.getArrayVariants(textOptionVariantArray)) { +        for (const [halfWidth, numeric, alphabetic, katakana, hiragana, [collapseEmphatic, collapseEmphaticFull]] of Translator.getArrayVariants(textOptionVariantArray)) {              let text2 = text;              const sourceMap = new TextSourceMap(text2);              if (halfWidth) { @@ -376,6 +385,9 @@ class Translator {              if (hiragana) {                  text2 = jp.convertKatakanaToHiragana(text2);              } +            if (collapseEmphatic) { +                text2 = jp.collapseEmphaticSequences(text2, collapseEmphaticFull, sourceMap); +            }              for (let i = text2.length; i > 0; --i) {                  const text2Substring = text2.substring(0, i); diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index a7ed4a34..69536f02 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/bg/legal.html b/ext/bg/legal.html index c1e606d7..78acf79a 100644 --- a/ext/bg/legal.html +++ b/ext/bg/legal.html @@ -17,7 +17,7 @@          <div class="container">              <h3>Yomichan License</h3>  <pre> -Copyright (C) 2016-2020  Alex Yatskov +Copyright (C) 2016-2020  Yomichan Authors  This program is free software: you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 1297a9cc..96c1db82 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -427,7 +427,7 @@                  <p class="help-block">                      The conversion options below are listed in the order that the conversions are applied to the input text. -                    Each conversion has three possible values: +                    Conversions commonly have three possible values:                  </p>                  <ul class="help-block"> @@ -490,6 +490,15 @@                          <option value="variant">Use both variants</option>                      </select>                  </div> + +                <div class="form-group"> +                    <label for="translation-collapse-emphatic-sequences">Collapse emphatic character sequences <span class="label-light">(すっっごーーい → すっごーい / すごい)</span></label> +                    <select class="form-control" id="translation-collapse-emphatic-sequences"> +                        <option value="false">Disabled</option> +                        <option value="true">Collapse into single character</option> +                        <option value="full">Remove all characters</option> +                    </select> +                </div>              </div>              <div id="popup-content-scanning"> diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css index 5720d8ac..227f5030 100644 --- a/ext/fg/css/client.css +++ b/ext/fg/css/client.css @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 490f61bb..3b4cc28f 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 01055ca6..5c2c50c2 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -18,7 +17,7 @@  /* global   * Display - * apiForward + * apiBroadcastTab   * apiGetMessageToken   * popupNestedInitialize   */ @@ -80,7 +79,7 @@ class DisplayFloat extends Display {          this.setContentScale(scale); -        apiForward('popupPrepareCompleted', {targetPopupId: this._popupId}); +        apiBroadcastTab('popupPrepareCompleted', {targetPopupId: this._popupId});      }      onError(error) { @@ -181,7 +180,7 @@ class DisplayFloat extends Display {                  },                  2000              ); -            apiForward('requestDocumentInformationBroadcast', {uniqueId}); +            apiBroadcastTab('requestDocumentInformationBroadcast', {uniqueId});              const {title} = await promise;              return title; diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js index 7b417b6e..c658c55a 100644 --- a/ext/fg/js/frame-offset-forwarder.js +++ b/ext/fg/js/frame-offset-forwarder.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -17,7 +16,7 @@   */  /* global - * apiForward + * apiBroadcastTab   */  class FrameOffsetForwarder { @@ -97,6 +96,6 @@ class FrameOffsetForwarder {      }      _forwardFrameOffsetOrigin(offset, uniqueId) { -        apiForward('frameOffset', {offset, uniqueId}); +        apiBroadcastTab('frameOffset', {offset, uniqueId});      }  } diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js index 642d96df..4abd4e81 100644 --- a/ext/fg/js/frontend-api-receiver.js +++ b/ext/fg/js/frontend-api-receiver.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js index 4431df61..1d539cab 100644 --- a/ext/fg/js/frontend-api-sender.js +++ b/ext/fg/js/frontend-api-sender.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 4a1409db..5af7fdf0 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -21,7 +20,7 @@   * Frontend   * PopupProxy   * PopupProxyHost - * apiForward + * apiBroadcastTab   * apiOptionsGet   */ @@ -44,7 +43,7 @@ async function main() {                  }              }          ); -        apiForward('rootPopupRequestInformationBroadcast'); +        apiBroadcastTab('rootPopupRequestInformationBroadcast');          const {popupId, frameId} = await rootPopupInformationPromise;          const frameOffsetForwarder = new FrameOffsetForwarder(); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 31843212..55d699e5 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -18,7 +17,7 @@  /* global   * TextScanner - * apiForward + * apiBroadcastTab   * apiGetZoom   * apiKanjiFind   * apiOptionsGet @@ -261,12 +260,12 @@ class Frontend extends TextScanner {      _broadcastRootPopupInformation() {          if (!this.popup.isProxy() && this.popup.depth === 0) { -            apiForward('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId}); +            apiBroadcastTab('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId});          }      }      _broadcastDocumentInformation(uniqueId) { -        apiForward('documentInformationBroadcast', { +        apiBroadcastTab('documentInformationBroadcast', {              uniqueId,              frameId: this.popup.frameId,              title: document.title diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index 39d91fd8..1b24614b 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 4b136e41..958462ff 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 966198a9..82ad9a8f 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 60dc16dd..42f08afa 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index 6dc482bd..3d9afe0f 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/manifest.json b/ext/manifest.json index 98965389..788e1469 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@  {      "manifest_version": 2,      "name": "Yomichan", -    "version": "20.3.14.0", +    "version": "20.4.10.0",      "description": "Japanese dictionary with Anki integration",      "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, diff --git a/ext/mixed/css/display-dark.css b/ext/mixed/css/display-dark.css index 550dff3e..e4549bbf 100644 --- a/ext/mixed/css/display-dark.css +++ b/ext/mixed/css/display-dark.css @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the entrys of the GNU General Public License as published by diff --git a/ext/mixed/css/display-default.css b/ext/mixed/css/display-default.css index 487b8cb8..7bcb1014 100644 --- a/ext/mixed/css/display-default.css +++ b/ext/mixed/css/display-default.css @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the entrys of the GNU General Public License as published by diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css index a4432016..d1a54064 100644 --- a/ext/mixed/css/display.css +++ b/ext/mixed/css/display.css @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the entrys of the GNU General Public License as published by @@ -298,13 +297,13 @@ button.action-button {      content: "\3001";  } -.term-expression-list[data-multi=true]>.term-expression:last-of-type:after { +.entry[data-expression-multi=true] .term-expression-list>.term-expression:last-of-type:after {      font-size: 2em;      content: "\3000";      visibility: hidden;  } -.term-expression-list[data-multi=true] .term-expression-details { +.entry[data-expression-multi=true] .term-expression-list .term-expression-details {      display: inline-block;      position: relative;      width: 0; @@ -313,21 +312,21 @@ button.action-button {      z-index: 1;  } -.term-expression-list[data-multi=true] .term-expression:hover .term-expression-details { +.entry[data-expression-multi=true] .term-expression:hover .term-expression-details {      visibility: visible;  } -.term-expression-list[data-multi=true] .term-expression-details>.action-play-audio { +.entry[data-expression-multi=true] .term-expression-list .term-expression-details>.action-play-audio {      position: absolute;      left: 0;      bottom: 0.5em;  } -.term-expression-list:not([data-multi=true]) .term-expression-details>.action-play-audio { +.entry:not([data-expression-multi=true]) .term-expression-list .term-expression-details>.action-play-audio {      display: none;  } -.term-expression-list[data-multi=true] .term-expression-details>.tags { +.entry[data-expression-multi=true] .term-expression-list .term-expression-details>.tags {      display: block;      position: absolute;      left: 0; @@ -335,7 +334,7 @@ button.action-button {      white-space: nowrap;  } -.term-expression-list[data-multi=true] .term-expression-details>.frequencies { +.entry[data-expression-multi=true] .term-expression-list .term-expression-details>.frequencies {      display: block;      position: absolute;      left: 0; @@ -365,19 +364,19 @@ button.action-button {      list-style-type: circle;  } -.term-definition-only-list[data-count="0"] { +.term-definition-disambiguation-list[data-count="0"] {      display: none;  } -.term-definition-only-list:before { +.term-definition-disambiguation-list:before {      content: "(";  } -.term-definition-only-list:after { +.term-definition-disambiguation-list:after {      content: " only)";  } -.term-definition-only+.term-definition-only:before { +.term-definition-disambiguation+.term-definition-disambiguation:before {      content: ", ";  } @@ -399,7 +398,7 @@ button.action-button {  }  :root[data-compact-glossaries=true] .term-definition-tag-list, -:root[data-compact-glossaries=true] .term-definition-only-list:not([data-count="0"]) { +:root[data-compact-glossaries=true] .term-definition-disambiguation-list:not([data-count="0"]) {      display: inline;  } diff --git a/ext/mixed/display-templates.html b/ext/mixed/display-templates.html index b8d52d15..3baa8293 100644 --- a/ext/mixed/display-templates.html +++ b/ext/mixed/display-templates.html @@ -30,10 +30,10 @@  </div></div></template>  <template id="term-definition-item-template"><li class="term-definition-item">      <div class="term-definition-tag-list tag-list"></div> -    <div class="term-definition-only-list"></div> +    <div class="term-definition-disambiguation-list"></div>      <ul class="term-glossary-list"></ul>  </li></template> -<template id="term-definition-only-template"><span class="term-definition-only"></span></template> +<template id="term-definition-disambiguation-template"><span class="term-definition-disambiguation"></span></template>  <template id="term-glossary-item-template"><li class="term-glossary-item"><span class="term-glossary-separator"> </span><span class="term-glossary"></span></li></template>  <template id="term-reason-template"><span class="term-reason"></span><span class="term-reason-separator"> </span></template> diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index feec94df..50b285a5 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -81,8 +80,8 @@ function apiScreenshotGet(options) {      return _apiInvoke('screenshotGet', {options});  } -function apiForward(action, params) { -    return _apiInvoke('forward', {action, params}); +function apiBroadcastTab(action, params) { +    return _apiInvoke('broadcastTab', {action, params});  }  function apiFrameInformationGet() { diff --git a/ext/mixed/js/audio-system.js b/ext/mixed/js/audio-system.js index 31c476b1..45b733fc 100644 --- a/ext/mixed/js/audio-system.js +++ b/ext/mixed/js/audio-system.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index db7fc69b..2d11c11a 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/display-context.js b/ext/mixed/js/display-context.js index c11c2342..5ee78459 100644 --- a/ext/mixed/js/display-context.js +++ b/ext/mixed/js/display-context.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index f1122e3d..0f991362 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -44,13 +43,15 @@ class DisplayGenerator {          const debugInfoContainer = node.querySelector('.debug-info');          const bodyContainer = node.querySelector('.term-entry-body'); -        const pitches = DisplayGenerator._getPitchInfos(details); +        const {termTags, expressions, definitions} = details; + +        const pitches = this._getPitchInfos(details);          const pitchCount = pitches.reduce((i, v) => i + v[1].length, 0); -        const expressionMulti = Array.isArray(details.expressions); -        const definitionMulti = Array.isArray(details.definitions); -        const expressionCount = expressionMulti ? details.expressions.length : 1; -        const definitionCount = definitionMulti ? details.definitions.length : 1; +        const expressionMulti = Array.isArray(expressions); +        const definitionMulti = Array.isArray(definitions); +        const expressionCount = expressionMulti ? expressions.length : 1; +        const definitionCount = definitionMulti ? definitions.length : 1;          const uniqueExpressionCount = Array.isArray(details.expression) ? new Set(details.expression).size : 1;          node.dataset.expressionMulti = `${expressionMulti}`; @@ -66,15 +67,56 @@ class DisplayGenerator {              (pitches.length > 0 ? 1 : 0)          }`; -        const termTags = details.termTags; -        let expressions = details.expressions; -        expressions = Array.isArray(expressions) ? expressions.map((e) => [e, termTags]) : null; +        this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressionMulti ? expressions : [details], termTags); +        this._appendMultiple(reasonsContainer, this._createTermReason.bind(this), details.reasons); +        this._appendMultiple(frequenciesContainer, this._createFrequencyTag.bind(this), details.frequencies); +        this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches); +        this._appendMultiple(definitionsContainer, this._createTermDefinitionItem.bind(this), definitionMulti ? definitions : [details]); + +        if (debugInfoContainer !== null) { +            debugInfoContainer.textContent = JSON.stringify(details, null, 4); +        } + +        return node; +    } + +    createKanjiEntry(details) { +        const node = this._templateHandler.instantiate('kanji-entry'); + +        const glyphContainer = node.querySelector('.kanji-glyph'); +        const frequenciesContainer = node.querySelector('.frequencies'); +        const tagContainer = node.querySelector('.tags'); +        const glossaryContainer = node.querySelector('.kanji-glossary-list'); +        const chineseReadingsContainer = node.querySelector('.kanji-readings-chinese'); +        const japaneseReadingsContainer = node.querySelector('.kanji-readings-japanese'); +        const statisticsContainer = node.querySelector('.kanji-statistics'); +        const classificationsContainer = node.querySelector('.kanji-classifications'); +        const codepointsContainer = node.querySelector('.kanji-codepoints'); +        const dictionaryIndicesContainer = node.querySelector('.kanji-dictionary-indices'); +        const debugInfoContainer = node.querySelector('.debug-info'); + +        if (glyphContainer !== null) { +            glyphContainer.textContent = details.character; +        } -        DisplayGenerator._appendMultiple(expressionsContainer, this.createTermExpression.bind(this), expressions, [[details, termTags]]); -        DisplayGenerator._appendMultiple(reasonsContainer, this.createTermReason.bind(this), details.reasons); -        DisplayGenerator._appendMultiple(frequenciesContainer, this.createFrequencyTag.bind(this), details.frequencies); -        DisplayGenerator._appendMultiple(pitchesContainer, this.createPitches.bind(this), pitches); -        DisplayGenerator._appendMultiple(definitionsContainer, this.createTermDefinitionItem.bind(this), details.definitions, [details]); +        this._appendMultiple(frequenciesContainer, this._createFrequencyTag.bind(this), details.frequencies); +        this._appendMultiple(tagContainer, this._createTag.bind(this), details.tags); +        this._appendMultiple(glossaryContainer, this._createKanjiGlossaryItem.bind(this), details.glossary); +        this._appendMultiple(chineseReadingsContainer, this._createKanjiReading.bind(this), details.onyomi); +        this._appendMultiple(japaneseReadingsContainer, this._createKanjiReading.bind(this), details.kunyomi); + +        if (statisticsContainer !== null) { +            statisticsContainer.appendChild(this._createKanjiInfoTable(details.stats.misc)); +        } +        if (classificationsContainer !== null) { +            classificationsContainer.appendChild(this._createKanjiInfoTable(details.stats.class)); +        } +        if (codepointsContainer !== null) { +            codepointsContainer.appendChild(this._createKanjiInfoTable(details.stats.code)); +        } +        if (dictionaryIndicesContainer !== null) { +            dictionaryIndicesContainer.appendChild(this._createKanjiInfoTable(details.stats.index)); +        }          if (debugInfoContainer !== null) {              debugInfoContainer.textContent = JSON.stringify(details, null, 4); @@ -83,7 +125,9 @@ class DisplayGenerator {          return node;      } -    createTermExpression([details, termTags]) { +    // Private + +    _createTermExpression(details, termTags) {          const node = this._templateHandler.instantiate('term-expression');          const expressionContainer = node.querySelector('.term-expression-text'); @@ -100,7 +144,7 @@ class DisplayGenerator {                  // This case should not occur                  furiganaSegments = [{text: details.expression, furigana: details.reading}];              } -            DisplayGenerator._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this)); +            this._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this));          }          if (!Array.isArray(termTags)) { @@ -110,14 +154,14 @@ class DisplayGenerator {          const searchQueries = [details.expression, details.reading]              .filter((x) => !!x)              .map((x) => ({query: x})); -        DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), termTags); -        DisplayGenerator._appendMultiple(tagContainer, this.createSearchTag.bind(this), searchQueries); -        DisplayGenerator._appendMultiple(frequencyContainer, this.createFrequencyTag.bind(this), details.frequencies); +        this._appendMultiple(tagContainer, this._createTag.bind(this), termTags); +        this._appendMultiple(tagContainer, this._createSearchTag.bind(this), searchQueries); +        this._appendMultiple(frequencyContainer, this._createFrequencyTag.bind(this), details.frequencies);          return node;      } -    createTermReason(reason) { +    _createTermReason(reason) {          const fragment = this._templateHandler.instantiateFragment('term-reason');          const node = fragment.querySelector('.term-reason');          node.textContent = reason; @@ -125,39 +169,39 @@ class DisplayGenerator {          return fragment;      } -    createTermDefinitionItem(details) { +    _createTermDefinitionItem(details) {          const node = this._templateHandler.instantiate('term-definition-item');          const tagListContainer = node.querySelector('.term-definition-tag-list'); -        const onlyListContainer = node.querySelector('.term-definition-only-list'); +        const onlyListContainer = node.querySelector('.term-definition-disambiguation-list');          const glossaryContainer = node.querySelector('.term-glossary-list');          node.dataset.dictionary = details.dictionary; -        DisplayGenerator._appendMultiple(tagListContainer, this.createTag.bind(this), details.definitionTags); -        DisplayGenerator._appendMultiple(onlyListContainer, this.createTermOnly.bind(this), details.only); -        DisplayGenerator._appendMultiple(glossaryContainer, this.createTermGlossaryItem.bind(this), details.glossary); +        this._appendMultiple(tagListContainer, this._createTag.bind(this), details.definitionTags); +        this._appendMultiple(onlyListContainer, this._createTermDisambiguation.bind(this), details.only); +        this._appendMultiple(glossaryContainer, this._createTermGlossaryItem.bind(this), details.glossary);          return node;      } -    createTermGlossaryItem(glossary) { +    _createTermGlossaryItem(glossary) {          const node = this._templateHandler.instantiate('term-glossary-item');          const container = node.querySelector('.term-glossary');          if (container !== null) { -            DisplayGenerator._appendMultilineText(container, glossary); +            this._appendMultilineText(container, glossary);          }          return node;      } -    createTermOnly(only) { -        const node = this._templateHandler.instantiate('term-definition-only'); -        node.dataset.only = only; -        node.textContent = only; +    _createTermDisambiguation(disambiguation) { +        const node = this._templateHandler.instantiate('term-definition-disambiguation'); +        node.dataset.term = disambiguation; +        node.textContent = disambiguation;          return node;      } -    createKanjiLink(character) { +    _createKanjiLink(character) {          const node = document.createElement('a');          node.href = '#';          node.className = 'kanji-link'; @@ -165,75 +209,30 @@ class DisplayGenerator {          return node;      } -    createKanjiEntry(details) { -        const node = this._templateHandler.instantiate('kanji-entry'); - -        const glyphContainer = node.querySelector('.kanji-glyph'); -        const frequenciesContainer = node.querySelector('.frequencies'); -        const tagContainer = node.querySelector('.tags'); -        const glossaryContainer = node.querySelector('.kanji-glossary-list'); -        const chineseReadingsContainer = node.querySelector('.kanji-readings-chinese'); -        const japaneseReadingsContainer = node.querySelector('.kanji-readings-japanese'); -        const statisticsContainer = node.querySelector('.kanji-statistics'); -        const classificationsContainer = node.querySelector('.kanji-classifications'); -        const codepointsContainer = node.querySelector('.kanji-codepoints'); -        const dictionaryIndicesContainer = node.querySelector('.kanji-dictionary-indices'); -        const debugInfoContainer = node.querySelector('.debug-info'); - -        if (glyphContainer !== null) { -            glyphContainer.textContent = details.character; -        } - -        DisplayGenerator._appendMultiple(frequenciesContainer, this.createFrequencyTag.bind(this), details.frequencies); -        DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), details.tags); -        DisplayGenerator._appendMultiple(glossaryContainer, this.createKanjiGlossaryItem.bind(this), details.glossary); -        DisplayGenerator._appendMultiple(chineseReadingsContainer, this.createKanjiReading.bind(this), details.onyomi); -        DisplayGenerator._appendMultiple(japaneseReadingsContainer, this.createKanjiReading.bind(this), details.kunyomi); - -        if (statisticsContainer !== null) { -            statisticsContainer.appendChild(this.createKanjiInfoTable(details.stats.misc)); -        } -        if (classificationsContainer !== null) { -            classificationsContainer.appendChild(this.createKanjiInfoTable(details.stats.class)); -        } -        if (codepointsContainer !== null) { -            codepointsContainer.appendChild(this.createKanjiInfoTable(details.stats.code)); -        } -        if (dictionaryIndicesContainer !== null) { -            dictionaryIndicesContainer.appendChild(this.createKanjiInfoTable(details.stats.index)); -        } - -        if (debugInfoContainer !== null) { -            debugInfoContainer.textContent = JSON.stringify(details, null, 4); -        } - -        return node; -    } - -    createKanjiGlossaryItem(glossary) { +    _createKanjiGlossaryItem(glossary) {          const node = this._templateHandler.instantiate('kanji-glossary-item');          const container = node.querySelector('.kanji-glossary');          if (container !== null) { -            DisplayGenerator._appendMultilineText(container, glossary); +            this._appendMultilineText(container, glossary);          }          return node;      } -    createKanjiReading(reading) { +    _createKanjiReading(reading) {          const node = this._templateHandler.instantiate('kanji-reading');          node.textContent = reading;          return node;      } -    createKanjiInfoTable(details) { +    _createKanjiInfoTable(details) {          const node = this._templateHandler.instantiate('kanji-info-table');          const container = node.querySelector('.kanji-info-table-body');          if (container !== null) { -            const count = DisplayGenerator._appendMultiple(container, this.createKanjiInfoTableItem.bind(this), details); +            const count = this._appendMultiple(container, this._createKanjiInfoTableItem.bind(this), details);              if (count === 0) { -                const n = this.createKanjiInfoTableItemEmpty(); +                const n = this._createKanjiInfoTableItemEmpty();                  container.appendChild(n);              }          } @@ -241,7 +240,7 @@ class DisplayGenerator {          return node;      } -    createKanjiInfoTableItem(details) { +    _createKanjiInfoTableItem(details) {          const node = this._templateHandler.instantiate('kanji-info-table-item');          const nameNode = node.querySelector('.kanji-info-table-item-header');          const valueNode = node.querySelector('.kanji-info-table-item-value'); @@ -254,11 +253,11 @@ class DisplayGenerator {          return node;      } -    createKanjiInfoTableItemEmpty() { +    _createKanjiInfoTableItemEmpty() {          return this._templateHandler.instantiate('kanji-info-table-empty');      } -    createTag(details) { +    _createTag(details) {          const node = this._templateHandler.instantiate('tag');          const inner = node.querySelector('.tag-inner'); @@ -270,7 +269,7 @@ class DisplayGenerator {          return node;      } -    createSearchTag(details) { +    _createSearchTag(details) {          const node = this._templateHandler.instantiate('tag-search');          node.textContent = details.query; @@ -280,7 +279,7 @@ class DisplayGenerator {          return node;      } -    createPitches(details) { +    _createPitches(details) {          if (!this._termPitchAccentStaticTemplateIsSetup) {              this._termPitchAccentStaticTemplateIsSetup = true;              const t = this._templateHandler.instantiate('term-pitch-accent-static'); @@ -294,16 +293,16 @@ class DisplayGenerator {          node.dataset.pitchesMulti = 'true';          node.dataset.pitchesCount = `${dictionaryPitches.length}`; -        const tag = this.createTag({notes: '', name: dictionary, category: 'pitch-accent-dictionary'}); +        const tag = this._createTag({notes: '', name: dictionary, category: 'pitch-accent-dictionary'});          node.querySelector('.term-pitch-accent-group-tag-list').appendChild(tag);          const n = node.querySelector('.term-pitch-accent-list'); -        DisplayGenerator._appendMultiple(n, this.createPitch.bind(this), dictionaryPitches); +        this._appendMultiple(n, this._createPitch.bind(this), dictionaryPitches);          return node;      } -    createPitch(details) { +    _createPitch(details) {          const {reading, position, tags, exclusiveExpressions, exclusiveReadings} = details;          const morae = jp.getKanaMorae(reading); @@ -316,10 +315,10 @@ class DisplayGenerator {          n.textContent = `${position}`;          n = node.querySelector('.term-pitch-accent-tag-list'); -        DisplayGenerator._appendMultiple(n, this.createTag.bind(this), tags); +        this._appendMultiple(n, this._createTag.bind(this), tags);          n = node.querySelector('.term-pitch-accent-disambiguation-list'); -        this.createPitchAccentDisambiguations(n, exclusiveExpressions, exclusiveReadings); +        this._createPitchAccentDisambiguations(n, exclusiveExpressions, exclusiveReadings);          n = node.querySelector('.term-pitch-accent-characters');          for (let i = 0, ii = morae.length; i < ii; ++i) { @@ -339,13 +338,13 @@ class DisplayGenerator {          }          if (morae.length > 0) { -            this.populatePitchGraph(node.querySelector('.term-pitch-accent-graph'), position, morae); +            this._populatePitchGraph(node.querySelector('.term-pitch-accent-graph'), position, morae);          }          return node;      } -    createPitchAccentDisambiguations(container, exclusiveExpressions, exclusiveReadings) { +    _createPitchAccentDisambiguations(container, exclusiveExpressions, exclusiveReadings) {          const templateName = 'term-pitch-accent-disambiguation';          for (const exclusiveExpression of exclusiveExpressions) {              const node = this._templateHandler.instantiate(templateName); @@ -361,13 +360,12 @@ class DisplayGenerator {              container.appendChild(node);          } -        container.dataset.multi = 'true';          container.dataset.count = `${exclusiveExpressions.length + exclusiveReadings.length}`;          container.dataset.expressionCount = `${exclusiveExpressions.length}`;          container.dataset.readingCount = `${exclusiveReadings.length}`;      } -    populatePitchGraph(svg, position, morae) { +    _populatePitchGraph(svg, position, morae) {          const svgns = svg.getAttribute('xmlns');          const ii = morae.length;          svg.setAttribute('viewBox', `0 0 ${50 * (ii + 1)} 100`); @@ -407,7 +405,7 @@ class DisplayGenerator {          path.setAttribute('d', `M${pathPoints.join(' L')}`);      } -    createFrequencyTag(details) { +    _createFrequencyTag(details) {          const node = this._templateHandler.instantiate('tag-frequency');          let n = node.querySelector('.term-frequency-dictionary-name'); @@ -435,7 +433,7 @@ class DisplayGenerator {                      part = '';                  } -                const link = this.createKanjiLink(c); +                const link = this._createKanjiLink(c);                  container.appendChild(link);              } else {                  part += c; @@ -446,31 +444,31 @@ class DisplayGenerator {          }      } -    static _appendMultiple(container, createItem, detailsIterable, fallback=[]) { -        if (container === null) { return 0; } - -        const multi = ( -            detailsIterable !== null && -            typeof detailsIterable === 'object' && -            typeof detailsIterable[Symbol.iterator] !== 'undefined' +    _isIterable(value) { +        return ( +            value !== null && +            typeof value === 'object' && +            typeof value[Symbol.iterator] !== 'undefined'          ); -        if (!multi) { detailsIterable = fallback; } +    } +    _appendMultiple(container, createItem, detailsIterable, ...args) {          let count = 0; -        for (const details of detailsIterable) { -            const item = createItem(details); -            if (item === null) { continue; } -            container.appendChild(item); -            ++count; +        if (container !== null && this._isIterable(detailsIterable)) { +            for (const details of detailsIterable) { +                const item = createItem(details, ...args); +                if (item === null) { continue; } +                container.appendChild(item); +                ++count; +            }          } -        container.dataset.multi = `${multi}`;          container.dataset.count = `${count}`;          return count;      } -    static _appendFurigana(container, segments, addText) { +    _appendFurigana(container, segments, addText) {          for (const {text, furigana} of segments) {              if (furigana) {                  const ruby = document.createElement('ruby'); @@ -485,7 +483,7 @@ class DisplayGenerator {          }      } -    static _appendMultilineText(container, text) { +    _appendMultilineText(container, text) {          const parts = text.split('\n');          container.appendChild(document.createTextNode(parts[0]));          for (let i = 1, ii = parts.length; i < ii; ++i) { @@ -494,7 +492,7 @@ class DisplayGenerator {          }      } -    static _getPitchInfos(definition) { +    _getPitchInfos(definition) {          const results = new Map();          const allExpressions = new Set(); @@ -512,7 +510,7 @@ class DisplayGenerator {                  }                  for (const {position, tags} of pitches) { -                    let pitchInfo = DisplayGenerator._findExistingPitchInfo(reading, position, tags, dictionaryResults); +                    let pitchInfo = this._findExistingPitchInfo(reading, position, tags, dictionaryResults);                      if (pitchInfo === null) {                          pitchInfo = {expressions: new Set(), reading, position, tags};                          dictionaryResults.push(pitchInfo); @@ -541,12 +539,12 @@ class DisplayGenerator {          return [...results.entries()];      } -    static _findExistingPitchInfo(reading, position, tags, pitchInfoList) { +    _findExistingPitchInfo(reading, position, tags, pitchInfoList) {          for (const pitchInfo of pitchInfoList) {              if (                  pitchInfo.reading === reading &&                  pitchInfo.position === position && -                DisplayGenerator._areTagListsEqual(pitchInfo.tags, tags) +                this._areTagListsEqual(pitchInfo.tags, tags)              ) {                  return pitchInfo;              } @@ -554,7 +552,7 @@ class DisplayGenerator {          return null;      } -    static _areTagListsEqual(tagList1, tagList2) { +    _areTagListsEqual(tagList1, tagList2) {          const ii = tagList1.length;          if (tagList2.length !== ii) { return false; } diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 2f456c3e..63687dc2 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2017-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2017-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -23,9 +22,9 @@   * DisplayGenerator   * WindowScroll   * apiAudioGetUri + * apiBroadcastTab   * apiDefinitionAdd   * apiDefinitionsAddable - * apiForward   * apiKanjiFind   * apiNoteView   * apiOptionsGet @@ -855,7 +854,7 @@ class Display {      }      setPopupVisibleOverride(visible) { -        return apiForward('popupSetVisibleOverride', {visible}); +        return apiBroadcastTab('popupSetVisibleOverride', {visible});      }      setSpinnerVisible(visible) { diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js index 807a48e1..03acbb80 100644 --- a/ext/mixed/js/dom.js +++ b/ext/mixed/js/dom.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js index e6b9a8a0..79d69946 100644 --- a/ext/mixed/js/japanese.js +++ b/ext/mixed/js/japanese.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/object-property-accessor.js b/ext/mixed/js/object-property-accessor.js index 108afc0d..349037b3 100644 --- a/ext/mixed/js/object-property-accessor.js +++ b/ext/mixed/js/object-property-accessor.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2016-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2016-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/scroll.js b/ext/mixed/js/scroll.js index 72da8b65..840fdb9c 100644 --- a/ext/mixed/js/scroll.js +++ b/ext/mixed/js/scroll.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/template-handler.js b/ext/mixed/js/template-handler.js index a5a62937..f17fd60c 100644 --- a/ext/mixed/js/template-handler.js +++ b/ext/mixed/js/template-handler.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index 9d8a7f0c..e6b9a2e6 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/ext/mixed/js/timer.js b/ext/mixed/js/timer.js index 1caf7a05..30408e93 100644 --- a/ext/mixed/js/timer.js +++ b/ext/mixed/js/timer.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2019-2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2019-2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/dictionary-validate.js b/test/dictionary-validate.js index 6496f2ac..f1730852 100644 --- a/test/dictionary-validate.js +++ b/test/dictionary-validate.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/lint/global-declarations.js b/test/lint/global-declarations.js index 2629cc5e..07ba5570 100644 --- a/test/lint/global-declarations.js +++ b/test/lint/global-declarations.js @@ -1,6 +1,6 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors + * Author: Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/schema-validate.js b/test/schema-validate.js index eb31aa8d..761f0a1c 100644 --- a/test/schema-validate.js +++ b/test/schema-validate.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-database.js b/test/test-database.js index bab15aa4..d27f92e1 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-dictionary.js b/test/test-dictionary.js index 74f9e62b..27cc90df 100644 --- a/test/test-dictionary.js +++ b/test/test-dictionary.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-document.js b/test/test-document.js index 80b9719d..0d9026db 100644 --- a/test/test-document.js +++ b/test/test-document.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-japanese.js b/test/test-japanese.js index ca65dde2..89e41c36 100644 --- a/test/test-japanese.js +++ b/test/test-japanese.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -394,6 +393,59 @@ function testDistributeFuriganaInflected() {      }  } +function testCollapseEmphaticSequences() { +    const data = [ +        [['かこい', false], ['かこい', [1, 1, 1]]], +        [['かこい', true], ['かこい', [1, 1, 1]]], +        [['かっこい', false], ['かっこい', [1, 1, 1, 1]]], +        [['かっこい', true], ['かこい', [2, 1, 1]]], +        [['かっっこい', false], ['かっこい', [1, 2, 1, 1]]], +        [['かっっこい', true], ['かこい', [3, 1, 1]]], +        [['かっっっこい', false], ['かっこい', [1, 3, 1, 1]]], +        [['かっっっこい', true], ['かこい', [4, 1, 1]]], + +        [['こい', false], ['こい', [1, 1]]], +        [['こい', true], ['こい', [1, 1]]], +        [['っこい', false], ['っこい', [1, 1, 1]]], +        [['っこい', true], ['こい', [2, 1]]], +        [['っっこい', false], ['っこい', [2, 1, 1]]], +        [['っっこい', true], ['こい', [3, 1]]], +        [['っっっこい', false], ['っこい', [3, 1, 1]]], +        [['っっっこい', true], ['こい', [4, 1]]], + +        [['すごい', false], ['すごい', [1, 1, 1]]], +        [['すごい', true], ['すごい', [1, 1, 1]]], +        [['すごーい', false], ['すごーい', [1, 1, 1, 1]]], +        [['すごーい', true], ['すごい', [1, 2, 1]]], +        [['すごーーい', false], ['すごーい', [1, 1, 2, 1]]], +        [['すごーーい', true], ['すごい', [1, 3, 1]]], +        [['すっごーい', false], ['すっごーい', [1, 1, 1, 1, 1]]], +        [['すっごーい', true], ['すごい', [2, 2, 1]]], +        [['すっっごーーい', false], ['すっごーい', [1, 2, 1, 2, 1]]], +        [['すっっごーーい', true], ['すごい', [3, 3, 1]]], + +        [['', false], ['', []]], +        [['', true], ['', []]], +        [['っ', false], ['っ', [1]]], +        [['っ', true], ['', [1]]], +        [['っっ', false], ['っ', [2]]], +        [['っっ', true], ['', [2]]], +        [['っっっ', false], ['っ', [3]]], +        [['っっっ', true], ['', [3]]] +    ]; + +    for (const [[text, fullCollapse], [expected, expectedSourceMapping]] of data) { +        const sourceMap = new TextSourceMap(text); +        const actual1 = jp.collapseEmphaticSequences(text, fullCollapse, null); +        const actual2 = jp.collapseEmphaticSequences(text, fullCollapse, sourceMap); +        assert.strictEqual(actual1, expected); +        assert.strictEqual(actual2, expected); +        if (typeof expectedSourceMapping !== 'undefined') { +            assert.ok(sourceMap.equals(new TextSourceMap(text, expectedSourceMapping))); +        } +    } +} +  function testIsMoraPitchHigh() {      const data = [          [[0, 0], false], @@ -463,6 +515,7 @@ function main() {      testConvertAlphabeticToKana();      testDistributeFurigana();      testDistributeFuriganaInflected(); +    testCollapseEmphaticSequences();      testIsMoraPitchHigh();      testGetKanaMorae();  } diff --git a/test/test-object-property-accessor.js b/test/test-object-property-accessor.js index 47d2e451..0773ba6e 100644 --- a/test/test-object-property-accessor.js +++ b/test/test-object-property-accessor.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-schema.js b/test/test-schema.js index 5f9915fd..7620ab16 100644 --- a/test/test-schema.js +++ b/test/test-schema.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/test-text-source-map.js b/test/test-text-source-map.js index 25bd8fc2..f092de2c 100644 --- a/test/test-text-source-map.js +++ b/test/test-text-source-map.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/yomichan-test.js b/test/yomichan-test.js index 5fa7730b..3351ecdf 100644 --- a/test/yomichan-test.js +++ b/test/yomichan-test.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by diff --git a/test/yomichan-vm.js b/test/yomichan-vm.js index ff478844..97faa03e 100644 --- a/test/yomichan-vm.js +++ b/test/yomichan-vm.js @@ -1,6 +1,5 @@  /* - * Copyright (C) 2020  Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> + * Copyright (C) 2020  Yomichan Authors   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by |