summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/api.js2
-rw-r--r--ext/bg/js/backend.js2
-rw-r--r--ext/bg/js/display-window.js19
3 files changed, 13 insertions, 10 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 9dbb69c1..bc2693e5 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -35,7 +35,7 @@ async function apiOptionsSet(options) {
// to the DOM across to the background page, causing the options object to
// become a "DeadObject" after the options page is closed. The workaround used
// here is to create a deep copy of the options object.
- backend().optionsSet(JSON.parse(JSON.stringify(options)));
+ backend().onOptionsUpdated(JSON.parse(JSON.stringify(options)));
}
async function apiOptionsGet() {
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 6b345e6d..1c058433 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -36,7 +36,7 @@ window.yomichan_backend = new class {
}
}
- optionsSet(options) {
+ onOptionsUpdated(options) {
this.options = options;
if (!options.general.enable) {
diff --git a/ext/bg/js/display-window.js b/ext/bg/js/display-window.js
index 1f607510..52c0cafa 100644
--- a/ext/bg/js/display-window.js
+++ b/ext/bg/js/display-window.js
@@ -21,12 +21,11 @@ window.displayWindow = new class extends Display {
constructor() {
super($('#spinner'), $('#content'));
- const search = $('#search');
- search.click(this.onSearch.bind(this));
+ this.search = $('#search').click(this.onSearch.bind(this));
+ this.query = $('#query').on('input', this.inputSearch.bind(this));
+ this.intro = $('#intro');
- const query = $('#query');
- query.on('input', () => search.prop('disabled', query.val().length === 0));
- window.wanakana.bind(query.get(0));
+ window.wanakana.bind(this.query.get(0));
}
handleError(error) {
@@ -34,15 +33,19 @@ window.displayWindow = new class extends Display {
}
clearSearch() {
- $('#query').focus().select();
+ this.query.focus().select();
+ }
+
+ inputSearch() {
+ this.search.prop('disabled', this.query.val().length === 0);
}
async onSearch(e) {
e.preventDefault();
try {
- $('#intro').slideUp();
- const {length, definitions} = await apiTermsFind($('#query').val());
+ this.intro.slideUp();
+ const {length, definitions} = await apiTermsFind(this.query.val());
super.showTermDefs(definitions, await apiOptionsGet());
} catch (e) {
this.handleError(e);