From c242e49c7f10943c2a9515e8b60f0b675a992573 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 20 Mar 2016 18:27:11 -0700 Subject: [PATCH] Cleanup --- ext/content.js | 2 +- ext/jp/deinflector.js | 24 ++++++++++-------------- ext/jp/translator.js | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ext/content.js b/ext/content.js index aa51d758..4938805f 100644 --- a/ext/content.js +++ b/ext/content.js @@ -19,7 +19,7 @@ function getRangeAtCursor(e, lookAhead) { const range = document.caretRangeFromPoint(e.clientX, e.clientY); if (range === null) { - return null + return null; } const node = range.startContainer; diff --git a/ext/jp/deinflector.js b/ext/jp/deinflector.js index e93da29e..e4457507 100644 --- a/ext/jp/deinflector.js +++ b/ext/jp/deinflector.js @@ -23,7 +23,6 @@ class Deinflection { this.term = term; this.tags = tags; this.rule = rule; - this.success = false; } validate(validator) { @@ -63,17 +62,15 @@ class Deinflection { } } - // FIX - // if (!allowed || !this.term.endswith(kanaIn)) { - // continue; - // } + if (!allowed || !this.term.endsWith(kanaIn)) { + continue; + } - // FIX - // const term = self.term[:-kanaIn.length] + kanaOut; - // const child = new Deinflection(term, tagsOut, rule); - // if (child.deinflect(validator, rules)) { - // this.children.append(child); - // } + const term = self.term.slice(0, -kanaIn.length) + kanaOut; + const child = new Deinflection(term, tagsOut, rule); + if (child.deinflect(validator, rules)) { + this.children.append(child); + } } } @@ -82,8 +79,7 @@ class Deinflection { searchTags(tag, tags) { for (const t of tags) { - // FIX - if (re.search(tag, t)) { + if (tag === t) { return true; } } @@ -123,7 +119,7 @@ class Deinflector { } deinflect(term, validator) { - const node = new Deinflection(term) + const node = new Deinflection(term); if (node.deinflect(validator, this.rules)) { return node.gather(); } diff --git a/ext/jp/translator.js b/ext/jp/translator.js index c69b6786..4086a5bc 100644 --- a/ext/jp/translator.js +++ b/ext/jp/translator.js @@ -57,7 +57,7 @@ trans.initialize({ rules: 'jp/data/rules.json', edict: 'jp/data/edict.json', enamdict: 'jp/data/enamdict.json', - kanjidic: 'jp/data/kanjidic.json', + kanjidic: 'jp/data/kanjidic.json' }, function() { alert('Loaded'); // alert(trans.dictionary.findTerm('猫'));