This commit is contained in:
Alex Yatskov 2017-08-14 23:22:37 -07:00
parent 61dde5b3b7
commit 211e5d1155
4 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 Alex Yatskov <alex@foosoft.net> * Copyright (C) 2016-2017 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net> * Author: Alex Yatskov <alex@foosoft.net>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 Alex Yatskov <alex@foosoft.net> * Copyright (C) 2016-2017 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net> * Author: Alex Yatskov <alex@foosoft.net>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -20,7 +20,7 @@
class DisplayFloat extends Display { class DisplayFloat extends Display {
constructor() { constructor() {
super($('#spinner'), $('#definitions')); super($('#spinner'), $('#definitions'));
$(window).on('message', e => this.onMessage(e)); $(window).on('message', utilAsync(this.onMessage.bind(this)));
} }
onError(error) { onError(error) {

View File

@ -33,14 +33,14 @@ class Frontend {
try { try {
this.options = await apiOptionsGet(); this.options = await apiOptionsGet();
window.addEventListener('message', e => this.onFrameMessage(e)); window.addEventListener('message', this.onFrameMessage.bind(this));
window.addEventListener('mousedown', e => this.onMouseDown(e)); window.addEventListener('mousedown', this.onMouseDown.bind(this));
window.addEventListener('mousemove', e => this.onMouseMove(e)); window.addEventListener('mousemove', this.onMouseMove.bind(this));
window.addEventListener('mouseover', e => this.onMouseOver(e)); window.addEventListener('mouseover', this.onMouseOver.bind(this));
window.addEventListener('mouseup', e => this.onMouseUp(e)); window.addEventListener('mouseup', this.onMouseUp.bind(this));
window.addEventListener('resize', e => this.onResize(e)); window.addEventListener('resize', this.onResize.bind(this));
chrome.runtime.onMessage.addListener(({action, params}, sender, callback) => this.onBgMessage(action, params, sender, callback)); chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this));
} catch (e) { } catch (e) {
this.onError(e); this.onError(e);
} }
@ -124,7 +124,7 @@ class Frontend {
this.searchClear(); this.searchClear();
} }
onBgMessage(action, params, sender, callback) { onBgMessage({action, params}, sender, callback) {
const handlers = { const handlers = {
optionsSet: options => { optionsSet: options => {
this.options = options; this.options = options;

View File

@ -17,6 +17,12 @@
*/ */
function utilAsync(func) {
return function(...args) {
func.apply(this, args);
};
}
function utilInvoke(action, params={}) { function utilInvoke(action, params={}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {