aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-07 08:29:21 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-07 08:29:21 -0800
commita18f3be559b9a8298f93f04837d400a1fff0b2b9 (patch)
tree4223d737f1aee4e43c21ac514a089fa5ffca8d80
parentc11b24cb37948c9cf7dc91c97cdc01ba65db875b (diff)
Renaming things
-rw-r--r--ext/bg/background.html2
-rw-r--r--ext/bg/js/database.js (renamed from ext/bg/js/dictionary.js)12
-rw-r--r--ext/bg/js/options-form.js4
-rw-r--r--ext/bg/js/translator.js18
4 files changed, 18 insertions, 18 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 1bb36cf8..49fc6d0f 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -9,7 +9,7 @@
<script src="js/ankinull.js"></script>
<script src="js/templates.js"></script>
<script src="js/util.js"></script>
- <script src="js/dictionary.js"></script>
+ <script src="js/database.js"></script>
<script src="js/deinflector.js"></script>
<script src="js/translator.js"></script>
<script src="js/options.js"></script>
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/database.js
index a7bca2f1..19e3228f 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/database.js
@@ -17,14 +17,14 @@
*/
-class Dictionary {
+class Database {
constructor() {
this.db = null;
this.dbVer = 6;
this.entities = null;
}
- initDb() {
+ init() {
if (this.db !== null) {
return Promise.reject('database already initialized');
}
@@ -39,8 +39,8 @@ class Dictionary {
});
}
- prepareDb() {
- this.initDb();
+ prepare() {
+ this.init();
return this.db.meta.get('version').then(row => {
return row ? row.value : 0;
@@ -56,13 +56,13 @@ class Dictionary {
this.db = null;
return db.delete().then(() => {
- this.initDb();
+ this.init();
return false;
});
});
}
- sealDb() {
+ seal() {
if (this.db === null) {
return Promise.reject('database not initialized');
}
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 2f2fe6fd..14143d81 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -166,7 +166,7 @@ function populateDictionaries(opts) {
const container = $('.dicts');
container.empty();
- yomichan().translator.dictionary.getDictionaries().then(rows => {
+ yomichan().translator.database.getDictionaries().then(rows => {
rows.forEach(row => {
const dictOpts = opts.dictionaries[row.title] || {enableTerms: true, enableKanji: false};
const html = Handlebars.templates['dictionary.html']({
@@ -184,7 +184,7 @@ function populateDictionaries(opts) {
$('.dict-delete').click(e => {
const dict = $(e.target).closest('.dict');
const title = dict.data('title');
- yomichan().translator.dictionary.deleteDictionary(title);
+ yomichan().translator.database.deleteDictionary(title);
dict.slideUp();
});
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 0a0a6109..e65acd60 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -21,7 +21,7 @@ class Translator {
constructor() {
this.loaded = false;
this.tagMeta = null;
- this.dictionary = new Dictionary();
+ this.database = new Database();
this.deinflector = new Deinflector();
}
@@ -35,7 +35,7 @@ class Translator {
return loadJson('bg/data/tags.json');
}).then(tagMeta => {
this.tagMeta = tagMeta;
- return this.dictionary.prepareDb();
+ return this.database.prepare();
}).then(exists => {
if (exists) {
return;
@@ -62,11 +62,11 @@ class Translator {
};
return Promise.all([
- this.dictionary.importDictionary('bg/data/edict/index.json', bankCallback),
- this.dictionary.importDictionary('bg/data/enamdict/index.json', bankCallback),
- this.dictionary.importDictionary('bg/data/kanjidic/index.json', bankCallback),
+ this.database.importDictionary('bg/data/edict/index.json', bankCallback),
+ this.database.importDictionary('bg/data/enamdict/index.json', bankCallback),
+ this.database.importDictionary('bg/data/kanjidic/index.json', bankCallback),
]).then(() => {
- return this.dictionary.sealDb();
+ return this.database.seal();
}).then(() => {
if (callback) {
callback({state: 'end', progress: 100.0});
@@ -84,7 +84,7 @@ class Translator {
for (let i = text.length; i > 0; --i) {
deinflectPromises.push(
this.deinflector.deinflect(text.slice(0, i), term => {
- return this.dictionary.findTerm(term).then(definitions => definitions.map(definition => definition.tags));
+ return this.database.findTerm(term).then(definitions => definitions.map(definition => definition.tags));
}).then(deinflects => {
const processPromises = [];
for (const deinflect of deinflects) {
@@ -143,7 +143,7 @@ class Translator {
for (const c of text) {
if (!processed[c]) {
- promises.push(this.dictionary.findKanji(c).then((definitions) => definitions));
+ promises.push(this.database.findKanji(c).then((definitions) => definitions));
processed[c] = true;
}
}
@@ -152,7 +152,7 @@ class Translator {
}
processTerm(groups, source, tags, rules, root) {
- return this.dictionary.findTerm(root).then(definitions => {
+ return this.database.findTerm(root).then(definitions => {
for (const definition of definitions) {
if (definition.id in groups) {
continue;