abort uploads over maxfilesize

This commit is contained in:
Danny Coates 2017-07-20 12:50:20 -07:00
parent 34f26fc017
commit 55d3d1a792
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
11 changed files with 415 additions and 2438 deletions

View file

@ -1,5 +1,7 @@
/* global MAXFILESIZE */
const FileSender = require('./fileSender');
const { notify, gcmCompliant } = require('./utils');
const bytes = require('bytes');
const $ = require('jquery');
require('jquery-circle-progress');
@ -84,6 +86,10 @@ $(document).ready(function() {
file = event.target.files[0];
}
if (file.size > MAXFILESIZE) {
return document.l10n.formatValue('fileTooBig', {size: bytes(MAXFILESIZE)}).then(alert);
}
$('#page-one').attr('hidden', true);
$('#upload-error').attr('hidden', true);
$('#upload-progress').removeAttr('hidden');
@ -108,19 +114,7 @@ $(document).ready(function() {
$('#ul-progress').circleProgress().on('circle-animation-end', function() {
$('.percent-number').html(`${Math.floor(percent * 100)}`);
});
if (progress[1] < 1000000) {
$('.progress-text').text(
`${file.name} (${(progress[0] / 1000).toFixed(1)}KB of ${(progress[1] / 1000).toFixed(1)}KB)`
);
} else if (progress[1] < 1000000000) {
$('.progress-text').text(
`${file.name} (${(progress[0] / 1000000).toFixed(1)}MB of ${(progress[1] / 1000000).toFixed(1)}MB)`
);
} else {
$('.progress-text').text(
`${file.name} (${(progress[0] / 1000000).toFixed(1)}MB of ${(progress[1] / 1000000000).toFixed(1)}GB)`
);
}
$('.progress-text').text(`${file.name} (${bytes(progress[0])} of ${bytes(progress[1])})`);
});
fileSender.on('loading', isStillLoading => {