From aa8c1afa9df7460c839021ac2454f674104db89a Mon Sep 17 00:00:00 2001 From: Daniela Arcese Date: Fri, 23 Jun 2017 15:17:47 -0400 Subject: [PATCH] lint --- frontend/src/download.js | 3 +-- frontend/src/fileReceiver.js | 40 ++++++++++++++++++------------------ frontend/src/fileSender.js | 8 ++++---- frontend/src/upload.js | 33 ++++++++++++++--------------- server/portal_server.js | 7 ++++--- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/frontend/src/download.js b/frontend/src/download.js index d59691c7..52e71f91 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -4,7 +4,6 @@ const $ = require('jquery'); const Raven = window.Raven; - $(document).ready(function() { $('#download-progress').hide(); $('#send-file').click(() => { @@ -63,7 +62,7 @@ $(document).ready(function() { document.body.appendChild(a); a.click(); }) - .catch(err => { + .catch(err => { Raven.captureException(err); return Promise.reject(err); }); diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index 0b969dbc..d73fae3c 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -64,26 +64,26 @@ class FileReceiver extends EventEmitter { ['encrypt', 'decrypt'] ) ]) - .then(([fdata, key]) => { - const salt = this.salt; - return Promise.all([ - window.crypto.subtle.decrypt( - { - name: 'AES-CBC', - iv: salt - }, - key, - fdata.data - ), - new Promise((resolve, reject) => { - resolve(fdata.fname); - }) - ]); - }) - .catch(err => { - Raven.captureException(err); - return Promise.reject(err); - }); + .then(([fdata, key]) => { + const salt = this.salt; + return Promise.all([ + window.crypto.subtle.decrypt( + { + name: 'AES-CBC', + iv: salt + }, + key, + fdata.data + ), + new Promise((resolve, reject) => { + resolve(fdata.fname); + }) + ]); + }) + .catch(err => { + Raven.captureException(err); + return Promise.reject(err); + }); } } diff --git a/frontend/src/fileSender.js b/frontend/src/fileSender.js index af285f86..ede0b252 100644 --- a/frontend/src/fileSender.js +++ b/frontend/src/fileSender.js @@ -66,8 +66,8 @@ class FileSender extends EventEmitter { window.crypto.subtle.exportKey('jwk', secretKey) ]); }) - .catch(err => { - Raven.captureException(err) + .catch(err => { + Raven.captureException(err); return Promise.reject(err); }) .then(([encrypted, keydata]) => { @@ -106,8 +106,8 @@ class FileSender extends EventEmitter { xhr.send(fd); }); }) - .catch(err => { - Raven.captureException(err) + .catch(err => { + Raven.captureException(err); return Promise.reject(err); }); } diff --git a/frontend/src/upload.js b/frontend/src/upload.js index af035906..aba17737 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -15,7 +15,7 @@ $(document).ready(function() { $('#upload-progress').hide(); $('#share-link').hide(); - for(let i=0; i { const url = info.url.trim() + `#${info.secretKey}`.trim(); @@ -97,14 +96,13 @@ $(document).ready(function() { //load previous uploads function checkUploads(file) { - return new Promise ((resolve, reject) => { + return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.responseType = 'json'; xhr.onreadystatechange = () => { if (xhr.readyState == 4 && xhr.status == 200) { resolve(xhr.response); - } - else if (xhr.readyState == 4 && xhr.status == 404) { + } else if (xhr.readyState == 4 && xhr.status == 404) { reject('error code: ' + xhr.status); } }; @@ -113,11 +111,14 @@ $(document).ready(function() { }; xhr.open('get', '/file/' + id, true); xhr.send(); - }).then (response => { - populateFileList(response, url); - }, error => { - console.log(error); - }); + }).then( + response => { + populateFileList(response, url); + }, + error => { + console.log(error); + } + ); } //update file table with current files in localStorage @@ -142,7 +143,7 @@ $(document).ready(function() { // create delete button btn.innerHTML = 'x'; btn.classList.add('delete-btn'); - link.innerHTML = file.url.trim() + `#${file.secretKey}`.trim();; + link.innerHTML = file.url.trim() + `#${file.secretKey}`.trim(); // create popup popupDiv.classList.add('popup'); @@ -152,10 +153,7 @@ $(document).ready(function() { // delete file $popupText.find('.del-file').click(e => { - FileSender.delete( - file.fileId, - file.deleteToken - ).then(() => { + FileSender.delete(file.fileId, file.deleteToken).then(() => { $(e.target).parents('tr').remove(); localStorage.removeItem(file.fileId); }); @@ -173,11 +171,11 @@ $(document).ready(function() { // show popup del.addEventListener('click', toggleShow); // hide popup - $popupText.find('.nvm').click(function(e){ + $popupText.find('.nvm').click(function(e) { e.stopPropagation(); toggleShow(); }); - $popupText.click(function(e){ + $popupText.click(function(e) { e.stopPropagation(); }); @@ -187,5 +185,4 @@ $(document).ready(function() { $popupText.toggleClass('show'); } } - }); diff --git a/server/portal_server.js b/server/portal_server.js index 6fba066a..9939a979 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -60,11 +60,12 @@ app.get('/file/:id', (req, res) => { name: filename, filesize: bytes(contentLength), fileId: id - }) - }).catch(() => { + }); + }) + .catch(() => { console.log('error retrieving id ' + id); }); - }) + }); }); app.get('/download/:id', (req, res) => {