summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/dictionary.js2
-rw-r--r--ext/bg/translator.js19
-rw-r--r--ext/client.js4
3 files changed, 13 insertions, 12 deletions
diff --git a/ext/bg/dictionary.js b/ext/bg/dictionary.js
index 1264263a..a68c2daf 100644
--- a/ext/bg/dictionary.js
+++ b/ext/bg/dictionary.js
@@ -60,7 +60,7 @@ class Dictionary {
storeIndex(indices, term, index) {
if (term.length > 0) {
const indices = this.termIndices[term] || [];
- indices.push(term);
+ indices.push(index);
this.termIndices[term] = indices;
}
}
diff --git a/ext/bg/translator.js b/ext/bg/translator.js
index e76a1b07..23d5d964 100644
--- a/ext/bg/translator.js
+++ b/ext/bg/translator.js
@@ -19,9 +19,9 @@
class Translator {
constructor() {
- this.dictionary = new Dictionary();
- this.deinflector = new Deinflector();
- this.pendingLoads = [];
+ this.dictionary = new Dictionary();
+ this.deinflector = new Deinflector();
+ this.initialized = false;
}
loadData(paths, callback) {
@@ -30,8 +30,9 @@ class Translator {
return;
}
+ const pendingLoads = [];
for (const key of ['rules', 'edict', 'enamdict', 'kanjidic']) {
- this.pendingLoads.push(key);
+ pendingLoads.push(key);
Translator.loadData(paths[key], (response) => {
switch (key) {
case 'rules':
@@ -46,9 +47,9 @@ class Translator {
break;
}
- const index = this.pendingLoads.indexOf(key);
- this.pendingLoads = this.pendingLoads.splice(index, 1);
- if (this.pendingLoads.length === 0) {
+ pendingLoads.splice(pendingLoads.indexOf(key), 1);
+ if (pendingLoads.length === 0) {
+ this.initialized = true;
callback();
}
});
@@ -160,7 +161,9 @@ class Translator {
static parseCsv(data) {
const result = [];
for (const row of data.split('\n')) {
- result.push(row.split('\t'));
+ if (row.length > 0) {
+ result.push(row.split('\t'));
+ }
}
return result;
diff --git a/ext/client.js b/ext/client.js
index 1c8c0a9f..2d9a470f 100644
--- a/ext/client.js
+++ b/ext/client.js
@@ -27,9 +27,7 @@ class Client {
this.popup.classList.add('yomichan-popup');
this.popup.addEventListener('mousedown', (e) => e.stopPropagation());
this.popup.addEventListener('scroll', (e) => e.stopPropagation());
-
- const base = document.body.appendChild('div');
- base.createShadowRoot().appendChild(this.popup);
+ document.body.appendChild(this.popup);
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
window.addEventListener('mousedown', this.onMouseDown.bind(this));