aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-07 09:22:57 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-07 09:22:57 -0800
commitda29797dcf017e23e09ca6288e81899d12b8c9c2 (patch)
treec2f1fb8308f9b7d01fb90d15a244e533fd343570
parent8f995194bbf23a074a901c8fdaf4ddad22370dd3 (diff)
User dictionary importing
-rw-r--r--ext/bg/js/translator.js4
-rw-r--r--ext/bg/js/util.js6
2 files changed, 7 insertions, 3 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e65acd60..c33a0ea6 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -30,9 +30,9 @@ class Translator {
return Promise.resolve();
}
- return loadJson('bg/data/rules.json').then(rules => {
+ return loadJsonInt('bg/data/rules.json').then(rules => {
this.deinflector.setRules(rules);
- return loadJson('bg/data/tags.json');
+ return loadJsonInt('bg/data/tags.json');
}).then(tagMeta => {
this.tagMeta = tagMeta;
return this.database.prepare();
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 8a21b264..124438ed 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -113,11 +113,15 @@ function loadJson(url) {
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText)));
xhr.addEventListener('error', () => reject('failed to execute network request'));
- xhr.open('GET', chrome.extension.getURL(url));
+ xhr.open('GET', url);
xhr.send();
});
}
+function loadJsonInt(url) {
+ return loadJson(chrome.extension.getURL(url));
+}
+
function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/'));
return loadJson(indexUrl).then(index => {