2016-10-09 07:13:36 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Speedtest</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Speedtest</h1>
|
2017-02-26 11:15:51 +00:00
|
|
|
<h4>IP Address</h4>
|
|
|
|
<div id="ip"></div>
|
2016-10-09 07:13:36 +00:00
|
|
|
<h4>Download</h4>
|
|
|
|
<div id="download"></div>
|
|
|
|
<h4>Upload</h4>
|
|
|
|
<div id="upload"></div>
|
|
|
|
<h4>Latency</h4>
|
|
|
|
<div id="ping"></div>
|
|
|
|
<script type="text/javascript">
|
2017-03-02 16:58:40 +00:00
|
|
|
var w=new Worker("speedtest_worker.min.js"); //create new worker
|
2016-10-09 07:13:36 +00:00
|
|
|
setInterval(function(){w.postMessage("status");}.bind(this),100); //ask for status every 100ms
|
|
|
|
w.onmessage=function(event){ //when status is received, split the string and put the values in the appropriate fields
|
|
|
|
var data=event.data.split(";"); //string format: status;download;upload;ping (speeds are in mbit/s) (status: 0=not started, 1=downloading, 2=uploading, 3=ping, 4=done, 5=aborted)
|
|
|
|
document.getElementById("download").innerHTML=data[1]+" Mbit/s";
|
|
|
|
document.getElementById("upload").innerHTML=data[2]+" Mbit/s";
|
2017-03-02 16:58:40 +00:00
|
|
|
document.getElementById("ping").innerHTML=data[3]+" ms, "+data[5]+" ms jitter";
|
2017-02-26 11:15:51 +00:00
|
|
|
document.getElementById("ip").innerHTML=data[4];
|
2016-10-09 07:13:36 +00:00
|
|
|
}
|
2016-10-23 17:47:55 +00:00
|
|
|
w.postMessage("start"); //start the speedtest (default params. keep garbage.php and empty.dat in the same directory as the js file)
|
2016-10-09 07:13:36 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|