aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/driver.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/driver.js')
-rw-r--r--ext/fg/js/driver.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 5467a9f0..8904c12c 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -33,11 +33,11 @@ class Driver {
window.addEventListener('mousemove', this.onMouseMove.bind(this));
window.addEventListener('resize', e => this.searchClear());
- getOptions().then(options => {
+ Promise.all([getOptions(), isEnabled()]).then(([options, enabled]) => {
this.options = options;
- return isEnabled();
- }).then(enabled => {
this.enabled = enabled;
+ }).catch(error => {
+ this.handleError(error);
});
}
@@ -119,14 +119,14 @@ class Driver {
this.pendingLookup = true;
this.searchTerms(textSource).then(found => {
if (!found) {
- this.searchKanji(textSource).then(found => {
+ return this.searchKanji(textSource).then(found => {
if (!found && hideNotFound) {
this.searchClear();
}
});
}
}).catch(error => {
- window.alert('Error: ' + error);
+ this.handleError(error, textSource);
}).then(() => {
this.pendingLookup = false;
});
@@ -157,9 +157,6 @@ class Driver {
return true;
}
- }).catch(error => {
- window.alert('Error: ' + error);
- return false;
});
}
@@ -181,9 +178,6 @@ class Driver {
return true;
}
- }).catch(error => {
- window.alert('Error: ' + error);
- return false;
});
}
@@ -197,6 +191,17 @@ class Driver {
this.lastTextSource = null;
}
+ handleError(error, textSource) {
+ if (window.orphaned) {
+ if (textSource) {
+ this.popup.showNextTo(textSource.getRect());
+ this.popup.showOrphaned();
+ }
+ } else {
+ showError(error);
+ }
+ }
+
api_setOptions(options) {
this.options = options;
}