summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-23 22:28:37 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-23 22:28:37 -0700
commitb2d9b613ad3a673abb20033808877962545644d4 (patch)
tree46f95c67332136992ae0f346ab0d10d056a4dc62 /ext/bg/js/dictionary.js
parent8b5f74f99bdbaeb1b7c72614f2a71abfc72be479 (diff)
Cleanup
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();
- });
- }
}