From ae3e18c443f407823b45fa1f1815c1f5b302ba2b Mon Sep 17 00:00:00 2001 From: Daniela Arcese Date: Tue, 20 Jun 2017 15:52:01 -0400 Subject: [PATCH] format --- frontend/src/download.js | 56 +++++++++++++++++++++------------------- frontend/src/upload.js | 8 +++--- public/main.css | 7 ++++- server/portal_server.js | 19 ++++++++------ server/storage.js | 2 +- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/frontend/src/download.js b/frontend/src/download.js index 545ae82c..65045433 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -16,7 +16,9 @@ $(document).ready(function() { $('.send-new').hide(); $('#download-progress').show(); // update progress bar - document.querySelector('#progress-bar').style.setProperty('--progress', percentComplete+'%'); + document + .querySelector('#progress-bar') + .style.setProperty('--progress', percentComplete + '%'); $('#progress-text').html(`${percentComplete}%`); //on complete if (percentComplete === 100) { @@ -29,33 +31,33 @@ $(document).ready(function() { }); fileReceiver - .download() - .catch(() => { - $('.title').text( - 'This link has expired or never existed in the first place.' - ); - $('#download-btn').hide(); - $('#expired-img').show(); - console.log('The file has expired, or has already been deleted.'); - return; - }) - .then(([decrypted, fname]) => { - name.innerText = fname; - const dataView = new DataView(decrypted); - const blob = new Blob([dataView]); - const downloadUrl = URL.createObjectURL(blob); - - const a = document.createElement('a'); - a.href = downloadUrl; - if (window.navigator.msSaveBlob) { - // if we are in microsoft edge or IE - window.navigator.msSaveBlob(blob, fname); + .download() + .catch(() => { + $('.title').text( + 'This link has expired or never existed in the first place.' + ); + $('#download-btn').hide(); + $('#expired-img').show(); + console.log('The file has expired, or has already been deleted.'); return; - } - a.download = fname; - document.body.appendChild(a); - a.click(); - }); + }) + .then(([decrypted, fname]) => { + name.innerText = fname; + const dataView = new DataView(decrypted); + const blob = new Blob([dataView]); + const downloadUrl = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = downloadUrl; + if (window.navigator.msSaveBlob) { + // if we are in microsoft edge or IE + window.navigator.msSaveBlob(blob, fname); + return; + } + a.download = fname; + document.body.appendChild(a); + a.click(); + }); }; window.download = download; diff --git a/frontend/src/upload.js b/frontend/src/upload.js index bf14f95b..3bc586a7 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -21,9 +21,9 @@ $(document).ready(function() { document.execCommand('copy'); document.body.removeChild(aux); //disable button for 3s - $copyBtn.attr('disabled', true) + $copyBtn.attr('disabled', true); $copyBtn.html('Copied!'); - window.setTimeout(()=>{ + window.setTimeout(() => { $copyBtn.attr('disabled', false); $copyBtn.html('Copy'); }, 3000); @@ -90,7 +90,9 @@ $(document).ready(function() { $('#upload-progress').show(); $('#upload-filename').innerHTML += file.name; // update progress bar - document.querySelector('#progress-bar').style.setProperty('--progress', percentComplete+'%'); + document + .querySelector('#progress-bar') + .style.setProperty('--progress', percentComplete + '%'); $('#progress-text').html(`${percentComplete}%`); }); fileSender.upload().then(info => { diff --git a/public/main.css b/public/main.css index ae45ecd0..d97ea06a 100644 --- a/public/main.css +++ b/public/main.css @@ -155,7 +155,12 @@ td { #progress-bar { width: 300px; height: 5px; - background: linear-gradient(90deg, #FD9800, #D73000 var(--progress), white var(--progress)); + background: linear-gradient( + 90deg, + #FD9800, + #D73000 var(--progress), + white var(--progress) + ); border: 0.5px solid; border-radius: 5px; } diff --git a/server/portal_server.js b/server/portal_server.js index c6f74c68..2c16ee3d 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -71,13 +71,16 @@ app.get('/assets/download/:id', (req, res) => { const file_stream = storage.get(id); file_stream.on(notLocalHost ? 'finish' : 'close', () => { - storage.forceDelete(id).then(err => { - if (!err) { - log.info('Deleted:', id); - } - }).catch(err => { - log.info('DeleteError:', id); - }); + storage + .forceDelete(id) + .then(err => { + if (!err) { + log.info('Deleted:', id); + } + }) + .catch(err => { + log.info('DeleteError:', id); + }); }); file_stream.pipe(res); @@ -104,7 +107,7 @@ app.post('/delete/:id', (req, res) => { storage .delete(id, delete_token) - .then((err) => { + .then(err => { if (!err) { log.info('Deleted:', id); res.sendStatus(200); diff --git a/server/storage.js b/server/storage.js index 93d02791..e3af4440 100644 --- a/server/storage.js +++ b/server/storage.js @@ -145,7 +145,7 @@ function awsGet(id) { try { return s3.getObject(params).createReadStream(); - } catch(err) { + } catch (err) { log.info('GetFailed', 'Get Object from s3 failed.'); return null; }