From 88ba5352d4b2730cc1d30b030424e93b1720c822 Mon Sep 17 00:00:00 2001 From: Daniela Arcese Date: Wed, 5 Jul 2017 09:50:00 -0400 Subject: [PATCH] hide table header on empty list --- frontend/src/upload.js | 24 +++++++++++++++++++----- views/index.handlebars | 33 ++++++++++++++++----------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index ae63be42..60fcbf43 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -13,10 +13,14 @@ $(document).ready(function() { $('#upload-progress').hide(); $('#share-link').hide(); - for (let i = 0; i < localStorage.length; i++) { - const id = localStorage.key(i); - //check if file exists before adding to list - checkExistence(id, true); + if (localStorage.length === 0) { + toggleHeader(); + } else { + for (let i = 0; i < localStorage.length; i++) { + const id = localStorage.key(i); + //check if file exists before adding to list + checkExistence(id, true); + } } // copy link to clipboard @@ -55,7 +59,7 @@ $(document).ready(function() { } else { file = event.target.files[0]; } - const expiration = 2 * 60 * 1000; //will eventually come from a field + const expiration = 24 * 60 * 60 * 1000; //will eventually come from a field const fileSender = new FileSender(file); fileSender.on('progress', percentComplete => { @@ -196,6 +200,7 @@ $(document).ready(function() { FileSender.delete(file.fileId, file.deleteToken).then(() => { $(e.target).parents('tr').remove(); localStorage.removeItem(file.fileId); + toggleHeader(); }); }); @@ -224,5 +229,14 @@ $(document).ready(function() { function toggleShow() { $popupText.toggleClass('show'); } + toggleHeader(); + } + function toggleHeader() { + //hide table header if empty list + if (document.querySelector('tbody').childNodes.length === 1) { + $('#file-list').hide(); + } else { + $('#file-list').show(); + } } }); diff --git a/views/index.handlebars b/views/index.handlebars index f6d101d7..3fac035b 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -36,24 +36,23 @@ - +
+ + + + + + + + + + + + -
-
FileCopy URLExpires inDelete
- - - - - - - - - - - - - -
FileCopy URLExpires inDelete
+ + +