workaround for broken const in firefox
This commit is contained in:
parent
bf9925ec9c
commit
8efe5b1fbf
@ -87,7 +87,7 @@ class Database {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.cacheTagMeta(dictionaries);
|
return this.cacheTagMeta(dictionaries);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
for (const result of results) {
|
for (let result of results) {
|
||||||
result.tagMeta = this.tagMetaCache[result.dictionary] || {};
|
result.tagMeta = this.tagMetaCache[result.dictionary] || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class Database {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.cacheTagMeta(dictionaries);
|
return this.cacheTagMeta(dictionaries);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
for (const result of results) {
|
for (let result of results) {
|
||||||
result.tagMeta = this.tagMetaCache[result.dictionary] || {};
|
result.tagMeta = this.tagMetaCache[result.dictionary] || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const dictionary of dictionaries) {
|
for (let dictionary of dictionaries) {
|
||||||
if (this.tagMetaCache[dictionary]) {
|
if (this.tagMetaCache[dictionary]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ class Database {
|
|||||||
|
|
||||||
return this.db.dictionaries.add({title, version, revision, hasTerms, hasKanji}).then(() => {
|
return this.db.dictionaries.add({title, version, revision, hasTerms, hasKanji}).then(() => {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
for (const tag in tagMeta || {}) {
|
for (let tag in tagMeta || {}) {
|
||||||
const meta = tagMeta[tag];
|
const meta = tagMeta[tag];
|
||||||
const row = sanitizeTag({
|
const row = sanitizeTag({
|
||||||
name: tag,
|
name: tag,
|
||||||
@ -266,7 +266,7 @@ class Database {
|
|||||||
|
|
||||||
const termsLoaded = (title, entries, total, current) => {
|
const termsLoaded = (title, entries, total, current) => {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
for (const [expression, reading, tags, rules, score, ...glossary] of entries) {
|
for (let [expression, reading, tags, rules, score, ...glossary] of entries) {
|
||||||
rows.push({
|
rows.push({
|
||||||
expression,
|
expression,
|
||||||
reading,
|
reading,
|
||||||
@ -287,7 +287,7 @@ class Database {
|
|||||||
|
|
||||||
const kanjiLoaded = (title, entries, total, current) => {
|
const kanjiLoaded = (title, entries, total, current) => {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) {
|
for (let [character, onyomi, kunyomi, tags, ...meanings] of entries) {
|
||||||
rows.push({
|
rows.push({
|
||||||
character,
|
character,
|
||||||
onyomi,
|
onyomi,
|
||||||
|
@ -32,8 +32,8 @@ class Deinflection {
|
|||||||
if (this.rules.length === 0) {
|
if (this.rules.length === 0) {
|
||||||
this.definitions = definitions;
|
this.definitions = definitions;
|
||||||
} else {
|
} else {
|
||||||
for (const rule of this.rules) {
|
for (let rule of this.rules) {
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
if (definition.rules.includes(rule)) {
|
if (definition.rules.includes(rule)) {
|
||||||
this.definitions.push(definition);
|
this.definitions.push(definition);
|
||||||
}
|
}
|
||||||
@ -46,11 +46,11 @@ class Deinflection {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const reason in reasons) {
|
for (let reason in reasons) {
|
||||||
for (const variant of reasons[reason]) {
|
for (let variant of reasons[reason]) {
|
||||||
let accept = this.rules.length === 0;
|
let accept = this.rules.length === 0;
|
||||||
if (!accept) {
|
if (!accept) {
|
||||||
for (const rule of this.rules) {
|
for (let rule of this.rules) {
|
||||||
if (variant.rulesIn.includes(rule)) {
|
if (variant.rulesIn.includes(rule)) {
|
||||||
accept = true;
|
accept = true;
|
||||||
break;
|
break;
|
||||||
@ -95,8 +95,8 @@ class Deinflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const child of this.children) {
|
for (let child of this.children) {
|
||||||
for (const result of child.gather()) {
|
for (let result of child.gather()) {
|
||||||
if (this.reason.length > 0) {
|
if (this.reason.length > 0) {
|
||||||
result.reasons.push(this.reason);
|
result.reasons.push(this.reason);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ function optionsSetDefaults(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const combine = (target, source) => {
|
const combine = (target, source) => {
|
||||||
for (const key in source) {
|
for (let key in source) {
|
||||||
if (!(key in target)) {
|
if (!(key in target)) {
|
||||||
target[key] = source[key];
|
target[key] = source[key];
|
||||||
}
|
}
|
||||||
@ -104,8 +104,8 @@ function optionsVersion(options) {
|
|||||||
'{glossary-list}': '{glossary}'
|
'{glossary-list}': '{glossary}'
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const name in fields) {
|
for (let name in fields) {
|
||||||
for (const fixup in fixups) {
|
for (let fixup in fixups) {
|
||||||
fields[name] = fields[name].replace(fixup, fixups[fixup]);
|
fields[name] = fields[name].replace(fixup, fixups[fixup]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ function optionsVersion(options) {
|
|||||||
fixupFields(options.anki.terms.fields);
|
fixupFields(options.anki.terms.fields);
|
||||||
fixupFields(options.anki.kanji.fields);
|
fixupFields(options.anki.kanji.fields);
|
||||||
|
|
||||||
for (const title in options.dictionaries) {
|
for (let title in options.dictionaries) {
|
||||||
const dictionary = options.dictionaries[title];
|
const dictionary = options.dictionaries[title];
|
||||||
dictionary.enabled = dictionary.enableTerms || dictionary.enableKanji;
|
dictionary.enabled = dictionary.enableTerms || dictionary.enableKanji;
|
||||||
dictionary.priority = 0;
|
dictionary.priority = 0;
|
||||||
@ -127,8 +127,8 @@ function optionsVersion(options) {
|
|||||||
'{glossary-list}': '{glossary}'
|
'{glossary-list}': '{glossary}'
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const name in fields) {
|
for (let name in fields) {
|
||||||
for (const fixup in fixups) {
|
for (let fixup in fixups) {
|
||||||
fields[name] = fields[name].replace(fixup, fixups[fixup]);
|
fields[name] = fields[name].replace(fixup, fixups[fixup]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ class Translator {
|
|||||||
}
|
}
|
||||||
}).then(deinflections => {
|
}).then(deinflections => {
|
||||||
let definitions = [];
|
let definitions = [];
|
||||||
for (const deinflection of deinflections) {
|
for (let deinflection of deinflections) {
|
||||||
for (const definition of deinflection.definitions) {
|
for (let definition of deinflection.definitions) {
|
||||||
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
||||||
tags.push(buildDictTag(definition.dictionary));
|
tags.push(buildDictTag(definition.dictionary));
|
||||||
definitions.push({
|
definitions.push({
|
||||||
@ -76,7 +76,7 @@ class Translator {
|
|||||||
definitions = sortTermDefs(definitions, dictionaries);
|
definitions = sortTermDefs(definitions, dictionaries);
|
||||||
|
|
||||||
let length = 0;
|
let length = 0;
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
length = Math.max(length, definition.source.length);
|
length = Math.max(length, definition.source.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class Translator {
|
|||||||
const processed = {};
|
const processed = {};
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
for (const c of text) {
|
for (let c of text) {
|
||||||
if (!processed[c]) {
|
if (!processed[c]) {
|
||||||
promises.push(this.database.findKanji(c, titles));
|
promises.push(this.database.findKanji(c, titles));
|
||||||
processed[c] = true;
|
processed[c] = true;
|
||||||
@ -104,7 +104,7 @@ class Translator {
|
|||||||
|
|
||||||
return Promise.all(promises).then(defSets => {
|
return Promise.all(promises).then(defSets => {
|
||||||
const definitions = defSets.reduce((a, b) => a.concat(b), []);
|
const definitions = defSets.reduce((a, b) => a.concat(b), []);
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
||||||
tags.push(buildDictTag(definition.dictionary));
|
tags.push(buildDictTag(definition.dictionary));
|
||||||
definition.tags = sortTags(tags);
|
definition.tags = sortTags(tags);
|
||||||
@ -130,7 +130,7 @@ class Translator {
|
|||||||
|
|
||||||
return Promise.all(promises).then(results => {
|
return Promise.all(promises).then(results => {
|
||||||
let deinflections = [];
|
let deinflections = [];
|
||||||
for (const result of results) {
|
for (let result of results) {
|
||||||
deinflections = deinflections.concat(result);
|
deinflections = deinflections.concat(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processKanji(definitions) {
|
processKanji(definitions) {
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
|
||||||
definition.tags = sortTags(tags);
|
definition.tags = sortTags(tags);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
function kanjiLinks(options) {
|
function kanjiLinks(options) {
|
||||||
let result = '';
|
let result = '';
|
||||||
for (const c of options.fn(this)) {
|
for (let c of options.fn(this)) {
|
||||||
if (isKanji(c)) {
|
if (isKanji(c)) {
|
||||||
result += `<a href="#" class="kanji-link">${c}</a>`;
|
result += `<a href="#" class="kanji-link">${c}</a>`;
|
||||||
} else {
|
} else {
|
||||||
@ -41,7 +41,7 @@ function isKanji(c) {
|
|||||||
|
|
||||||
function enabledDicts(options) {
|
function enabledDicts(options) {
|
||||||
const dictionaries = {};
|
const dictionaries = {};
|
||||||
for (const title in options.dictionaries) {
|
for (let title in options.dictionaries) {
|
||||||
const dictionary = options.dictionaries[title];
|
const dictionary = options.dictionaries[title];
|
||||||
if (dictionary.enabled) {
|
if (dictionary.enabled) {
|
||||||
dictionaries[title] = dictionary;
|
dictionaries[title] = dictionary;
|
||||||
@ -104,7 +104,7 @@ function sortTermDefs(definitions, dictionaries=null) {
|
|||||||
|
|
||||||
function undupeTermDefs(definitions) {
|
function undupeTermDefs(definitions) {
|
||||||
const definitionGroups = {};
|
const definitionGroups = {};
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
const definitionExisting = definitionGroups[definition.id];
|
const definitionExisting = definitionGroups[definition.id];
|
||||||
if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) {
|
if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) {
|
||||||
definitionGroups[definition.id] = definition;
|
definitionGroups[definition.id] = definition;
|
||||||
@ -112,7 +112,7 @@ function undupeTermDefs(definitions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const definitionsUnique = [];
|
const definitionsUnique = [];
|
||||||
for (const key in definitionGroups) {
|
for (let key in definitionGroups) {
|
||||||
definitionsUnique.push(definitionGroups[key]);
|
definitionsUnique.push(definitionGroups[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ function undupeTermDefs(definitions) {
|
|||||||
|
|
||||||
function groupTermDefs(definitions, dictionaries) {
|
function groupTermDefs(definitions, dictionaries) {
|
||||||
const groups = {};
|
const groups = {};
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
const key = [definition.source, definition.expression].concat(definition.reasons);
|
const key = [definition.source, definition.expression].concat(definition.reasons);
|
||||||
if (definition.reading) {
|
if (definition.reading) {
|
||||||
key.push(definition.reading);
|
key.push(definition.reading);
|
||||||
@ -136,7 +136,7 @@ function groupTermDefs(definitions, dictionaries) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const key in groups) {
|
for (let key in groups) {
|
||||||
const groupDefs = groups[key];
|
const groupDefs = groups[key];
|
||||||
const firstDef = groupDefs[0];
|
const firstDef = groupDefs[0];
|
||||||
sortTermDefs(groupDefs, dictionaries);
|
sortTermDefs(groupDefs, dictionaries);
|
||||||
@ -160,7 +160,7 @@ function buildDictTag(name) {
|
|||||||
function buildTag(name, meta) {
|
function buildTag(name, meta) {
|
||||||
const tag = {name};
|
const tag = {name};
|
||||||
const symbol = name.split(':')[0];
|
const symbol = name.split(':')[0];
|
||||||
for (const prop in meta[symbol] || {}) {
|
for (let prop in meta[symbol] || {}) {
|
||||||
tag[prop] = meta[symbol][prop];
|
tag[prop] = meta[symbol][prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ function formatField(field, definition, mode, options) {
|
|||||||
'url'
|
'url'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const marker of markers) {
|
for (let marker of markers) {
|
||||||
const data = {
|
const data = {
|
||||||
marker,
|
marker,
|
||||||
definition,
|
definition,
|
||||||
@ -303,7 +303,7 @@ function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let chain = Promise.resolve();
|
let chain = Promise.resolve();
|
||||||
for (const loader of loaders) {
|
for (let loader of loaders) {
|
||||||
chain = chain.then(loader);
|
chain = chain.then(loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class Yomichan {
|
|||||||
|
|
||||||
tabInvokeAll(action, params) {
|
tabInvokeAll(action, params) {
|
||||||
chrome.tabs.query({}, tabs => {
|
chrome.tabs.query({}, tabs => {
|
||||||
for (const tab of tabs) {
|
for (let tab of tabs) {
|
||||||
chrome.tabs.sendMessage(tab.id, {action, params}, () => null);
|
chrome.tabs.sendMessage(tab.id, {action, params}, () => null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -106,7 +106,7 @@ class Yomichan {
|
|||||||
fields: []
|
fields: []
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const name in fields) {
|
for (let name in fields) {
|
||||||
if (fields[name].includes('{audio}')) {
|
if (fields[name].includes('{audio}')) {
|
||||||
audio.fields.push(name);
|
audio.fields.push(name);
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ class Yomichan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const name in fields) {
|
for (let name in fields) {
|
||||||
note.fields[name] = formatField(
|
note.fields[name] = formatField(
|
||||||
fields[name],
|
fields[name],
|
||||||
definition,
|
definition,
|
||||||
@ -175,8 +175,8 @@ class Yomichan {
|
|||||||
|
|
||||||
api_canAddDefinitions({definitions, modes, callback}) {
|
api_canAddDefinitions({definitions, modes, callback}) {
|
||||||
const notes = [];
|
const notes = [];
|
||||||
for (const definition of definitions) {
|
for (let definition of definitions) {
|
||||||
for (const mode of modes) {
|
for (let mode of modes) {
|
||||||
notes.push(this.formatNote(definition, mode));
|
notes.push(this.formatNote(definition, mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
states.forEach((state, index) => {
|
states.forEach((state, index) => {
|
||||||
for (const mode in state) {
|
for (let mode in state) {
|
||||||
const button = this.findAddNoteButton(index, mode);
|
const button = this.findAddNoteButton(index, mode);
|
||||||
if (state[mode]) {
|
if (state[mode]) {
|
||||||
button.removeClass('disabled');
|
button.removeClass('disabled');
|
||||||
@ -147,7 +147,7 @@ class Frame {
|
|||||||
url += `&kana=${encodeURIComponent(definition.reading)}`;
|
url += `&kana=${encodeURIComponent(definition.reading)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in this.audioCache) {
|
for (let key in this.audioCache) {
|
||||||
this.audioCache[key].pause();
|
this.audioCache[key].pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user