Would anyone be able to help me, i am trying to implement a speedtest into my dashboard, the code is here: https://github.com/librespeed/speedtest. This uses HTML and Javascript elements which i have tried to use with reference here: Executing javascript block then modal are opened? but i am not getting anywhere with it.
I have the .js script published and i can browse to it but i cant get the html part to reference the javascript…
I have tried with Invoke-UDJavaScript and New-UDElement -Tag script -Attributes @{type=“application/javascript”} for the javascript element, and New-UDHtml -Markup.
The basic speedtest code:
<!DOCTYPE html>
<html>
<meta charset="UTF-8" />
<head>
<title>LibreSpeed Example</title>
<link rel="shortcut icon" href="favicon.ico">
</head>
<script type="text/javascript" src="speedtest.js"></script>
<body>
<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
}
s.start(); // start the speedtest with default settings
</script>
<a href="https://github.com/librespeed/speedtest">Source code</a>
</body>
</html>
Just incase anyone is bored - i wish i knew more about js.