Updated example
This commit is contained in:
parent
bec767c9ed
commit
48139c7fba
1 changed files with 28 additions and 27 deletions
51
example.html
51
example.html
|
@ -13,34 +13,35 @@
|
||||||
<h4>Latency</h4>
|
<h4>Latency</h4>
|
||||||
<div id="ping">Wait...</div>
|
<div id="ping">Wait...</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var tester=new DownloadTester("garbage.php");
|
var tester=new DownloadTester("garbage.php",function(){
|
||||||
var d=document.getElementById("download");
|
//when the download test is done, start the upload test
|
||||||
tester.onUpdate=function(){
|
tester=new UploadTester("upload-test", function(){
|
||||||
d.innerHTML=tester.getValue()+" Megabit/s";
|
//when the upload test is done, start the latency test
|
||||||
|
tester=new PingTester("empty.dat",null //when the test ends, do nothing
|
||||||
|
,function(){
|
||||||
|
//called periodically to update latency
|
||||||
|
document.getElementById("ping").innerHTML=tester.getValue()+" ms";
|
||||||
|
},function(){
|
||||||
|
//when the latency test fails
|
||||||
|
document.getElementById("ping").innerHTML="Failed";
|
||||||
}
|
}
|
||||||
tester.onFail=function(){
|
);
|
||||||
d.innerHTML="Failed";
|
},function(){
|
||||||
|
//called periodically to update upload speed
|
||||||
|
document.getElementById("upload").innerHTML=tester.getValue()+" Megabit/s";
|
||||||
|
},function(){
|
||||||
|
//when the upload test fails
|
||||||
|
document.getElementById("upload").innerHTML="Failed";
|
||||||
tester.onDone();
|
tester.onDone();
|
||||||
}
|
});
|
||||||
tester.onDone=function(){
|
},function(){
|
||||||
tester=new UploadTester("upload-test");
|
//called periodically to update download speed
|
||||||
d=document.getElementById("upload");
|
document.getElementById("download").innerHTML=tester.getValue()+" Megabit/s";
|
||||||
tester.onUpdate=function(){
|
},function(){
|
||||||
d.innerHTML=tester.getValue()+" Megabit/s";
|
//when the download test fails
|
||||||
}
|
document.getElementById("download").innerHTML="Failed";
|
||||||
tester.onFail=function(){
|
|
||||||
d.innerHTML="Failed";
|
|
||||||
tester.onDone();
|
tester.onDone();
|
||||||
}
|
});
|
||||||
tester.onDone=function(){
|
|
||||||
tester=new PingTester("empty.dat");
|
|
||||||
d=document.getElementById("ping");
|
|
||||||
tester.onUpdate=function(){
|
|
||||||
d.innerHTML=tester.getValue()+" ms";
|
|
||||||
}
|
|
||||||
tester.onFail=function(){d.innerHTML="Failed";}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue