summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/display-frame.js40
-rw-r--r--ext/fg/js/driver.js12
2 files changed, 30 insertions, 22 deletions
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js
index 16435a27..56b56861 100644
--- a/ext/fg/js/display-frame.js
+++ b/ext/fg/js/display-frame.js
@@ -41,31 +41,37 @@ window.displayFrame = new class extends Display {
handleError(error) {
if (window.orphaned) {
- this.api_showOrphaned();
+ this.showOrphaned();
} else {
errorShow(error);
}
}
- onMessage(e) {
- const {action, params} = e.originalEvent.data, method = this['api_' + action];
- if (typeof(method) === 'function') {
- method.call(this, params);
- }
+ showOrphaned() {
+ $('#content').hide();
+ $('#orphan').show();
}
- api_showTermDefs({definitions, options, context}) {
- window.scrollTo(0, 0);
- super.showTermDefs(definitions, options, context);
- }
+ onMessage(e) {
+ const handlers = new class {
+ api_showTermDefs({definitions, options, context}) {
+ window.scrollTo(0, 0);
+ this.showTermDefs(definitions, options, context);
+ }
- api_showKanjiDefs({definitions, options, context}) {
- window.scrollTo(0, 0);
- super.showKanjiDefs(defintions, options, context);
- }
+ api_showKanjiDefs({definitions, options, context}) {
+ window.scrollTo(0, 0);
+ this.showKanjiDefs(defintions, options, context);
+ }
- api_showOrphaned() {
- $('#content').hide();
- $('#orphan').show();
+ api_showOrphaned() {
+ this.showOrphaned();
+ }
+ };
+
+ const {action, params} = e.originalEvent.data, method = handlers[`api_${action}`];
+ if (typeof(method) === 'function') {
+ method.call(this, params);
+ }
}
};
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 73ddd84f..2cbe3e08 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -102,7 +102,13 @@ class Driver {
}
onBgMessage({action, params}, sender, callback) {
- const method = this['api_' + action];
+ const handlers = new class {
+ api_optionsSet(options) {
+ this.options = options;
+ }
+ };
+
+ const method = handlers[`api_${action}`];
if (typeof(method) === 'function') {
method.call(this, params);
}
@@ -205,10 +211,6 @@ class Driver {
errorShow(error);
}
}
-
- api_setOptions(options) {
- this.options = options;
- }
}
window.driver = new Driver();