mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Updated home.js again: Fixed live upload speed
My silly bad habit of not debugging things properly before committing
This commit is contained in:
parent
f27db6f252
commit
9c7b0e22d7
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
@ -385,22 +385,26 @@ page.prepareDropzone = () => {
|
||||
}
|
||||
|
||||
// Upload speed calculation
|
||||
let bytesPerSec
|
||||
let prettyBytesPerSec
|
||||
if (!skipProgress) {
|
||||
const now = Date.now()
|
||||
const elapsedSecs = (now - xhr._upSpeedCalc.timestamp) / 1000
|
||||
// Calculate only if at least 1 second has elapsed
|
||||
// Calculate only if at least 1s has elapsed
|
||||
if (elapsedSecs >= 1) {
|
||||
const bytesSent = upl.bytesSent - xhr._upSpeedCalc.bytes
|
||||
bytesPerSec = elapsedSecs ? (bytesSent / elapsedSecs) : 0
|
||||
const bytesPerSec = elapsedSecs ? (bytesSent / elapsedSecs) : 0
|
||||
// Update data for next upload speed calculation
|
||||
xhr._upSpeedCalc.bytes = upl.bytesSent
|
||||
xhr._upSpeedCalc.timestamp = now
|
||||
// Store latest pretty speed to be used in next iteration, if less than 1s elapsed
|
||||
xhr._upSpeedCalc.lastPretty = prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)
|
||||
} else if (xhr._upSpeedCalc.lastPretty) {
|
||||
prettyBytesPerSec = xhr._upSpeedCalc.lastPretty
|
||||
}
|
||||
}
|
||||
|
||||
file.previewElement.querySelector('.descriptive-progress').innerHTML =
|
||||
`${prefix} ${percentage}%${bytesPerSec ? ` at ${page.getPrettyBytes(bytesPerSec)}/s` : ''}`
|
||||
`${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`
|
||||
})
|
||||
|
||||
this.on('success', (file, data) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"1": "1587464170",
|
||||
"1": "1587464783",
|
||||
"2": "1581416390",
|
||||
"3": "1581416390",
|
||||
"4": "1581416390",
|
||||
|
Loading…
Reference in New Issue
Block a user