From 2d109c3e56231fc84dd225977bc4ef78eac9ed4d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 Feb 2020 21:17:01 -0500 Subject: [PATCH] Use functions directly rather than wrapping in () => {} when args are same --- ext/bg/js/settings/anki-templates.js | 8 ++++---- ext/bg/js/settings/anki.js | 6 +++--- ext/bg/js/settings/audio.js | 8 ++++---- ext/bg/js/settings/dictionaries.js | 14 +++++++------- ext/bg/js/settings/main.js | 2 +- ext/bg/js/settings/profiles.js | 16 ++++++++-------- ext/bg/js/settings/storage.js | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index 2e80e334..770716d4 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -45,10 +45,10 @@ function ankiTemplatesInitialize() { node.addEventListener('click', onAnkiTemplateMarkerClicked, false); } - $('#field-templates').on('change', (e) => onAnkiFieldTemplatesChanged(e)); - $('#field-template-render').on('click', (e) => onAnkiTemplateRender(e)); - $('#field-templates-reset').on('click', (e) => onAnkiFieldTemplatesReset(e)); - $('#field-templates-reset-confirm').on('click', (e) => onAnkiFieldTemplatesResetConfirm(e)); + $('#field-templates').on('change', onAnkiFieldTemplatesChanged); + $('#field-template-render').on('click', onAnkiTemplateRender); + $('#field-templates-reset').on('click', onAnkiFieldTemplatesReset); + $('#field-templates-reset-confirm').on('click', onAnkiFieldTemplatesResetConfirm); ankiTemplatesUpdateValue(); } diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index 4263fc51..782691ab 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -154,10 +154,10 @@ async function _ankiFieldsPopulate(tabId, options) { container.appendChild(fragment); for (const node of container.querySelectorAll('.anki-field-value')) { - node.addEventListener('change', (e) => onFormOptionsChanged(e), false); + node.addEventListener('change', onFormOptionsChanged, false); } for (const node of container.querySelectorAll('.marker-link')) { - node.addEventListener('click', (e) => _onAnkiMarkerClicked(e), false); + node.addEventListener('click', _onAnkiMarkerClicked, false); } } @@ -267,7 +267,7 @@ function ankiGetFieldMarkers(type) { function ankiInitialize() { for (const node of document.querySelectorAll('#anki-terms-model,#anki-kanji-model')) { - node.addEventListener('change', (e) => _onAnkiModelChanged(e), false); + node.addEventListener('change', _onAnkiModelChanged, false); } } diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index 588d9a11..6d183a43 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -29,7 +29,7 @@ async function audioSettingsInitialize() { document.querySelector('.audio-source-list'), document.querySelector('.audio-source-add') ); - audioSourceUI.save = () => settingsSaveOptions(); + audioSourceUI.save = settingsSaveOptions; textToSpeechInitialize(); } @@ -37,11 +37,11 @@ async function audioSettingsInitialize() { function textToSpeechInitialize() { if (typeof speechSynthesis === 'undefined') { return; } - speechSynthesis.addEventListener('voiceschanged', () => updateTextToSpeechVoices(), false); + speechSynthesis.addEventListener('voiceschanged', updateTextToSpeechVoices, false); updateTextToSpeechVoices(); - document.querySelector('#text-to-speech-voice').addEventListener('change', (e) => onTextToSpeechVoiceChange(e), false); - document.querySelector('#text-to-speech-voice-test').addEventListener('click', () => textToSpeechTest(), false); + document.querySelector('#text-to-speech-voice').addEventListener('change', onTextToSpeechVoiceChange, false); + document.querySelector('#text-to-speech-voice-test').addEventListener('click', textToSpeechTest, false); } function updateTextToSpeechVoices() { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 3ceb12fa..b9551073 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -341,14 +341,14 @@ async function dictSettingsInitialize() { document.querySelector('#dict-groups-extra'), document.querySelector('#dict-extra-template') ); - dictionaryUI.save = () => settingsSaveOptions(); + dictionaryUI.save = settingsSaveOptions; - document.querySelector('#dict-purge-button').addEventListener('click', (e) => onDictionaryPurgeButtonClick(e), false); - document.querySelector('#dict-purge-confirm').addEventListener('click', (e) => onDictionaryPurge(e), false); - document.querySelector('#dict-file-button').addEventListener('click', (e) => onDictionaryImportButtonClick(e), false); - document.querySelector('#dict-file').addEventListener('change', (e) => onDictionaryImport(e), false); - document.querySelector('#dict-main').addEventListener('change', (e) => onDictionaryMainChanged(e), false); - document.querySelector('#database-enable-prefix-wildcard-searches').addEventListener('change', (e) => onDatabaseEnablePrefixWildcardSearchesChanged(e), false); + document.querySelector('#dict-purge-button').addEventListener('click', onDictionaryPurgeButtonClick, false); + document.querySelector('#dict-purge-confirm').addEventListener('click', onDictionaryPurge, false); + document.querySelector('#dict-file-button').addEventListener('click', onDictionaryImportButtonClick, false); + document.querySelector('#dict-file').addEventListener('change', onDictionaryImport, false); + document.querySelector('#dict-main').addEventListener('change', onDictionaryMainChanged, false); + document.querySelector('#database-enable-prefix-wildcard-searches').addEventListener('change', onDatabaseEnablePrefixWildcardSearchesChanged, false); await onDictionaryOptionsChanged(); await onDatabaseUpdated(); diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index d1ad2c6b..127a6d2b 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -200,7 +200,7 @@ async function formWrite(options) { } function formSetupEventListeners() { - $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change((e) => onFormOptionsChanged(e)); + $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change(onFormOptionsChanged); } function formUpdateVisibility(options) { diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index 3e589809..f946a33a 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -39,16 +39,16 @@ async function profileOptionsSetup() { } function profileOptionsSetupEventListeners() { - $('#profile-target').change((e) => onTargetProfileChanged(e)); - $('#profile-name').change((e) => onProfileNameChanged(e)); - $('#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-target').change(onTargetProfileChanged); + $('#profile-name').change(onProfileNameChanged); + $('#profile-add').click(onProfileAdd); + $('#profile-remove').click(onProfileRemove); + $('#profile-remove-confirm').click(onProfileRemoveConfirm); + $('#profile-copy').click(onProfileCopy); + $('#profile-copy-confirm').click(onProfileCopyConfirm); $('#profile-move-up').click(() => onProfileMove(-1)); $('#profile-move-down').click(() => onProfileMove(1)); - $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change((e) => onProfileOptionsChanged(e)); + $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change(onProfileOptionsChanged); } function tryGetIntegerValue(selector, min, max) { diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index cbe1bb4d..8978414e 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -57,7 +57,7 @@ async function storageInfoInitialize() { await storageShowInfo(); - document.querySelector('#storage-refresh').addEventListener('click', () => storageShowInfo(), false); + document.querySelector('#storage-refresh').addEventListener('click', storageShowInfo, false); } async function storageUpdateStats() {