mirror of
https://github.com/librespeed/speedtest.git
synced 2024-05-10 18:54:52 +00:00
changed handling of settings
- changed worker: allowing direct message to set options, also timeouts and pingcounts - examples changed with new set message
This commit is contained in:
192
example3.html
192
example3.html
@@ -1,97 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Speedtest</title>
|
||||
<style type="text/css">
|
||||
html,body{
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:none;
|
||||
text-align:center;
|
||||
}
|
||||
div.test{
|
||||
display:inline-block;
|
||||
width:30vw;
|
||||
text-align:center;
|
||||
}
|
||||
div.testName,div.meterUnit{
|
||||
font-size:3vw;
|
||||
}
|
||||
div.meter{
|
||||
font-size:6vw;
|
||||
line-height:1.5em;
|
||||
height:1.5em !important;
|
||||
}
|
||||
.flash{
|
||||
animation:flash 0.6s linear infinite;
|
||||
}
|
||||
@keyframes flash{
|
||||
0%{opacity:0.6;}
|
||||
50%{opacity:1;}
|
||||
}
|
||||
a{
|
||||
display:inline-block;
|
||||
border:0.15em solid #000000;
|
||||
padding:0.3em 0.5em;
|
||||
margin:0.6em;
|
||||
color:#000000;
|
||||
text-decoration:none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var w=null;
|
||||
function runTest(){
|
||||
document.getElementById("startBtn").style.display="none";
|
||||
document.getElementById("testArea").style.display="";
|
||||
document.getElementById("abortBtn").style.display="";
|
||||
w=new Worker("speedtest_worker.js");
|
||||
var interval=setInterval(function(){w.postMessage("status");}.bind(this),100);
|
||||
w.onmessage=function(event){
|
||||
var data=event.data.split(";");
|
||||
var status=Number(data[0]);
|
||||
var dl=document.getElementById("download"),ul=document.getElementById("upload"),ping=document.getElementById("ping");
|
||||
dl.className=status==1?"flash":"";ul.className=status==2?"flash":"";ping.className=status==3?"flash":"";
|
||||
if(status>=4){
|
||||
clearInterval(interval);
|
||||
document.getElementById("abortBtn").style.display="none";
|
||||
document.getElementById("startBtn").style.display="";
|
||||
w=null;
|
||||
}
|
||||
if(status==5){
|
||||
document.getElementById("testArea").style.display="none";
|
||||
}
|
||||
dl.innerHTML=data[1];
|
||||
ul.innerHTML=data[2];
|
||||
ping.innerHTML=data[3];
|
||||
}.bind(this);
|
||||
w.postMessage("start garbage.php empty.dat empty.dat");
|
||||
}
|
||||
function abortTest(){
|
||||
if(w)w.postMessage("abort");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Speedtest</h1>
|
||||
<div id="testArea" style="display:none">
|
||||
<div class="test">
|
||||
<div class="testName">Download</div>
|
||||
<div class="meter"> <span id="download"></span> </div>
|
||||
<div class="meterUnit">Mbit/s</div>
|
||||
</div>
|
||||
<div class="test">
|
||||
<div class="testName">Upload</div>
|
||||
<div class="meter"> <span id="upload"></span> </div>
|
||||
<div class="meterUnit">Mbit/s</div>
|
||||
</div>
|
||||
<div class="test">
|
||||
<div class="testName">Latency</div>
|
||||
<div class="meter"> <span id="ping"></span> </div>
|
||||
<div class="meterUnit">ms</div>
|
||||
</div>
|
||||
<br/>
|
||||
<a href="javascript:abortTest()" id="abortBtn">Abort</a>
|
||||
</div>
|
||||
<a href="javascript:runTest()" id="startBtn">Run speedtest</a>
|
||||
</body>
|
||||
<head>
|
||||
<title>Speedtest</title>
|
||||
<style type="text/css">
|
||||
html,body{
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:none;
|
||||
text-align:center;
|
||||
}
|
||||
div.test{
|
||||
display:inline-block;
|
||||
width:30vw;
|
||||
text-align:center;
|
||||
}
|
||||
div.testName,div.meterUnit{
|
||||
font-size:3vw;
|
||||
}
|
||||
div.meter{
|
||||
font-size:6vw;
|
||||
line-height:1.5em;
|
||||
height:1.5em !important;
|
||||
}
|
||||
.flash{
|
||||
animation:flash 0.6s linear infinite;
|
||||
}
|
||||
@keyframes flash{
|
||||
0%{opacity:0.6;}
|
||||
50%{opacity:1;}
|
||||
}
|
||||
a{
|
||||
display:inline-block;
|
||||
border:0.15em solid #000000;
|
||||
padding:0.3em 0.5em;
|
||||
margin:0.6em;
|
||||
color:#000000;
|
||||
text-decoration:none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var w=null;
|
||||
function runTest(){
|
||||
document.getElementById("startBtn").style.display="none";
|
||||
document.getElementById("testArea").style.display="";
|
||||
document.getElementById("abortBtn").style.display="";
|
||||
w=new Worker("speedtest_worker.js");
|
||||
var interval=setInterval(function(){w.postMessage("status");}.bind(this),100);
|
||||
w.onmessage=function(event){
|
||||
var data=event.data.split(";");
|
||||
var status=Number(data[0]);
|
||||
var dl=document.getElementById("download"),ul=document.getElementById("upload"),ping=document.getElementById("ping");
|
||||
// dl.className=status==1?"flash":"";ul.className=status==2?"flash":"";ping.className=status==3?"flash":"";
|
||||
|
||||
if(status>=4){
|
||||
clearInterval(interval);
|
||||
document.getElementById("abortBtn").style.display="none";
|
||||
document.getElementById("startBtn").style.display="";
|
||||
w=null;
|
||||
}
|
||||
if(status==5){
|
||||
document.getElementById("testArea").style.display="none";
|
||||
}
|
||||
dl.innerHTML=data[1];
|
||||
ul.innerHTML=data[2];
|
||||
ping.innerHTML=data[3];
|
||||
}.bind(this);
|
||||
w.postMessage("set time_dl 10"); // Timeout download
|
||||
w.postMessage("set time_ul 20"); // Timeout upload
|
||||
w.postMessage("set count_ping 30"); // Count of pings
|
||||
w.postMessage("start");
|
||||
}
|
||||
function abortTest(){
|
||||
if(w)w.postMessage("abort");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Speedtest</h1>
|
||||
<div id="testArea" style="display:none">
|
||||
<div class="test">
|
||||
<div class="testName">Download</div>
|
||||
<div class="meter"> <span id="download"></span> </div>
|
||||
<div class="meterUnit">Mbit/s</div>
|
||||
</div>
|
||||
<div class="test">
|
||||
<div class="testName">Upload</div>
|
||||
<div class="meter"> <span id="upload"></span> </div>
|
||||
<div class="meterUnit">Mbit/s</div>
|
||||
</div>
|
||||
<div class="test">
|
||||
<div class="testName">Latency</div>
|
||||
<div class="meter"> <span id="ping"></span> </div>
|
||||
<div class="meterUnit">ms</div>
|
||||
</div>
|
||||
<br/>
|
||||
<a href="javascript:abortTest()" id="abortBtn">Abort</a>
|
||||
</div>
|
||||
<a href="javascript:runTest()" id="startBtn">Run speedtest</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user