From d869d96a2b28c4037741044153529f80fb96608d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 7 Feb 2021 20:51:26 -0500 Subject: [PATCH] pad_impexp: Simplify creation of import failure message --- src/static/js/pad_impexp.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js index 9ac2824db..e05b97a54 100644 --- a/src/static/js/pad_impexp.js +++ b/src/static/js/pad_impexp.js @@ -74,24 +74,19 @@ const padimpexp = (() => { }; const importErrorMessage = (status) => { - let msg = ''; - - if (status === 'convertFailed') { - msg = html10n.get('pad.impexp.convertFailed'); - } else if (status === 'uploadFailed') { - msg = html10n.get('pad.impexp.uploadFailed'); - } else if (status === 'padHasData') { - msg = html10n.get('pad.impexp.padHasData'); - } else if (status === 'maxFileSize') { - msg = html10n.get('pad.impexp.maxFileSize'); - } else if (status === 'permission') { - msg = html10n.get('pad.impexp.permission'); - } + const known = [ + 'convertFailed', + 'uploadFailed', + 'padHasData', + 'maxFileSize', + 'permission', + ]; + const msg = html10n.get(`pad.impexp.${known.indexOf(status) !== -1 ? status : 'copypaste'}`); const showError = (fade) => { $('#importmessagefail').html( `${html10n.get('pad.impexp.importfailed')}: ` + - `${msg || html10n.get('pad.impexp.copypaste', '')}`)[(fade ? 'fadeIn' : 'show')](); + `${msg}`)[(fade ? 'fadeIn' : 'show')](); }; if ($('#importexport .importmessage').is(':visible')) {