aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/background.html2
-rw-r--r--ext/bg/js/backend.js18
-rw-r--r--ext/bg/js/dictionary-database.js (renamed from ext/bg/js/database.js)2
-rw-r--r--ext/bg/js/dictionary-importer.js12
4 files changed, 17 insertions, 17 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 11ea002f..0591032d 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -32,7 +32,7 @@
<script src="/bg/js/clipboard-monitor.js"></script>
<script src="/bg/js/conditions.js"></script>
<script src="/bg/js/generic-database.js"></script>
- <script src="/bg/js/database.js"></script>
+ <script src="/bg/js/dictionary-database.js"></script>
<script src="/bg/js/dictionary-importer.js"></script>
<script src="/bg/js/deinflector.js"></script>
<script src="/bg/js/dictionary.js"></script>
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 547b32d0..4791bfb5 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -21,7 +21,7 @@
* AudioSystem
* AudioUriBuilder
* ClipboardMonitor
- * Database
+ * DictionaryDatabase
* DictionaryImporter
* Environment
* JsonSchema
@@ -43,9 +43,9 @@
class Backend {
constructor() {
this._environment = new Environment();
- this._database = new Database();
+ this._dictionaryDatabase = new DictionaryDatabase();
this._dictionaryImporter = new DictionaryImporter();
- this._translator = new Translator(this._database);
+ this._translator = new Translator(this._dictionaryDatabase);
this._anki = new AnkiConnect();
this._mecab = new Mecab();
this._clipboardMonitor = new ClipboardMonitor({getClipboard: this._onApiClipboardGet.bind(this)});
@@ -193,7 +193,7 @@ class Backend {
await this._environment.prepare();
try {
- await this._database.prepare();
+ await this._dictionaryDatabase.prepare();
} catch (e) {
yomichan.logError(e);
}
@@ -709,11 +709,11 @@ class Backend {
async _onApiPurgeDatabase() {
this._translator.clearDatabaseCaches();
- await this._database.purge();
+ await this._dictionaryDatabase.purge();
}
async _onApiGetMedia({targets}) {
- return await this._database.getMedia(targets);
+ return await this._dictionaryDatabase.getMedia(targets);
}
_onApiLog({error, level, context}) {
@@ -747,12 +747,12 @@ class Backend {
}
async _onApiImportDictionaryArchive({archiveContent, details}, sender, onProgress) {
- return await this._dictionaryImporter.import(this._database, archiveContent, details, onProgress);
+ return await this._dictionaryImporter.import(this._dictionaryDatabase, archiveContent, details, onProgress);
}
async _onApiDeleteDictionary({dictionaryName}, sender, onProgress) {
this._translator.clearDatabaseCaches();
- await this._database.deleteDictionary(dictionaryName, {rate: 1000}, onProgress);
+ await this._dictionaryDatabase.deleteDictionary(dictionaryName, {rate: 1000}, onProgress);
}
async _onApiModifySettings({targets, source}) {
@@ -966,7 +966,7 @@ class Backend {
}
async _importDictionary(archiveSource, onProgress, details) {
- return await this._dictionaryImporter.import(this._database, archiveSource, onProgress, details);
+ return await this._dictionaryImporter.import(this._dictionaryDatabase, archiveSource, onProgress, details);
}
async _textParseScanning(text, options) {
diff --git a/ext/bg/js/database.js b/ext/bg/js/dictionary-database.js
index 47f1ebdd..c48320cd 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/dictionary-database.js
@@ -20,7 +20,7 @@
* dictFieldSplit
*/
-class Database {
+class DictionaryDatabase {
constructor() {
this._db = new GenericDatabase();
this._dbName = 'dict';
diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js
index 10e30cec..12f3129d 100644
--- a/ext/bg/js/dictionary-importer.js
+++ b/ext/bg/js/dictionary-importer.js
@@ -27,11 +27,11 @@ class DictionaryImporter {
this._schemas = new Map();
}
- async import(database, archiveSource, details, onProgress) {
- if (!database) {
+ async import(dictionaryDatabase, archiveSource, details, onProgress) {
+ if (!dictionaryDatabase) {
throw new Error('Invalid database');
}
- if (!database.isPrepared()) {
+ if (!dictionaryDatabase.isPrepared()) {
throw new Error('Database is not ready');
}
@@ -60,7 +60,7 @@ class DictionaryImporter {
}
// Verify database is not already imported
- if (await database.dictionaryExists(dictionaryTitle)) {
+ if (await dictionaryDatabase.dictionaryExists(dictionaryTitle)) {
throw new Error('Dictionary is already imported');
}
@@ -168,7 +168,7 @@ class DictionaryImporter {
// Add dictionary
const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported});
- database.bulkAdd('dictionaries', [summary], 0, 1);
+ dictionaryDatabase.bulkAdd('dictionaries', [summary], 0, 1);
// Add data
const errors = [];
@@ -188,7 +188,7 @@ class DictionaryImporter {
const count = Math.min(maxTransactionLength, ii - i);
try {
- await database.bulkAdd(objectStoreName, entries, i, count);
+ await dictionaryDatabase.bulkAdd(objectStoreName, entries, i, count);
} catch (e) {
errors.push(errorToJson(e));
}