summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/css/display-dark.css3
-rw-r--r--ext/mixed/css/display-default.css3
-rw-r--r--ext/mixed/css/display.css27
-rw-r--r--ext/mixed/display-templates.html4
-rw-r--r--ext/mixed/js/api.js7
-rw-r--r--ext/mixed/js/audio-system.js3
-rw-r--r--ext/mixed/js/core.js3
-rw-r--r--ext/mixed/js/display-context.js3
-rw-r--r--ext/mixed/js/display-generator.js240
-rw-r--r--ext/mixed/js/display.js7
-rw-r--r--ext/mixed/js/dom.js3
-rw-r--r--ext/mixed/js/japanese.js3
-rw-r--r--ext/mixed/js/object-property-accessor.js3
-rw-r--r--ext/mixed/js/scroll.js3
-rw-r--r--ext/mixed/js/template-handler.js3
-rw-r--r--ext/mixed/js/text-scanner.js3
-rw-r--r--ext/mixed/js/timer.js3
17 files changed, 152 insertions, 169 deletions
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