| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Speedtest</title>
- <script type="text/javascript" src="speedtest.js"></script>
- </head>
- <body>
- <h1>Speedtest</h1>
- <h4>Download</h4>
- <div id="download">Wait...</div>
- <h4>Upload</h4>
- <div id="upload">Wait...</div>
- <h4>Latency</h4>
- <div id="ping">Wait...</div>
- <script type="text/javascript">
- var tester=new DownloadTester("garbage.php",function(){
- //when the download test is done, start the upload test
- tester=new UploadTester("upload-test", function(){
- //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";
- }
- );
- },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();
- });
- },function(){
- //called periodically to update download speed
- document.getElementById("download").innerHTML=tester.getValue()+" Megabit/s";
- },function(){
- //when the download test fails
- document.getElementById("download").innerHTML="Failed";
- tester.onDone();
- });
- </script>
- </body>
- </html>
|