| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | 
							- <!DOCTYPE html>
 
- <html>
 
- <head>
 
- <meta charset="UTF-8" />
 
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
 
- <title>HTML5 Speedtest</title>
 
- <style type="text/css">
 
- 	html,body{
 
- 		border:none; padding:0; margin:0;
 
- 		background:#FFFFFF;
 
- 		color:#202020;
 
- 	}
 
- 	body{
 
- 		text-align:center;
 
- 		font-family:"Roboto",sans-serif;
 
- 	}
 
- 	h1{
 
- 		color:#404040;
 
- 	}
 
- 	#startStopBtn{
 
- 		display:inline-block;
 
- 		margin:0 auto;
 
- 		color:#6060AA;
 
- 		background-color:rgba(0,0,0,0);
 
- 		border:0.15em solid #6060FF;
 
- 		border-radius:0.3em;
 
- 		transition:all 0.3s;
 
- 		box-sizing:border-box;
 
- 		width:8em; height:3em;
 
- 		line-height:2.7em;
 
- 		cursor:pointer;
 
- 		box-shadow: 0 0 0 rgba(0,0,0,0.1), inset 0 0 0 rgba(0,0,0,0.1);
 
- 	}
 
- 	#startStopBtn:hover{
 
- 		box-shadow: 0 0 2em rgba(0,0,0,0.1), inset 0 0 1em rgba(0,0,0,0.1);
 
- 	}
 
- 	#startStopBtn.running{
 
- 		background-color:#FF3030;
 
- 		border-color:#FF6060;
 
- 		color:#FFFFFF;
 
- 	}
 
- 	#startStopBtn:before{
 
- 		content:"Start";
 
- 	}
 
- 	#startStopBtn.running:before{
 
- 		content:"Abort";
 
- 	}
 
- 	#test{
 
- 		margin-top:2em;
 
- 		margin-bottom:12em;
 
- 	}
 
- 	div.testArea{
 
- 		display:inline-block;
 
- 		width:14em;
 
- 		height:9em;
 
- 		position:relative;
 
- 		box-sizing:border-box;
 
- 	}
 
- 	div.testName{
 
- 		position:absolute;
 
- 		top:0.1em; left:0;
 
- 		width:100%;
 
- 		font-size:1.4em;
 
- 		z-index:9;
 
- 	}
 
- 	div.meterText{
 
- 		position:absolute;
 
- 		bottom:1.5em; left:0;
 
- 		width:100%;
 
- 		font-size:2.5em;
 
- 		z-index:9;
 
- 	}
 
- 	#dlText{
 
- 		color:#6060AA;
 
- 	}
 
- 	#ulText{
 
- 		color:#309030;
 
- 	}
 
- 	#pingText,#jitText{
 
- 		color:#AA6060;
 
- 	}
 
- 	div.meterText:empty:before{
 
- 		color:#505050 !important;
 
- 		content:"0.00";
 
- 	}
 
- 	div.unit{
 
- 		position:absolute;
 
- 		bottom:2em; left:0;
 
- 		width:100%;
 
- 		z-index:9;
 
- 	}
 
- 	div.testGroup{
 
- 		display:inline-block;
 
- 	}
 
- 	@media all and (max-width:65em){
 
- 		body{
 
- 			font-size:1.5vw;
 
- 		}
 
- 	}
 
- 	@media all and (max-width:40em){
 
- 		body{
 
- 			font-size:0.8em;
 
- 		}
 
- 		div.testGroup{
 
- 			display:block;
 
- 			margin: 0 auto;
 
- 		}
 
- 	}
 
- </style>
 
- <script type="text/javascript">
 
- function I(id){return document.getElementById(id);}
 
- var w=null; //speedtest worker
 
- var parameters={ //custom test parameters. See doc.md for a complete list
 
- 	time_dl_max: 20, //download test lasts up to 20 seconds
 
- 	time_ul_max: 20, //upload test lasts up to 20 seconds
 
- 	count_ping: 15, //ping+jitter test does 15 pings
 
-     getIp_ispInfo: false //will only get IP address without ISP info
 
- };
 
- function startStop(){
 
- 	if(w!=null){
 
- 		//speedtest is running, abort
 
- 		w.postMessage('abort');
 
- 		w=null;
 
- 		I("startStopBtn").className="";
 
- 		initUI();
 
- 	}else{
 
- 		//test is not running, begin
 
- 		w=new Worker('speedtest_worker.min.js');
 
- 		w.postMessage('start '+JSON.stringify(parameters)); //run the test with custom parameters
 
- 		I("startStopBtn").className="running";
 
- 		w.onmessage=function(e){
 
- 			var data=JSON.parse(e.data);
 
- 			var status=data.testState;
 
- 			if(status>=4){
 
- 				//test completed
 
- 				I("startStopBtn").className="";
 
- 				w=null;
 
- 			}
 
- 			I("ip").textContent=data.clientIp;
 
- 			I("dlText").textContent=(status==1&&data.dlStatus==0)?"...":data.dlStatus;
 
- 			I("ulText").textContent=(status==3&&data.ulStatus==0)?"...":data.ulStatus;
 
- 			I("pingText").textContent=data.pingStatus;
 
- 			I("jitText").textContent=data.jitterStatus;
 
- 		};
 
- 	}
 
- }
 
- //poll the status from the worker every 200ms (this will also update the UI)
 
- setInterval(function(){
 
- 	if(w) w.postMessage('status');
 
- },200);
 
- //function to (re)initialize UI
 
- function initUI(){
 
- 	I("dlText").textContent="";
 
- 	I("ulText").textContent="";
 
- 	I("pingText").textContent="";
 
- 	I("jitText").textContent="";
 
- 	I("ip").textContent="";
 
- }
 
- </script>
 
- </head>
 
- <body>
 
- <h1>HTML5 Speedtest - Custom settings example</h1>
 
- <div id="startStopBtn" onclick="startStop()"></div>
 
- <div id="test">
 
- 	<div class="testGroup">
 
- 		<div class="testArea">
 
- 			<div class="testName">Download</div>
 
- 			<div id="dlText" class="meterText"></div>
 
- 			<div class="unit">Mbps</div>
 
- 		</div>
 
- 		<div class="testArea">
 
- 			<div class="testName">Upload</div>
 
- 			<div id="ulText" class="meterText"></div>
 
- 			<div class="unit">Mbps</div>
 
- 		</div>
 
- 	</div>
 
- 	<div class="testGroup">
 
- 		<div class="testArea">
 
- 			<div class="testName">Ping</div>
 
- 			<div id="pingText" class="meterText"></div>
 
- 			<div class="unit">ms</div>
 
- 		</div>
 
- 		<div class="testArea">
 
- 			<div class="testName">Jitter</div>
 
- 			<div id="jitText" class="meterText"></div>
 
- 			<div class="unit">ms</div>
 
- 		</div>
 
- 	</div>
 
- 	<div id="ipArea">
 
- 		IP Address: <span id="ip"></span>
 
- 	</div>
 
- </div>
 
- <div>Custom parameters: <span id="params"></span><script type="text/javascript">I("params").textContent=JSON.stringify(parameters)</script></div>
 
- <a href="https://github.com/adolfintel/speedtest">Source code</a>
 
- <script type="text/javascript">initUI();</script>
 
- </body>
 
- </html>
 
 
  |