WIP
This commit is contained in:
parent
1d29dd8ba7
commit
a9fb566884
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Yomichan</title>
|
<title>Welcome to Yomichan!</title>
|
||||||
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
|
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
|
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
|
||||||
</head>
|
</head>
|
||||||
@ -25,6 +25,7 @@
|
|||||||
<ol>
|
<ol>
|
||||||
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
|
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
|
||||||
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
|
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
|
||||||
|
<li>Import any dictionaries (bundled or custom) you wish to use for Kanji and term searches.</li>
|
||||||
<li>Hold down <kbd>Shift</kbd> (or the middle mouse button) as you hover over text to see term definitions.</li>
|
<li>Hold down <kbd>Shift</kbd> (or the middle mouse button) as you hover over text to see term definitions.</li>
|
||||||
<li>Resize the definitions window by dragging the bottom-left corner inwards or outwards.</li>
|
<li>Resize the definitions window by dragging the bottom-left corner inwards or outwards.</li>
|
||||||
<li>Click on Kanji in the definition window to view additional information about that character.</li>
|
<li>Click on Kanji in the definition window to view additional information about that character.</li>
|
||||||
|
@ -39,6 +39,18 @@ class Database {
|
|||||||
return this.db.open();
|
return this.db.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
purge() {
|
||||||
|
if (this.db === null) {
|
||||||
|
return Promise.reject('database not initialized');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.db.close();
|
||||||
|
return this.db.delete().then(() => {
|
||||||
|
this.db = null;
|
||||||
|
this.prepare();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
findTerm(term, dictionaries) {
|
findTerm(term, dictionaries) {
|
||||||
if (this.db === null) {
|
if (this.db === null) {
|
||||||
return Promise.reject('database not initialized');
|
return Promise.reject('database not initialized');
|
||||||
|
@ -134,20 +134,19 @@ function onDictionaryDelete() {
|
|||||||
dictProgress.find('div').css('width', `${current / total * 100.0}%`);
|
dictProgress.find('div').css('width', `${current / total * 100.0}%`);
|
||||||
};
|
};
|
||||||
|
|
||||||
database().deleteDictionary(dictGroup.data('title'), callback).then(() => {
|
database().deleteDictionary(dictGroup.data('title'), callback).catch(error => {
|
||||||
dictGroup.slideUp();
|
|
||||||
}).catch(error => {
|
|
||||||
dictError.show().find('span').text(error);
|
dictError.show().find('span').text(error);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
dictSpinner.hide();
|
dictSpinner.hide();
|
||||||
dictProgress.hide();
|
dictProgress.hide();
|
||||||
dictControls.show();
|
dictControls.show();
|
||||||
|
return loadOptions().then(opts => populateDictionaries(opts));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDictionaryImport() {
|
function onDictionaryImport() {
|
||||||
const dictImport = $(this);
|
const dictImporter = $('#dict-importer');
|
||||||
dictImport.prop('disabled', true);
|
dictImporter.hide();
|
||||||
|
|
||||||
const dictError = $('#dict-error');
|
const dictError = $('#dict-error');
|
||||||
dictError.hide();
|
dictError.hide();
|
||||||
@ -174,7 +173,7 @@ function onDictionaryImport() {
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dictError.show().find('span').text(error);
|
dictError.show().find('span').text(error);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
dictImport.prop('disabled', false);
|
dictImporter.show();
|
||||||
dictUrl.val('');
|
dictUrl.val('');
|
||||||
dictUrl.trigger('input');
|
dictUrl.trigger('input');
|
||||||
dictProgress.hide();
|
dictProgress.hide();
|
||||||
@ -313,6 +312,21 @@ function populateDictionaries(opts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onPurgeDb() {
|
||||||
|
const dictError = $('#dict-error');
|
||||||
|
dictError.hide();
|
||||||
|
|
||||||
|
const dictSpinner = $('#dict-spinner');
|
||||||
|
dictSpinner.show();
|
||||||
|
|
||||||
|
return database().purge().catch(error => {
|
||||||
|
dictError.show().find('span').text(error);
|
||||||
|
}).then(() => {
|
||||||
|
dictSpinner.hide();
|
||||||
|
return loadOptions().then(opts => populateDictionaries(opts));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onOptionsChanged(e) {
|
function onOptionsChanged(e) {
|
||||||
if (!e.originalEvent && !e.isTrigger) {
|
if (!e.originalEvent && !e.isTrigger) {
|
||||||
return;
|
return;
|
||||||
@ -383,6 +397,7 @@ $(document).ready(() => {
|
|||||||
$('input, select').not('.anki-model').change(onOptionsChanged);
|
$('input, select').not('.anki-model').change(onOptionsChanged);
|
||||||
$('.anki-model').change(onAnkiModelChanged);
|
$('.anki-model').change(onAnkiModelChanged);
|
||||||
|
|
||||||
|
$('#dict-purge').click(onPurgeDb);
|
||||||
$('#dict-importer a').click(onDictionarySetUrl);
|
$('#dict-importer a').click(onDictionarySetUrl);
|
||||||
$('#dict-import').click(onDictionaryImport);
|
$('#dict-import').click(onDictionaryImport);
|
||||||
$('#dict-url').on('input', onDictionaryUpdateUrl);
|
$('#dict-url').on('input', onDictionaryUpdateUrl);
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Yomichan can import both bundled and custom (see the <a href="https://foosoft.net/projects/yomichan-import">Yomichan Import</a>
|
Yomichan can import both bundled and custom (see the <a href="https://foosoft.net/projects/yomichan-import">Yomichan Import</a>
|
||||||
page for details) dictionaries. Although it is also possible to delete unneeded dictionaries, this operation is <em>extremely slow</em> and it is often
|
page for details) dictionaries. Although it is also possible to delete unneeded dictionaries, this operation is <em>extremely slow</em> and it is often
|
||||||
easier to disable them or simply <a href="javascript:resetDatabase();">reset the database</a>. Finally, please make sure to
|
easier to disable them or simply <a id="dict-purge">purge the database</a>. Finally, please make sure to
|
||||||
wait for import and delete operations to complete before closing this page.
|
wait for import and delete operations to complete before closing this page.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
<div class="alert alert-warning" id="dict-warning">
|
<div class="alert alert-warning" id="dict-warning">
|
||||||
<strong>No dictionaries found:</strong>
|
<strong>No dictionaries found:</strong>
|
||||||
<span>please use the dropdown below to install packaged and external dictionaries</span>
|
<span>please use the drop down below to install packaged and external dictionaries</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-danger" id="dict-error">
|
<div class="alert alert-danger" id="dict-error">
|
||||||
@ -106,7 +106,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="dict-url" class="form-control" placeholder="Dictionary import URL">
|
<input type="text" id="dict-url" class="form-control" placeholder="Dictionary import URL">
|
||||||
<div class="input-group-btn disabled">
|
<div class="input-group-btn">
|
||||||
<button type="button" id="dict-import" class="btn btn-primary" disabled>Import</button>
|
<button type="button" id="dict-import" class="btn btn-primary" disabled>Import</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user