mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Updated home.js: Improved live upload speed
Forcefully wait for at least 1 second before calculating speed Calculating faster tends to have 'jumpy' results
This commit is contained in:
parent
8932615fbb
commit
f27db6f252
2
dist/js/home.js
vendored
2
dist/js/home.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/home.js.map
vendored
2
dist/js/home.js.map
vendored
File diff suppressed because one or more lines are too long
@ -389,12 +389,14 @@ page.prepareDropzone = () => {
|
||||
if (!skipProgress) {
|
||||
const now = Date.now()
|
||||
const elapsedSecs = (now - xhr._upSpeedCalc.timestamp) / 1000
|
||||
const bytesSent = upl.bytesSent - xhr._upSpeedCalc.bytes
|
||||
bytesPerSec = elapsedSecs ? (bytesSent / elapsedSecs) : 0
|
||||
|
||||
// Update data for next upload speed calculation
|
||||
xhr._upSpeedCalc.bytes = upl.bytesSent
|
||||
xhr._upSpeedCalc.timestamp = now
|
||||
// Calculate only if at least 1 second has elapsed
|
||||
if (elapsedSecs >= 1) {
|
||||
const bytesSent = upl.bytesSent - xhr._upSpeedCalc.bytes
|
||||
bytesPerSec = elapsedSecs ? (bytesSent / elapsedSecs) : 0
|
||||
// Update data for next upload speed calculation
|
||||
xhr._upSpeedCalc.bytes = upl.bytesSent
|
||||
xhr._upSpeedCalc.timestamp = now
|
||||
}
|
||||
}
|
||||
|
||||
file.previewElement.querySelector('.descriptive-progress').innerHTML =
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"1": "1587463408",
|
||||
"1": "1587464170",
|
||||
"2": "1581416390",
|
||||
"3": "1581416390",
|
||||
"4": "1581416390",
|
||||
|
Loading…
Reference in New Issue
Block a user