forked from 0x2620/pandora
fix progress, fail without file object
This commit is contained in:
parent
cf3161d4bd
commit
e086a93c9c
1 changed files with 7 additions and 2 deletions
|
@ -37,6 +37,10 @@ pandora.chunkupload = function(options) {
|
||||||
request,
|
request,
|
||||||
that = Ox.Element();
|
that = Ox.Element();
|
||||||
|
|
||||||
|
if (Ox.typeOf(file) != 'file') {
|
||||||
|
Ox.print('Invalid arguments, options.file must be file', options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
options.data = options.data || {};
|
options.data = options.data || {};
|
||||||
|
|
||||||
initUpload();
|
initUpload();
|
||||||
|
@ -134,9 +138,10 @@ pandora.chunkupload = function(options) {
|
||||||
} else {
|
} else {
|
||||||
that.status = Ox._('Sorry, your browser is currently not supported.');
|
that.status = Ox._('Sorry, your browser is currently not supported.');
|
||||||
done();
|
done();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
progress(Math.min(parseFloat(chunkOffset)/bytesAvailable), 1);
|
progress(Math.min(parseFloat(chunkOffset) / bytesAvailable, 1));
|
||||||
|
|
||||||
request = new XMLHttpRequest();
|
request = new XMLHttpRequest();
|
||||||
request.addEventListener('load', function (evt) {
|
request.addEventListener('load', function (evt) {
|
||||||
|
@ -211,7 +216,7 @@ pandora.chunkupload = function(options) {
|
||||||
}, false);
|
}, false);
|
||||||
request.upload.addEventListener('progress', function (evt) {
|
request.upload.addEventListener('progress', function (evt) {
|
||||||
if (evt.lengthComputable) {
|
if (evt.lengthComputable) {
|
||||||
progress(parseFloat(chunkOffset + evt.loaded) / bytesAvailable);
|
progress(Math.min(parseFloat(chunkOffset + evt.loaded) / bytesAvailable, 1));
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
request.addEventListener('abort', function (evt) {
|
request.addEventListener('abort', function (evt) {
|
||||||
|
|
Loading…
Reference in a new issue