Cleanup
This commit is contained in:
parent
f65e9f2570
commit
997947caed
@ -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);
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -17,10 +17,6 @@
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Background APIs
|
||||
//
|
||||
|
||||
function bgSendMessage(action, params, callback) {
|
||||
chrome.runtime.sendMessage({action, params}, callback);
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -42,8 +42,13 @@ function onDomContentLoaded() {
|
||||
}
|
||||
|
||||
function onMessage(e) {
|
||||
const {action, params} = e.data, handlers = {
|
||||
setActionState: ({index, state, sequence}) => {
|
||||
const {action, params} = e.data, method = window['api_' + action];
|
||||
if (typeof(method) === 'function') {
|
||||
method(params);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -57,12 +62,6 @@ function onMessage(e) {
|
||||
classes.add('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (handlers.hasOwnProperty(action)) {
|
||||
handlers[action](params);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', onDomContentLoaded, false);
|
||||
|
Loading…
Reference in New Issue
Block a user