summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/yomichan.js4
-rw-r--r--ext/bg/options.html4
-rw-r--r--ext/fg/js/api.js4
-rw-r--r--ext/fg/js/client.js1
-rw-r--r--ext/fg/js/frame.js33
5 files changed, 23 insertions, 23 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 0187f76f..1714e778 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -156,6 +156,10 @@ class Yomichan {
this.ankiInvoke('modelNames', {}, null, callback);
}
+ api_getModelFieldNames({callback}) {
+ this.ankiInvoke('modelFieldNames', {}, null, callback);
+ }
+
api_getOptions({callback}) {
callback(this.options);
}
diff --git a/ext/bg/options.html b/ext/bg/options.html
index cd0710aa..ae7e4257 100644
--- a/ext/bg/options.html
+++ b/ext/bg/options.html
@@ -100,7 +100,7 @@
<th>Value</th>
</tr>
</thead>
- <tbody id="ankiVocabFields">
+ <tbody class="ankiFields">
</tbody>
</table>
</div>
@@ -126,7 +126,7 @@
<th>Value</th>
</tr>
</thead>
- <tbody id="ankiKanjiFields">
+ <tbody class="ankiFields">
</tbody>
</table>
</div>
diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js
index 462eafd1..ecd8dd36 100644
--- a/ext/fg/js/api.js
+++ b/ext/fg/js/api.js
@@ -17,10 +17,6 @@
*/
-//
-// Background APIs
-//
-
function bgSendMessage(action, params, callback) {
chrome.runtime.sendMessage({action, params}, callback);
}
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index bb25c4e4..932cd10f 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -104,6 +104,7 @@ class Client {
} else {
const sequence = ++this.sequence;
range.setLength(length);
+
bgRenderText(
{defs: definitions, root: this.fgRoot, options: this.options, sequence: sequence},
'term-list.html',
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 66d3a054..a61bb9ee 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -42,26 +42,25 @@ function onDomContentLoaded() {
}
function onMessage(e) {
- const {action, params} = e.data, handlers = {
- setActionState: ({index, state, sequence}) => {
- for (const mode in state) {
- const matches = document.querySelectorAll(`.action-link[data-sequence="${sequence}"][data-index="${index}"][data-mode="${mode}"]`);
- if (matches.length === 0) {
- return;
- }
+ const {action, params} = e.data, method = window['api_' + action];
+ if (typeof(method) === 'function') {
+ method(params);
+ }
+}
- const classes = matches[0].classList;
- if (state[mode]) {
- classes.remove('disabled');
- } else {
- classes.add('disabled');
- }
- }
+function api_setActionState({index, state, sequence}) {
+ for (const mode in state) {
+ const matches = document.querySelectorAll(`.action-link[data-sequence="${sequence}"][data-index="${index}"][data-mode="${mode}"]`);
+ if (matches.length === 0) {
+ return;
}
- };
- if (handlers.hasOwnProperty(action)) {
- handlers[action](params);
+ const classes = matches[0].classList;
+ if (state[mode]) {
+ classes.remove('disabled');
+ } else {
+ classes.add('disabled');
+ }
}
}