<!DOCTYPE html>
<html>

<head>
    <script src="../src/ndt7.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="server"></div>
    <div id="download"></div>
    <div id="upload"></div>
    <script type="text/javascript">
        ndt7.test(
            {
                userAcceptedDataPolicy: true,
                downloadworkerfile: "../src/ndt7-download-worker.min.js",
                uploadworkerfile: "../src/ndt7-upload-worker.min.js",
            },
            {
                serverChosen: function (server) {
                    console.log('Testing to:', {
                        machine: server.machine,
                        locations: server.location,
                    });
                    document.getElementById('server').innerHTML = 'Testing to: ' + server.machine + ' (' + server.location.city + ')';
                },
                downloadMeasurement: function (data) {
                    if (data.Source === 'client') {
                        document.getElementById('download').innerHTML = 'Download: ' + data.Data.MeanClientMbps.toFixed(2) + ' Mb/s';
                    }
                },
                downloadComplete: function (data) {
                    // (bytes/second) * (bits/byte) / (megabits/bit) = Mbps
                    const serverBw = data.LastServerMeasurement.BBRInfo.BW * 8 / 1000000;
                    const clientGoodput = data.LastClientMeasurement.MeanClientMbps;
                    console.log(
                        `Download test is complete:
    Instantaneous server bottleneck bandwidth estimate: ${serverBw} Mbps
    Mean client goodput: ${clientGoodput} Mbps`);
                    document.getElementById('download').innerHTML = 'Download: ' + clientGoodput.toFixed(2) + ' Mb/s';
                },
                uploadMeasurement: function (data) {
                    if (data.Source === 'server') {
                        document.getElementById('upload').innerHTML = 'Upload: ' + (data.Data.TCPInfo.BytesReceived /
                            data.Data.TCPInfo.ElapsedTime * 8).toFixed(2) + ' Mb/s';;
                    }
                },
                uploadComplete: function (data) {
                    // TODO: used actual upload duration for rate calculation.
                    // bytes * (bits/byte() * (megabits/bit) * (1/seconds) = Mbps
                    const serverBw =
                        data.LastServerMeasurement.TCPInfo.BytesReceived * 8 / 1000000 / 10;
                    const clientGoodput = data.LastClientMeasurement.MeanClientMbps;
                    console.log(
                        `Upload test is complete:
    Mean server throughput: ${serverBw} Mbps
    Mean client goodput: ${clientGoodput} Mbps`);
                    document.getElementById('upload').innerHTML = 'Upload: ' + clientGoodput.toFixed(2) + ' Mb/s';
                },
                error: function (err) {
                    console.log('Error while running the test:', err.message);
                },
            },
        ).then((exitcode) => {
            console.log("ndt7 test completed with exit code:", exitcode)
        });
    </script>

</html>
Add HTML example to the examples/ folder.
Add HTML example to the examples/ folder.
