Initial commit of (old) code.
This commit is contained in:
commit
6808d61199
16 changed files with 2003 additions and 0 deletions
43
html/init.js
Normal file
43
html/init.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
var s=new Speedtest(); //create speedtest object
|
||||
|
||||
s.setParameter("test_order","IP_D"); //we only want download test
|
||||
s.setParameter("time_auto",true); //fixed duration for tests
|
||||
s.setParameter("time_dl_max",10); //10 seconds for the download test
|
||||
|
||||
s.onupdate=function(data){
|
||||
I("ip").textContent=data.clientIp;
|
||||
I("dlText").textContent=(data.testState==1&&data.dlStatus==0)?"...":data.dlStatus;
|
||||
I("pingText").textContent=data.pingStatus;
|
||||
I("jitText").textContent=data.jitterStatus;
|
||||
var prog=(Number(data.dlProgress)*2+Number(data.pingProgress))/3;
|
||||
I("progress").style.width=(100*prog)+"%";
|
||||
}
|
||||
|
||||
s.onend=function(aborted){
|
||||
I("startStopBtn").className=""; //show start button again
|
||||
if(aborted){
|
||||
initUI();
|
||||
}
|
||||
}
|
||||
|
||||
function startStop(){
|
||||
if(s.getState()==3){
|
||||
//speedtest is running, abort
|
||||
s.abort();
|
||||
}else{
|
||||
//test is not running, begin
|
||||
s.start();
|
||||
I("startStopBtn").className="running";
|
||||
}
|
||||
}
|
||||
|
||||
function initUI(){
|
||||
I("dlText").textContent="";
|
||||
I("pingText").textContent="";
|
||||
I("jitText").textContent="";
|
||||
I("ip").textContent="";
|
||||
}
|
||||
|
||||
function I(id){
|
||||
return document.getElementById(id);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue