This commit is contained in:
Daniela Arcese 2017-06-29 16:11:33 -07:00
parent 421dd30c9d
commit 9026702e7b
2 changed files with 17 additions and 17 deletions

View File

@ -55,7 +55,7 @@ $(document).ready(function() {
} else { } else {
file = event.target.files[0]; file = event.target.files[0];
} }
let expiration = 24*60*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); const fileSender = new FileSender(file);
fileSender.on('progress', percentComplete => { fileSender.on('progress', percentComplete => {
@ -100,12 +100,12 @@ $(document).ready(function() {
function checkExistence(id, populate) { function checkExistence(id, populate) {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE){ if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status == 200) { if (xhr.status === 200) {
if (populate) { if (populate) {
populateFileList(localStorage.getItem(id)); populateFileList(localStorage.getItem(id));
} }
} else if (xhr.status == 404){ } else if (xhr.status === 404) {
localStorage.removeItem(id); localStorage.removeItem(id);
} }
} }
@ -140,17 +140,17 @@ $(document).ready(function() {
btn.classList.add('delete-btn'); btn.classList.add('delete-btn');
link.innerHTML = file.url.trim() + `#${file.secretKey}`.trim(); link.innerHTML = file.url.trim() + `#${file.secretKey}`.trim();
//file.expiry = new Date(file.expiry);
file.creationDate = new Date(file.creationDate); file.creationDate = new Date(file.creationDate);
let future = new Date(); const future = new Date();
future.setTime(file.creationDate.getTime() + file.expiry); future.setTime(file.creationDate.getTime() + file.expiry);
let countdown = 0; let countdown = 0;
countdown = future.getTime() - (new Date().getTime()); countdown = future.getTime() - new Date().getTime();
let minutes = Math.floor(countdown/1000/60); let minutes = Math.floor(countdown / 1000 / 60);
let hours = Math.floor(minutes/60); let hours = Math.floor(minutes / 60);
let seconds = Math.floor((countdown/1000)%60); let seconds = Math.floor(countdown / 1000 % 60);
if (hours > 0) { if (hours > 0) {
expiry.innerHTML = hours + 'h'; expiry.innerHTML = hours + 'h';
@ -158,7 +158,7 @@ $(document).ready(function() {
poll(); poll();
expiry.innerHTML = hours + 'h'; expiry.innerHTML = hours + 'h';
}, 3600000); }, 3600000);
} else if (hours == 0){ } else if (hours === 0) {
expiry.innerHTML = minutes + 'm' + seconds + 's'; expiry.innerHTML = minutes + 'm' + seconds + 's';
window.setInterval(() => { window.setInterval(() => {
poll(); poll();
@ -167,13 +167,13 @@ $(document).ready(function() {
} }
function poll() { function poll() {
countdown = future.getTime() - (new Date().getTime()); countdown = future.getTime() - new Date().getTime();
minutes = Math.floor(countdown/1000/60); minutes = Math.floor(countdown / 1000 / 60);
hours = Math.floor(minutes/60); hours = Math.floor(minutes / 60);
seconds = Math.floor((countdown/1000)%60); seconds = Math.floor(countdown / 1000 % 60);
//remove from list when expired //remove from list when expired
if (hours == 0 && minutes == 0 && seconds == 0){ if (hours === 0 && minutes === 0 && seconds === 0) {
localStorage.removeItem(file.fileId); localStorage.removeItem(file.fileId);
$(expiry).parents('tr').remove(); $(expiry).parents('tr').remove();
} }

View File

@ -1,6 +1,6 @@
const conf = require('./config.js'); const conf = require('./config.js');
const isProduction = conf.env === 'production' const isProduction = conf.env === 'production';
const mozlog = require('mozlog')({ const mozlog = require('mozlog')({
app: 'FirefoxFileshare', app: 'FirefoxFileshare',