aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-06-14 16:07:23 -0400
committerAlex Yatskov <alex@foosoft.net>2016-06-14 20:44:38 -0700
commitad617221308b04e8f26ec52d876603e7aec3a03d (patch)
tree005364d7c5485a1b470530b55f90f4e5ed8d6f4c /ext/bg/js
parentcaf067883275f9b46259c2dbbf1f36aafc7e9108 (diff)
Use `let` instead of `const` in for loops.
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/deinflector.js14
-rw-r--r--ext/bg/js/dictionary.js6
-rw-r--r--ext/bg/js/options.js2
-rw-r--r--ext/bg/js/translator.js18
-rw-r--r--ext/bg/js/yomichan.js14
5 files changed, 27 insertions, 27 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js
index ec43f037..a0a72872 100644
--- a/ext/bg/js/deinflector.js
+++ b/ext/bg/js/deinflector.js
@@ -26,12 +26,12 @@ class Deinflection {
}
validate(validator) {
- for (const tags of validator(this.term)) {
+ for (let tags of validator(this.term)) {
if (this.tags.length === 0) {
return true;
}
- for (const tag of this.tags) {
+ for (let tag of this.tags) {
if (tags.indexOf(tag) !== -1) {
return true;
}
@@ -47,11 +47,11 @@ class Deinflection {
this.children.push(child);
}
- for (const rule in rules) {
+ for (let rule in rules) {
const variants = rules[rule];
- for (const v of variants) {
+ for (let v of variants) {
let allowed = this.tags.length === 0;
- for (const tag of this.tags) {
+ for (let tag of this.tags) {
//
// TODO: Handle addons through tags.json or rules.json
//
@@ -83,8 +83,8 @@ class Deinflection {
}
const paths = [];
- for (const child of this.children) {
- for (const path of child.gather()) {
+ for (let child of this.children) {
+ for (let path of child.gather()) {
if (this.rule.length > 0) {
path.rules.push(this.rule);
}
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index cc7b507c..9ec23117 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -34,7 +34,7 @@ class Dictionary {
findTerm(term) {
let results = [];
- for (const name in this.termDicts) {
+ for (let name in this.termDicts) {
const dict = this.termDicts[name];
const indices = dict.indices[term] || [];
@@ -48,7 +48,7 @@ class Dictionary {
// TODO: Handle addons through data.
//
- for (const tag of tags) {
+ for (let tag of tags) {
if (tag.startsWith('v5') && tag !== 'v5') {
addons.push('v5');
} else if (tag.startsWith('vs-')) {
@@ -74,7 +74,7 @@ class Dictionary {
findKanji(kanji) {
const results = [];
- for (const name in this.kanjiDicts) {
+ for (let name in this.kanjiDicts) {
const def = this.kanjiDicts[name][kanji];
if (def) {
const [k, o, g] = def;
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index d0b7f4ca..eefba95e 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -33,7 +33,7 @@ function sanitizeOptions(options) {
ankiKanjiFields: {}
};
- for (const key in defaults) {
+ for (let key in defaults) {
if (!options.hasOwnProperty(key)) {
options[key] = defaults[key];
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index be1102f9..bf1538e2 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -45,7 +45,7 @@ class Translator {
}
const pendingLoads = [];
- for (const key of files) {
+ for (let key of files) {
pendingLoads.push(key);
Translator.loadData(this.paths[key], (response) => {
switch (key) {
@@ -80,7 +80,7 @@ class Translator {
const dfs = this.deinflector.deinflect(term, t => {
const tags = [];
- for (const d of this.dictionary.findTerm(t)) {
+ for (let d of this.dictionary.findTerm(t)) {
tags.push(d.tags);
}
@@ -91,13 +91,13 @@ class Translator {
continue;
}
- for (const df of dfs) {
+ for (let df of dfs) {
this.processTerm(groups, df.source, df.tags, df.rules, df.root);
}
}
let definitions = [];
- for (const key in groups) {
+ for (let key in groups) {
definitions.push(groups[key]);
}
@@ -130,7 +130,7 @@ class Translator {
});
let length = 0;
- for (const result of definitions) {
+ for (let result of definitions) {
length = Math.max(length, result.source.length);
}
@@ -141,7 +141,7 @@ class Translator {
let definitions = [];
const processed = {};
- for (const c of text) {
+ for (let c of text) {
if (!processed[c]) {
definitions = definitions.concat(this.dictionary.findKanji(c));
processed[c] = true;
@@ -152,13 +152,13 @@ class Translator {
}
processTerm(groups, source, tags, rules=[], root='') {
- for (const entry of this.dictionary.findTerm(root)) {
+ for (let entry of this.dictionary.findTerm(root)) {
if (entry.id in groups) {
continue;
}
let matched = tags.length == 0;
- for (const tag of tags) {
+ for (let tag of tags) {
if (entry.tags.indexOf(tag) !== -1) {
matched = true;
break;
@@ -167,7 +167,7 @@ class Translator {
let popular = false;
let tagItems = [];
- for (const tag of entry.tags) {
+ for (let tag of entry.tags) {
const tagItem = this.tags[tag];
if (tagItem && entry.addons.indexOf(tag) === -1) {
tagItems.push({
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 2c13e8c7..92ed8a27 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -22,7 +22,7 @@ class Yomichan {
Handlebars.partials = Handlebars.templates;
Handlebars.registerHelper('kanjiLinks', function(options) {
let result = '';
- for (const c of options.fn(this)) {
+ for (let c of options.fn(this)) {
if (Translator.isKanji(c)) {
result += Handlebars.templates['kanji-link.html']({kanji: c}).trim();
} else {
@@ -111,7 +111,7 @@ class Yomichan {
notifyTabs(name, value) {
chrome.tabs.query({}, (tabs) => {
- for (const tab of tabs) {
+ for (let tab of tabs) {
chrome.tabs.sendMessage(tab.id, {name, value}, () => null);
}
});
@@ -155,7 +155,7 @@ class Yomichan {
formatField(field, definition, mode) {
const supported = ['character', 'expression', 'glossary', 'kunyomi', 'onyomi', 'reading'];
- for (const key in definition) {
+ for (let key in definition) {
if (supported.indexOf(key) === -1) {
continue;
}
@@ -175,7 +175,7 @@ class Yomichan {
if (mode !== 'kanji' && key === 'glossary') {
value = '<ol>';
- for (const gloss of definition.glossary) {
+ for (let gloss of definition.glossary) {
value += `<li>${gloss}</li>`;
}
value += '</ol>';
@@ -201,7 +201,7 @@ class Yomichan {
note.modelName = this.options.ankiVocabModel;
}
- for (const name in fields) {
+ for (let name in fields) {
note.fields[name] = this.formatField(fields[name], definition, mode);
}
@@ -215,8 +215,8 @@ class Yomichan {
api_canAddDefinitions({definitions, modes, callback}) {
let notes = [];
- for (const definition of definitions) {
- for (const mode of modes) {
+ for (let definition of definitions) {
+ for (let mode of modes) {
notes.push(this.formatNote(definition, mode));
}
}