From e086a93c9cf6628fc8a91c67204868ed33cfb756 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 30 Aug 2016 18:56:11 +0200 Subject: [PATCH] fix progress, fail without file object --- static/js/chunkupload.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/js/chunkupload.js b/static/js/chunkupload.js index 68f62badf..012b72273 100644 --- a/static/js/chunkupload.js +++ b/static/js/chunkupload.js @@ -37,6 +37,10 @@ pandora.chunkupload = function(options) { request, that = Ox.Element(); + if (Ox.typeOf(file) != 'file') { + Ox.print('Invalid arguments, options.file must be file', options); + return; + } options.data = options.data || {}; initUpload(); @@ -134,9 +138,10 @@ pandora.chunkupload = function(options) { } else { that.status = Ox._('Sorry, your browser is currently not supported.'); done(); + return; } - progress(Math.min(parseFloat(chunkOffset)/bytesAvailable), 1); + progress(Math.min(parseFloat(chunkOffset) / bytesAvailable, 1)); request = new XMLHttpRequest(); request.addEventListener('load', function (evt) { @@ -211,7 +216,7 @@ pandora.chunkupload = function(options) { }, false); request.upload.addEventListener('progress', function (evt) { if (evt.lengthComputable) { - progress(parseFloat(chunkOffset + evt.loaded) / bytesAvailable); + progress(Math.min(parseFloat(chunkOffset + evt.loaded) / bytesAvailable, 1)); } }, false); request.addEventListener('abort', function (evt) {