aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/anki.js12
-rw-r--r--ext/bg/js/options-form.js49
-rw-r--r--ext/bg/js/yomichan.js16
3 files changed, 54 insertions, 23 deletions
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js
index a359f021..66cea094 100644
--- a/ext/bg/js/anki.js
+++ b/ext/bg/js/anki.js
@@ -43,6 +43,18 @@ class AnkiConnect {
return this.ankiInvokeSafe('modelFieldNames', {modelName}, null);
}
+ getStatus() {
+ return this.getVersion().then(version => {
+ if (version === null) {
+ return 'disconnected';
+ } else if (version === this.apiVersion) {
+ return 'ready';
+ } else {
+ return 'mismatch';
+ }
+ });
+ }
+
getVersion() {
return this.ankiInvoke('version', {}, null);
}
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 6508a9eb..653521d6 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -39,8 +39,25 @@ function modelIdToFieldOptKey(id) {
function modelIdToMarkers(id) {
return {
- 'anki-term-model': ['audio', 'expression', 'glossary', 'glossary-list', 'reading', 'sentence', 'tags', 'url'],
- 'anki-kanji-model': ['character', 'glossary', 'glossary-list', 'kunyomi', 'onyomi', 'url'],
+ 'anki-term-model': [
+ 'audio',
+ 'expression',
+ 'expression-furigana',
+ 'glossary',
+ 'glossary-list',
+ 'reading',
+ 'sentence',
+ 'tags',
+ 'url'
+ ],
+ 'anki-kanji-model': [
+ 'character',
+ 'glossary',
+ 'glossary-list',
+ 'kunyomi',
+ 'onyomi',
+ 'url'
+ ],
}[id];
}
@@ -111,19 +128,21 @@ function populateAnkiDeckAndModel(opts) {
}
function updateAnkiStatus() {
- $('.error-dlg').hide();
-
- yomichan().api_getVersion({callback: version => {
- if (version === null) {
- $('.error-dlg-connection').show();
- $('.options-anki-controls').hide();
- } else if (version !== yomichan().getApiVersion()) {
- $('.error-dlg-version').show();
- $('.options-anki-controls').hide();
- } else {
- $('.options-anki-controls').show();
- }
- }});
+ // $('.error-dlg').hide();
+
+ // yomichan().api_getVersion({callback: version => {
+ // if (version === null) {
+ // $('.error-dlg-connection').show();
+ // $('.options-anki-controls').hide();
+ // } else if (version !== yomichan().getApiVersion()) {
+ // $('.error-dlg-version').show();
+ // $('.options-anki-controls').hide();
+ // } else {
+ // $('.options-anki-controls').show();
+ // }
+ // }});
+
+ $('.options-anki-controls').show();
}
function populateAnkiFields(element, opts) {
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 25dbc23c..0038645c 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -103,10 +103,6 @@ class Yomichan {
this.tabInvokeAll('setOptions', this.options);
}
- getApiVersion() {
- return 1;
- }
-
tabInvokeAll(action, params) {
chrome.tabs.query({}, tabs => {
for (const tab of tabs) {
@@ -124,6 +120,7 @@ class Yomichan {
'audio',
'character',
'expression',
+ 'expression-furigana',
'glossary',
'glossary-list',
'kunyomi',
@@ -145,6 +142,13 @@ class Yomichan {
value = definition.reading;
}
break;
+ case 'expression-furigana':
+ if (mode === 'term_kana' && definition.reading) {
+ value = definition.reading;
+ } else {
+ value = `<ruby>${definition.expression}<rt>${definition.reading}</rt></ruby>`;
+ }
+ break;
case 'reading':
if (mode === 'term_kana') {
value = null;
@@ -274,10 +278,6 @@ class Yomichan {
api_getModelFieldNames({modelName, callback}) {
this.anki.getModelFieldNames(modelName).then(callback);
}
-
- api_getVersion({callback}) {
- this.anki.getVersion().then(callback);
- }
}
window.yomichan = new Yomichan();