Created
May 25, 2019 08:14
-
-
Save karthik20522/1d2f65a763e1c429ced5bbc59e15c62c to your computer and use it in GitHub Desktop.
Upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chunkSize = 1048; //default chunksize | |
var a = new XMLHttpRequest(); | |
a.onreadystatechange = function() { | |
if (a.readyState == 4 && a.status == 200) { | |
var timeToLoad = new Date - startPingDate; | |
chunkSize = Math.round(chunkSize - (timeToLoad * Math.random())); | |
if (chunkSize < 256) | |
chunkSize = 256; //set a default value if too low | |
$("#chunkSize").html(chunkSize); | |
$("#toSize").html(toSize(1 * 1024 * chunkSize)); | |
} | |
}; | |
var startPingDate = new Date; | |
a.open("GET", "/pingImage.jpg"); | |
a.send(null); | |
alert(chunksize); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment