From 7f9a73135da4244e779f32179c7d19e6984bbc55 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 26 Nov 2019 15:07:11 -0500 Subject: [PATCH] Remove utilAsync --- ext/bg/js/settings-profiles.js | 14 +++++++------- ext/bg/js/settings.js | 8 ++++---- ext/bg/js/util.js | 6 ------ ext/fg/js/util.js | 6 ------ 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/ext/bg/js/settings-profiles.js b/ext/bg/js/settings-profiles.js index 3ae9db14..357a1b9b 100644 --- a/ext/bg/js/settings-profiles.js +++ b/ext/bg/js/settings-profiles.js @@ -35,16 +35,16 @@ async function profileOptionsSetup() { } function profileOptionsSetupEventListeners() { - $('#profile-target').change(utilAsync(onTargetProfileChanged)); + $('#profile-target').change((e) => onTargetProfileChanged(e)); $('#profile-name').change(onProfileNameChanged); - $('#profile-add').click(utilAsync(onProfileAdd)); - $('#profile-remove').click(utilAsync(onProfileRemove)); - $('#profile-remove-confirm').click(utilAsync(onProfileRemoveConfirm)); - $('#profile-copy').click(utilAsync(onProfileCopy)); - $('#profile-copy-confirm').click(utilAsync(onProfileCopyConfirm)); + $('#profile-add').click((e) => onProfileAdd(e)); + $('#profile-remove').click((e) => onProfileRemove(e)); + $('#profile-remove-confirm').click((e) => onProfileRemoveConfirm(e)); + $('#profile-copy').click((e) => onProfileCopy(e)); + $('#profile-copy-confirm').click((e) => onProfileCopyConfirm(e)); $('#profile-move-up').click(() => onProfileMove(-1)); $('#profile-move-down').click(() => onProfileMove(1)); - $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change(utilAsync(onProfileOptionsChanged)); + $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change((e) => onProfileOptionsChanged(e)); } function tryGetIntegerValue(selector, min, max) { diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index ab267c32..d1f9d0d1 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -155,8 +155,8 @@ async function formWrite(options) { } function formSetupEventListeners() { - $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change(utilAsync(onFormOptionsChanged)); - $('.anki-model').change(utilAsync(onAnkiModelChanged)); + $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change((e) => onFormOptionsChanged(e)); + $('.anki-model').change((e) => onAnkiModelChanged(e)); } function formUpdateVisibility(options) { @@ -219,7 +219,7 @@ async function onReady() { chrome.runtime.onMessage.addListener(onMessage); } -$(document).ready(utilAsync(onReady)); +$(document).ready(() => onReady()); /* @@ -582,7 +582,7 @@ async function ankiFieldsPopulate(element, options) { container.append($(html)); } - tab.find('.anki-field-value').change(utilAsync(onFormOptionsChanged)); + tab.find('.anki-field-value').change((e) => onFormOptionsChanged(e)); tab.find('.marker-link').click(onAnkiMarkerClicked); } diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index a6126677..b9e602b3 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -16,12 +16,6 @@ * along with this program. If not, see . */ -function utilAsync(func) { - return function(...args) { - func.apply(this, args); - }; -} - function utilIsolate(data) { return JSON.parse(JSON.stringify(data)); } diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js index 9a7968a7..f28bd636 100644 --- a/ext/fg/js/util.js +++ b/ext/fg/js/util.js @@ -17,12 +17,6 @@ */ -function utilAsync(func) { - return function(...args) { - func.apply(this, args); - }; -} - function utilInvoke(action, params={}) { const data = {action, params}; return new Promise((resolve, reject) => {