summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 108c88e7..24050cf3 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -19,7 +19,7 @@
function kanjiLinks(options) {
let result = '';
- for (const c of options.fn(this)) {
+ for (let c of options.fn(this)) {
if (isKanji(c)) {
result += `<a href="#" class="kanji-link">${c}</a>`;
} else {
@@ -41,7 +41,7 @@ function isKanji(c) {
function enabledDicts(options) {
const dictionaries = {};
- for (const title in options.dictionaries) {
+ for (let title in options.dictionaries) {
const dictionary = options.dictionaries[title];
if (dictionary.enabled) {
dictionaries[title] = dictionary;
@@ -104,7 +104,7 @@ function sortTermDefs(definitions, dictionaries=null) {
function undupeTermDefs(definitions) {
const definitionGroups = {};
- for (const definition of definitions) {
+ for (let definition of definitions) {
const definitionExisting = definitionGroups[definition.id];
if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) {
definitionGroups[definition.id] = definition;
@@ -112,7 +112,7 @@ function undupeTermDefs(definitions) {
}
const definitionsUnique = [];
- for (const key in definitionGroups) {
+ for (let key in definitionGroups) {
definitionsUnique.push(definitionGroups[key]);
}
@@ -121,7 +121,7 @@ function undupeTermDefs(definitions) {
function groupTermDefs(definitions, dictionaries) {
const groups = {};
- for (const definition of definitions) {
+ for (let definition of definitions) {
const key = [definition.source, definition.expression].concat(definition.reasons);
if (definition.reading) {
key.push(definition.reading);
@@ -136,7 +136,7 @@ function groupTermDefs(definitions, dictionaries) {
}
const results = [];
- for (const key in groups) {
+ for (let key in groups) {
const groupDefs = groups[key];
const firstDef = groupDefs[0];
sortTermDefs(groupDefs, dictionaries);
@@ -160,7 +160,7 @@ function buildDictTag(name) {
function buildTag(name, meta) {
const tag = {name};
const symbol = name.split(':')[0];
- for (const prop in meta[symbol] || {}) {
+ for (let prop in meta[symbol] || {}) {
tag[prop] = meta[symbol][prop];
}
@@ -217,7 +217,7 @@ function formatField(field, definition, mode, options) {
'url'
];
- for (const marker of markers) {
+ for (let marker of markers) {
const data = {
marker,
definition,
@@ -240,6 +240,7 @@ function formatField(field, definition, mode, options) {
function loadJson(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
+ xhr.overrideMimeType('application/json');
xhr.addEventListener('load', () => resolve(xhr.responseText));
xhr.addEventListener('error', () => reject('failed to execute network request'));
xhr.open('GET', url);
@@ -303,7 +304,7 @@ function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
}
let chain = Promise.resolve();
- for (const loader of loaders) {
+ for (let loader of loaders) {
chain = chain.then(loader);
}