show upload progress in table background

pull/525/head
qkqpttgf 2022-01-18 13:04:46 +08:00 committed by GitHub
parent 9572b68be9
commit 08c12518a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -1057,7 +1057,9 @@
let tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime()); let tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
lastCurrentSpeed = tmpspeed; lastCurrentSpeed = tmpspeed;
let remaintime = (totalsize-asize-e.loaded)/tmpspeed; let remaintime = (totalsize-asize-e.loaded)/tmpspeed;
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1)); let percent = ((asize+e.loaded)*100/totalsize).toFixed(2);
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML = StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
} }
} }
var C_starttime = new Date(); var C_starttime = new Date();
@ -1086,7 +1088,7 @@
while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/'); while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/');
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.style.color='green'; label.parentNode.style.background = 'rgba(0,80,0,25%)';
// uploadbuttonshow(); // uploadbuttonshow();
<!--AdminStart--> <!--AdminStart-->
@ -1329,7 +1331,7 @@
} }
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.style.color='green'; label.parentNode.style.background = 'rgba(0,80,0,25%)';
} else { } else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>'; label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1); localStorage.removeItem(filesha1);
@ -1349,7 +1351,9 @@
var tmptime = new Date(); var tmptime = new Date();
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime()); var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
var remaintime = (totalsize-asize-e.loaded)/tmpspeed; var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1)); let percent = ((asize+e.loaded)*100/totalsize).toFixed(2);
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
} }
} }
var C_starttime = new Date(); var C_starttime = new Date();
@ -1400,7 +1404,7 @@
} }
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.style.color='green'; label.parentNode.style.background = 'rgba(0,80,0,25%)';
} else { } else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>'; label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1); localStorage.removeItem(filesha1);