User dictionary importing
This commit is contained in:
parent
8f995194bb
commit
da29797dcf
@ -30,9 +30,9 @@ class Translator {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadJson('bg/data/rules.json').then(rules => {
|
return loadJsonInt('bg/data/rules.json').then(rules => {
|
||||||
this.deinflector.setRules(rules);
|
this.deinflector.setRules(rules);
|
||||||
return loadJson('bg/data/tags.json');
|
return loadJsonInt('bg/data/tags.json');
|
||||||
}).then(tagMeta => {
|
}).then(tagMeta => {
|
||||||
this.tagMeta = tagMeta;
|
this.tagMeta = tagMeta;
|
||||||
return this.database.prepare();
|
return this.database.prepare();
|
||||||
|
@ -113,11 +113,15 @@ function loadJson(url) {
|
|||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText)));
|
xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText)));
|
||||||
xhr.addEventListener('error', () => reject('failed to execute network request'));
|
xhr.addEventListener('error', () => reject('failed to execute network request'));
|
||||||
xhr.open('GET', chrome.extension.getURL(url));
|
xhr.open('GET', url);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadJsonInt(url) {
|
||||||
|
return loadJson(chrome.extension.getURL(url));
|
||||||
|
}
|
||||||
|
|
||||||
function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
|
function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
|
||||||
const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/'));
|
const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/'));
|
||||||
return loadJson(indexUrl).then(index => {
|
return loadJson(indexUrl).then(index => {
|
||||||
|
Loading…
Reference in New Issue
Block a user