increase upload limit
remaining upload time will be calculated more simple
This commit is contained in:
@@ -18,9 +18,9 @@ function changeFile(fileInput){
|
||||
var file = fileInput.files[0];
|
||||
var size = file.size / (1000*1000);
|
||||
$('#uploadSize').html(size + " MB");
|
||||
if (size > 200){
|
||||
if (size > 300){
|
||||
$('#uploadButton').hide();
|
||||
showError("file is too large. maximum size is 200 MB! Please use MP3, 192 kHz, CBR, 44100 Hz, 16bit");
|
||||
showError("file is too large. maximum size is 300 MB! Please use MP3, 192 kHz, CBR, 44100 Hz, 16bit");
|
||||
}else{
|
||||
$('#uploadButton').show();
|
||||
}
|
||||
@@ -46,7 +46,10 @@ function hideFinished(){
|
||||
|
||||
function roundSize(size){
|
||||
var MB=1000*1000;
|
||||
return Math.round(size*10/MB)/10;
|
||||
var value= Math.round(size*10/MB)/10;
|
||||
value+='';
|
||||
if (value.indexOf('.')<0)value+='.0';
|
||||
return value;
|
||||
}
|
||||
|
||||
function uploadFile(uploadButton){
|
||||
@@ -64,24 +67,37 @@ function uploadFile(uploadButton){
|
||||
var start = new Date();
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
if (myXhr.upload) {
|
||||
var c=0;
|
||||
var oldRemaining=0;
|
||||
myXhr.upload.addEventListener(
|
||||
'progress',
|
||||
function(data) {
|
||||
if (data.lengthComputable) {
|
||||
var loaded=roundSize(data.loaded);
|
||||
var total=roundSize(data.total);
|
||||
$('#progressBar').attr("value", loaded);
|
||||
$('#progressBar').attr("max", total);
|
||||
var duration=(new Date().getTime() - start.getTime()) / 1000 ;
|
||||
var bitrate = loaded / duration;
|
||||
var remaining = Math.round(100 * bitrate * ( total - loaded) );
|
||||
var content = loaded + " of " + total + " MB<br>";
|
||||
content += '<div class="thin">';
|
||||
content += "finished in " + remaining + " seconds<br>";
|
||||
content += "took " + Math.round(duration) + " seconds<br>";
|
||||
content += '</div>'
|
||||
$('#progressLabel').html(content);
|
||||
}
|
||||
if (!data.lengthComputable) return;
|
||||
c++;
|
||||
|
||||
var loaded=roundSize(data.loaded);
|
||||
var total=roundSize(data.total);
|
||||
$('#progressBar').attr("value", loaded);
|
||||
$('#progressBar').attr("max", total);
|
||||
|
||||
if (c<2)return;
|
||||
c=0;
|
||||
|
||||
var duration=(new Date().getTime() - start.getTime()) / 1000 ;
|
||||
var bitrate = loaded / duration;
|
||||
|
||||
//var remaining = Math.round(bitrate * ( total - loaded) );
|
||||
var remaining = Math.round( (duration * data.total / data.loaded) - duration );
|
||||
if (oldRemaining == 0) oldRemaining = remaining;
|
||||
if (duration>30) remaining= oldRemaining*0.5 + remaining*0.5;
|
||||
oldRemaining=remaining;
|
||||
|
||||
var content = loaded + " of " + total + " MB<br>";
|
||||
content += '<div class="thin">';
|
||||
content += "finished in " + Math.round(remaining) + " seconds<br>";
|
||||
content += "took " + Math.round(duration) + " seconds<br>";
|
||||
content += '</div>'
|
||||
$('#progressLabel').html(content);
|
||||
} ,
|
||||
false
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user