This commit is contained in:
Alex Yatskov 2016-11-05 18:24:45 -07:00
parent 92fbc14e0b
commit c24e179b10
3 changed files with 22 additions and 3 deletions

View File

@ -20,7 +20,7 @@
class Dictionary { class Dictionary {
constructor() { constructor() {
this.db = null; this.db = null;
this.dbVer = 5; this.dbVer = 4;
this.entities = null; this.entities = null;
} }
@ -131,6 +131,14 @@ class Dictionary {
}); });
} }
getDictionaries() {
if (this.db === null) {
return Promise.reject('database not initialized');
}
return this.db.dictionaries.toArray();
}
importTermDict(indexUrl, callback) { importTermDict(indexUrl, callback) {
if (this.db === null) { if (this.db === null) {
return Promise.reject('database not initialized'); return Promise.reject('database not initialized');
@ -204,6 +212,6 @@ class Dictionary {
}); });
}; };
return importJsonDb(indexUrl, null, entriesLoaded); return importJsonDb(indexUrl, indexLoaded, entriesLoaded);
} }
} }

View File

@ -154,6 +154,16 @@ function populateAnkiDeckAndModel(opts) {
}); });
} }
function populateDictionaries() {
const dictionaries = $('.dictionaries');
yomichan().translator.dictionary.getDictionaries().then(rows => {
for (const row of rows) {
const dictionary = $('<p>').text(row.dictionary);
dictionaries.append(dictionary);
}
});
}
function populateAnkiFields(element, opts) { function populateAnkiFields(element, opts) {
const table = element.closest('.tab-pane').find('.anki-fields'); const table = element.closest('.tab-pane').find('.anki-fields');
table.find('tbody').remove(); table.find('tbody').remove();
@ -274,6 +284,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);
populateDictionaries();
populateAnkiDeckAndModel(opts); populateAnkiDeckAndModel(opts);
updateVisibility(opts); updateVisibility(opts);
}); });

View File

@ -65,7 +65,7 @@
<div> <div>
<h3>Dictionaries</h3> <h3>Dictionaries</h3>
<div name="dictionaries"> <div class="dictionaries">
</div> </div>
</div> </div>