summaryrefslogtreecommitdiff
path: root/ext/bg/js/options-form.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-05-29 14:20:13 -0700
committerAlex Yatskov <alex@foosoft.net>2016-05-29 14:20:13 -0700
commit6f63999dce9f14103d6dfae155c4fc0c151ab8de (patch)
tree2a8621b94c0bc0dc3d66526b4545c093cde870ea /ext/bg/js/options-form.js
parent9ab95e6602e7bf327764f356efc388558856e6e3 (diff)
Adding version checking
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r--ext/bg/js/options-form.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 6e79303b..239b09d5 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -86,6 +86,17 @@ function populateAnkiDeckAndModel(opts) {
}});
}
+function updateAnkiStatus() {
+ $('.error-dlg').hide();
+ yomichan().api_getVersion({callback: (version) => {
+ if (version === null) {
+ $('.error-dlg-connection').show();
+ } else if (version !== yomichan().getApiVersion()) {
+ $('.error-dlg-version').show();
+ }
+ }});
+}
+
function populateAnkiFields(element, opts) {
const modelName = element.val();
if (modelName === null) {
@@ -119,6 +130,7 @@ function onOptionsGeneralChanged(e) {
saveOptions(optsNew, () => {
yomichan().setOptions(optsNew);
if (!optsOld.enableAnkiConnect && optsNew.enableAnkiConnect) {
+ updateAnkiStatus();
populateAnkiDeckAndModel(optsNew);
$('.options-anki').fadeIn();
} else if (optsOld.enableAnkiConnect && !optsNew.enableAnkiConnect) {
@@ -159,6 +171,7 @@ $(document).ready(() => {
$('.anki-model').change(onAnkiModelChanged);
if (opts.enableAnkiConnect) {
+ updateAnkiStatus();
populateAnkiDeckAndModel(opts);
$('.options-anki').show();
}