aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/display-frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-04 18:24:57 -0800
committerAlex Yatskov <alex@foosoft.net>2017-03-04 18:24:57 -0800
commit30999c13d32e7f111db16814dc2cbb0f30825861 (patch)
tree3aa24f7045f10237aa744651844d18219d1890e6 /ext/fg/js/display-frame.js
parentb039d300249087aee18c7e8565ae7447d2cf5b15 (diff)
wip
Diffstat (limited to 'ext/fg/js/display-frame.js')
-rw-r--r--ext/fg/js/display-frame.js40
1 files changed, 23 insertions, 17 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);
+ }
}
};