speedtest/examples/example-singleServer-basic.html

39 lines
1.1 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<meta charset="UTF-8" />
<head>
2019-09-25 06:23:53 +00:00
<title>LibreSpeed Example</title>
2019-08-22 04:41:14 +00:00
<link rel="shortcut icon" href="favicon.ico">
</head>
<script type="text/javascript" src="speedtest.js"></script>
<body>
2019-09-25 06:23:53 +00:00
<h1>LibreSpeed Example</h1>
<h4>IP Address</h4>
<p id="ip"></p>
<h4>Download</h4>
<p id="download"></p>
<h4>Upload</h4>
<p id="upload"></p>
<h4>Latency</h4>
<p id="ping"></p>
<script type="text/javascript">
var s=new Speedtest();
s.onupdate = function (data) { // when status is received, put the values in the appropriate fields
document.getElementById('download').textContent = data.dlStatus + ' Mbit/s'
document.getElementById('upload').textContent = data.ulStatus + ' Mbit/s'
document.getElementById('ping').textContent = data.pingStatus + ' ms, ' + data.jitterStatus + ' ms jitter'
document.getElementById('ip').textContent = data.clientIp
}
2023-08-28 20:12:08 +00:00
s.start(); // start the speed test with default settings
</script>
2019-09-25 06:23:53 +00:00
<a href="https://github.com/librespeed/speedtest">Source code</a>
</body>
</html>