summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js17
1 files changed, 4 insertions, 13 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 8f04c458..3fceef65 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -92,7 +92,7 @@ class Dictionary {
importTermDict(indexUrl) {
const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/'));
- return Dictionary.loadJson(indexUrl).then((index) => {
+ return loadJson(indexUrl).then((index) => {
const entities = [];
for (const [name, value] of index.ents) {
entities.push({name, value});
@@ -111,7 +111,7 @@ class Dictionary {
for (let i = 0; i <= index.refs; ++i) {
const refUrl = `${indexDir}/ref_${i}.json`;
loaders.push(() => {
- return Dictionary.loadJson(refUrl).then((refs) => {
+ return loadJson(refUrl).then((refs) => {
const rows = [];
for (const [expression, reading, tags, ...glossary] of refs) {
rows.push({expression, reading, tags, glossary});
@@ -135,12 +135,12 @@ class Dictionary {
importKanjiDict(indexUrl) {
const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/'));
- return Dictionary.loadJson(indexUrl).then((index) => {
+ return loadJson(indexUrl).then((index) => {
const loaders = [];
for (let i = 0; i <= index.refs; ++i) {
const refUrl = `${indexDir}/ref_${i}.json`;
loaders.push(() => {
- return Dictionary.loadJson(refUrl).then((refs) => {
+ return loadJson(refUrl).then((refs) => {
const rows = [];
for (const [character, onyomi, kunyomi, tags, ...glossary] of refs) {
rows.push({character, onyomi, kunyomi, tags, glossary});
@@ -159,13 +159,4 @@ class Dictionary {
return chain;
});
}
-
- static loadJson(url) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
- xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText)));
- xhr.open('GET', chrome.extension.getURL(url), true);
- xhr.send();
- });
- }
}