From e4301963a2c7dbdc30190238319a431421af7c76 Mon Sep 17 00:00:00 2001 From: Daniela Arcese Date: Wed, 19 Jul 2017 17:27:08 -0400 Subject: [PATCH] add alert when uploading multiple files --- frontend/src/upload.js | 28 +++++++++++++++++++++------- public/locales/send.en-US.ftl | 3 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 7764a088..583b41c2 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -70,18 +70,32 @@ $(document).ready(function() { // on file upload by browse or drag & drop function onUpload(event) { event.preventDefault(); + let file = ''; + if (event.type === 'drop') { + if (event.originalEvent.dataTransfer.files.length > 1){ + document.l10n.formatValue('uploadPageMultipleFilesAlert') + .then(str => { + alert(str); + }); + return; + } + file = event.originalEvent.dataTransfer.files[0]; + } else { + if (event.target.files.length > 1){ + document.l10n.formatValue('uploadPageMultipleFilesAlert') + .then(str => { + alert(str); + }); + return; + } + file = event.target.files[0]; + } + $('#page-one').attr('hidden', true); $('#upload-error').attr('hidden', true); $('#upload-progress').removeAttr('hidden'); //don't allow drag and drop when not on page-one $('body').off('drop', onUpload); - - let file = ''; - if (event.type === 'drop') { - file = event.originalEvent.dataTransfer.files[0]; - } else { - file = event.target.files[0]; - } const expiration = 24 * 60 * 60 * 1000; //will eventually come from a field const fileSender = new FileSender(file); diff --git a/public/locales/send.en-US.ftl b/public/locales/send.en-US.ftl index a1c73b6b..a3873fbb 100644 --- a/public/locales/send.en-US.ftl +++ b/public/locales/send.en-US.ftl @@ -4,10 +4,11 @@ uploadPageHeader = Private, Encrypted File Sharing uploadPageExplainer = Send files through a safe, private, and encrypted link that automatically expires to ensure your stuff does not remain online forever. uploadPageLearnMore = Learn more -uploadPageDropMessage = Drop your files here to start uploading +uploadPageDropMessage = Drop your file here to start uploading uploadPageSizeMessage = For the most reliable operation, it’s best to keep your file under 1GB uploadPageBrowseButton = Select a file on your computer .title = {uploadPageBrowseButtonTitle} +uploadPageMultipleFilesAlert = Uploading multiple files or a folder is currently not supported. uploadPageBrowseButtonTitle = Upload file