aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/anki.js2
-rw-r--r--ext/bg/js/audio.js4
-rw-r--r--ext/bg/js/database.js26
-rw-r--r--ext/bg/js/request.js4
-rw-r--r--ext/bg/js/settings.js8
-rw-r--r--ext/bg/settings.html23
6 files changed, 28 insertions, 39 deletions
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js
index c327969f..183f37bc 100644
--- a/ext/bg/js/anki.js
+++ b/ext/bg/js/anki.js
@@ -62,7 +62,7 @@ class AnkiConnect {
if (this.remoteVersion < this.localVersion) {
this.remoteVersion = await this.ankiInvoke('version');
if (this.remoteVersion < this.localVersion) {
- throw 'extension and plugin versions incompatible';
+ throw 'Extension and plugin versions incompatible';
}
}
}
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index 0952887e..ce47490c 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -57,7 +57,7 @@ async function audioBuildUrl(definition, mode, cache={}) {
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.japanesepod101.com/learningcenter/reference/dictionary_post');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.addEventListener('error', () => reject('failed to scrape audio data'));
+ xhr.addEventListener('error', () => reject('Failed to scrape audio data'));
xhr.addEventListener('load', () => {
cache[definition.expression] = xhr.responseText;
resolve(xhr.responseText);
@@ -87,7 +87,7 @@ async function audioBuildUrl(definition, mode, cache={}) {
} else {
const xhr = new XMLHttpRequest();
xhr.open('GET', `http://jisho.org/search/${definition.expression}`);
- xhr.addEventListener('error', () => reject('failed to scrape audio data'));
+ xhr.addEventListener('error', () => reject('Failed to scrape audio data'));
xhr.addEventListener('load', () => {
cache[definition.expression] = xhr.responseText;
resolve(xhr.responseText);
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index f94c572e..e7316b3a 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -25,7 +25,7 @@ class Database {
async prepare() {
if (this.db) {
- throw 'database already initialized';
+ throw 'Database already initialized';
}
this.db = new Dexie('dict');
@@ -46,7 +46,7 @@ class Database {
async purge() {
if (!this.db) {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
this.db.close();
@@ -59,7 +59,7 @@ class Database {
async findTerms(term, titles) {
if (!this.db) {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
const results = [];
@@ -83,7 +83,7 @@ class Database {
async findTermFreq(term, titles) {
if (!this.db) {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
const results = [];
@@ -98,7 +98,7 @@ class Database {
async findKanji(kanji, titles) {
if (!this.db) {
- return Promise.reject('database not initialized');
+ throw 'Database not initialized';
}
const results = [];
@@ -121,7 +121,7 @@ class Database {
async findKanjiFreq(kanji, titles) {
if (!this.db) {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
const results = [];
@@ -136,7 +136,7 @@ class Database {
async findTagForTitle(name, title) {
if (!this.db) {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
this.tagCache[title] = this.tagCache[title] || {};
@@ -159,23 +159,23 @@ class Database {
if (this.db) {
return this.db.dictionaries.toArray();
} else {
- throw 'database not initialized';
+ throw 'Database not initialized';
}
}
async importDictionary(archive, callback) {
if (!this.db) {
- return Promise.reject('database not initialized');
+ throw 'Database not initialized';
}
const indexDataLoaded = async summary => {
if (summary.version > 2) {
- throw 'unsupported dictionary version';
+ throw 'Unsupported dictionary version';
}
const count = await this.db.dictionaries.where('title').equals(summary.title).count();
if (count > 0) {
- throw `dictionary "${summary.title}" is already imported`;
+ throw 'Dictionary is already imported';
}
await this.db.dictionaries.add(summary);
@@ -329,12 +329,12 @@ class Database {
const indexFile = zip.files['index.json'];
if (!indexFile) {
- throw 'no dictionary index found in archive';
+ throw 'No dictionary index found in archive';
}
const index = JSON.parse(await indexFile.async('string'));
if (!index.title || !index.revision) {
- throw 'unrecognized dictionary format';
+ throw 'Unrecognized dictionary format';
}
const summary = {
diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js
index 94fd135a..e4359863 100644
--- a/ext/bg/js/request.js
+++ b/ext/bg/js/request.js
@@ -22,7 +22,7 @@ function requestJson(url, action, params) {
const xhr = new XMLHttpRequest();
xhr.overrideMimeType('application/json');
xhr.addEventListener('load', () => resolve(xhr.responseText));
- xhr.addEventListener('error', () => reject('failed to execute network request'));
+ xhr.addEventListener('error', () => reject('Failed to connect'));
xhr.open(action, url);
if (params) {
xhr.send(JSON.stringify(params));
@@ -34,7 +34,7 @@ function requestJson(url, action, params) {
return JSON.parse(responseText);
}
catch (e) {
- return Promise.reject('invalid JSON response');
+ return Promise.reject('Invalid response');
}
});
}
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index d73d7509..161e9abe 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -142,7 +142,7 @@ async function onReady() {
$('#scan-length').val(options.scanning.length);
$('#scan-modifier-key').val(options.scanning.modifier);
- $('#dict-purge').click(utilAsync(onDictionaryPurge));
+ $('#dict-purge-link').click(utilAsync(onDictionaryPurge));
$('#dict-file').change(utilAsync(onDictionaryImport));
$('#anki-enable').prop('checked', options.anki.enable);
@@ -179,7 +179,7 @@ $(document).ready(utilAsync(onReady));
function dictionaryErrorShow(error) {
const dialog = $('#dict-error');
if (error) {
- dialog.show().find('span').text(error);
+ dialog.show().text(error);
} else {
dialog.hide();
}
@@ -245,7 +245,7 @@ async function onDictionaryPurge(e) {
e.preventDefault();
const dictControls = $('#dict-importer, #dict-groups').hide();
- const dictProgress = $('#dict-purge-progress').show();
+ const dictProgress = $('#dict-purge').show();
try {
dictionaryErrorShow();
@@ -314,7 +314,7 @@ function ankiSpinnerShow(show) {
function ankiErrorShow(error) {
const dialog = $('#anki-error');
if (error) {
- dialog.show().find('span').text(error);
+ dialog.show().text(error);
}
else {
dialog.hide();
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index c2612967..4315d74b 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="/mixed/lib/bootstrap/css/bootstrap-theme.min.css">
<style>
#anki-spinner, #anki-general, #anki-error,
- #dict-spinner, #dict-error, #dict-warning, #dict-purge-progress, #dict-import-progress,
+ #dict-spinner, #dict-error, #dict-warning, #dict-purge, #dict-import-progress,
#debug, .options-advanced {
display: none;
}
@@ -129,24 +129,16 @@
<p class="help-block">
Yomichan can import and use a variety of dictionary formats. Unneeded dictionaries can be disabled,
- or you can simply <a href="#" id="dict-purge">purge the database</a> to delete everything.
+ or you can simply <a href="#" id="dict-purge-link">purge the database</a> to delete everything.
</p>
<p class="help-block">
Please visit the <a href="https://foosoft.net/projects/yomichan" target="_blank">Yomichan</a> homepage to download free
dictionaries that you can use with this extension.
</p>
- <div id="dict-purge-progress" class="text-danger">Dictionary data is being purged, please be patient...</div>
-
- <div class="alert alert-warning" id="dict-warning">
- <strong>Warning:</strong>
- <span>no dictionaries found; please use the importer below to install packaged dictionaries</span>
- </div>
-
- <div class="alert alert-danger" id="dict-error">
- <strong>Error:</strong>
- <span></span>
- </div>
+ <div class="text-danger" id="dict-purge">Dictionary data is being purged, please be patient...</div>
+ <div class="alert alert-warning" id="dict-warning">No dictionaries have been installed</div>
+ <div class="alert alert-danger" id="dict-error"></div>
<div id="dict-groups"></div>
@@ -174,10 +166,7 @@
<a href="https://foosoft.net/projects/anki-connect/" target="_blank">AnkiConnect</a> plugin.
</p>
- <div class="alert alert-danger" id="anki-error">
- <strong>Error:</strong>
- <span></span>
- </div>
+ <div class="alert alert-danger" id="anki-error"></div>
<div class="checkbox">
<label><input type="checkbox" id="anki-enable"> Enable Anki integration</label>