aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/dictionary.js11
-rw-r--r--ext/bg/js/translator.js17
-rw-r--r--ext/fg/js/document.js4
-rw-r--r--ext/fg/js/frontend.js2
-rw-r--r--ext/fg/js/source.js22
-rw-r--r--ext/manifest.json2
6 files changed, 21 insertions, 37 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 49afc368..498eafcd 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -140,16 +140,17 @@ function dictTermsCompressTags(definitions) {
function dictTermsGroup(definitions, dictionaries) {
const groups = {};
for (const definition of definitions) {
- const key = [definition.source, definition.expression].concat(definition.reasons);
+ const key = [definition.source, definition.expression];
+ key.push(...definition.reasons);
if (definition.reading) {
key.push(definition.reading);
}
- const group = groups[key];
- if (group) {
- group.push(definition);
+ const keyString = key.toString();
+ if (groups.hasOwnProperty(keyString)) {
+ groups[keyString].push(definition);
} else {
- groups[key] = [definition];
+ groups[keyString] = [definition];
}
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index c6af1f4e..c89b43ff 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -186,7 +186,7 @@ class Translator {
let deinflections = await this.findTermDeinflections(text, titles, cache);
const textHiragana = jpKatakanaToHiragana(text);
if (text !== textHiragana) {
- deinflections = deinflections.concat(await this.findTermDeinflections(textHiragana, titles, cache));
+ deinflections.push(...await this.findTermDeinflections(textHiragana, titles, cache));
}
let definitions = [];
@@ -235,7 +235,7 @@ class Translator {
let deinflections = [];
for (let i = text.length; i > 0; --i) {
const textSlice = text.slice(0, i);
- deinflections = deinflections.concat(await this.deinflector.deinflect(textSlice, definer));
+ deinflections.push(...await this.deinflector.deinflect(textSlice, definer));
}
return deinflections;
@@ -247,7 +247,7 @@ class Translator {
const titles = Object.keys(dictionaries);
for (const c of text) {
if (!processed[c]) {
- definitions = definitions.concat(await this.database.findKanji(c, titles));
+ definitions.push(...await this.database.findKanji(c, titles));
processed[c] = true;
}
}
@@ -277,7 +277,7 @@ class Translator {
async buildTermFrequencies(definition, titles) {
let terms = [];
if (definition.expressions) {
- terms = terms.concat(definition.expressions);
+ terms.push(...definition.expressions);
} else {
terms.push(definition);
}
@@ -299,7 +299,7 @@ class Translator {
async expandTags(names, title) {
const tags = [];
for (const name of names) {
- const base = name.split(':')[0];
+ const base = Translator.getNameBase(name);
const meta = await this.database.findTagForTitle(base, title);
const tag = {name};
@@ -318,7 +318,7 @@ class Translator {
async expandStats(items, title) {
const stats = {};
for (const name in items) {
- const base = name.split(':')[0];
+ const base = Translator.getNameBase(name);
const meta = await this.database.findTagForTitle(base, title);
const group = stats[meta.category] = stats[meta.category] || [];
@@ -346,4 +346,9 @@ class Translator {
return stats;
}
+
+ static getNameBase(name) {
+ const pos = name.indexOf(':');
+ return (pos >= 0 ? name.substr(0, pos) : name);
+ }
}
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index bd876e5d..60b1b9bd 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -152,7 +152,7 @@ function docSentenceExtract(source, extent) {
if (quoteStack.length > 0 && c === quoteStack[0]) {
quoteStack.pop();
} else if (c in quotesBwd) {
- quoteStack = [quotesBwd[c]].concat(quoteStack);
+ quoteStack.unshift(quotesBwd[c]);
}
}
@@ -181,7 +181,7 @@ function docSentenceExtract(source, extent) {
if (quoteStack.length > 0 && c === quoteStack[0]) {
quoteStack.pop();
} else if (c in quotesFwd) {
- quoteStack = [quotesFwd[c]].concat(quoteStack);
+ quoteStack.unshift(quotesFwd[c]);
}
}
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6806e2c3..52620933 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -302,7 +302,7 @@ class Frontend {
}
const textSource = docRangeFromPoint(point, this.options);
- let hideResults = !textSource || !textSource.containsPoint(point);
+ let hideResults = textSource === null;
let searched = false;
let success = false;
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index 385b5001..18a1a976 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -59,11 +59,6 @@ class TextSourceRange {
return length - state.remainder;
}
- containsPoint(point) {
- const rect = this.getPaddedRect();
- return point.x >= rect.left && point.x <= rect.right;
- }
-
getRect() {
return this.range.getBoundingClientRect();
}
@@ -72,18 +67,6 @@ class TextSourceRange {
return TextSourceRange.getElementWritingMode(TextSourceRange.getParentElement(this.range.startContainer));
}
- getPaddedRect() {
- const range = this.range.cloneRange();
- const startOffset = range.startOffset;
- const endOffset = range.endOffset;
- const node = range.startContainer;
-
- range.setStart(node, Math.max(0, startOffset - 1));
- range.setEnd(node, Math.min(node.length, endOffset + 1));
-
- return range.getBoundingClientRect();
- }
-
select() {
const selection = window.getSelection();
selection.removeAllRanges();
@@ -334,11 +317,6 @@ class TextSourceElement {
return 0;
}
- containsPoint(point) {
- const rect = this.getRect();
- return point.x >= rect.left && point.x <= rect.right;
- }
-
getRect() {
return this.element.getBoundingClientRect();
}
diff --git a/ext/manifest.json b/ext/manifest.json
index 06d13dd1..86ee6b95 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Yomichan",
- "version": "1.7.5",
+ "version": "1.7.6",
"description": "Japanese dictionary with Anki integration (testing)",
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},