WIP
This commit is contained in:
parent
1d29dd8ba7
commit
a9fb566884
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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-theme.min.css">
|
||||
</head>
|
||||
@ -25,6 +25,7 @@
|
||||
<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>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>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>
|
||||
|
@ -39,6 +39,18 @@ class Database {
|
||||
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) {
|
||||
if (this.db === null) {
|
||||
return Promise.reject('database not initialized');
|
||||
|
@ -134,20 +134,19 @@ function onDictionaryDelete() {
|
||||
dictProgress.find('div').css('width', `${current / total * 100.0}%`);
|
||||
};
|
||||
|
||||
database().deleteDictionary(dictGroup.data('title'), callback).then(() => {
|
||||
dictGroup.slideUp();
|
||||
}).catch(error => {
|
||||
database().deleteDictionary(dictGroup.data('title'), callback).catch(error => {
|
||||
dictError.show().find('span').text(error);
|
||||
}).then(() => {
|
||||
dictSpinner.hide();
|
||||
dictProgress.hide();
|
||||
dictControls.show();
|
||||
return loadOptions().then(opts => populateDictionaries(opts));
|
||||
});
|
||||
}
|
||||
|
||||
function onDictionaryImport() {
|
||||
const dictImport = $(this);
|
||||
dictImport.prop('disabled', true);
|
||||
const dictImporter = $('#dict-importer');
|
||||
dictImporter.hide();
|
||||
|
||||
const dictError = $('#dict-error');
|
||||
dictError.hide();
|
||||
@ -174,7 +173,7 @@ function onDictionaryImport() {
|
||||
}).catch(error => {
|
||||
dictError.show().find('span').text(error);
|
||||
}).then(() => {
|
||||
dictImport.prop('disabled', false);
|
||||
dictImporter.show();
|
||||
dictUrl.val('');
|
||||
dictUrl.trigger('input');
|
||||
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) {
|
||||
if (!e.originalEvent && !e.isTrigger) {
|
||||
return;
|
||||
@ -383,6 +397,7 @@ $(document).ready(() => {
|
||||
$('input, select').not('.anki-model').change(onOptionsChanged);
|
||||
$('.anki-model').change(onAnkiModelChanged);
|
||||
|
||||
$('#dict-purge').click(onPurgeDb);
|
||||
$('#dict-importer a').click(onDictionarySetUrl);
|
||||
$('#dict-import').click(onDictionaryImport);
|
||||
$('#dict-url').on('input', onDictionaryUpdateUrl);
|
||||
|
@ -73,7 +73,7 @@
|
||||
<p class="help-block">
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
|
||||
<div class="alert alert-warning" id="dict-warning">
|
||||
<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 class="alert alert-danger" id="dict-error">
|
||||
@ -106,7 +106,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user