<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>Mocha Monster</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="mocha.css"/>

</head>
<body>
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
  <h1 style='margin-bottom: 0.1em;'>Monster 3.102.2</h1>
  <div id="lastupdate" style='font-size:0.7em'>last update Mi 29. Jan 14:25:07 CET 2025</div>
</div>
<div id="mocha-errors"
     style="color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>
<div id="mocha-done"
     style="color: grey;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>
<div id="mocks" style="position: absolute;right: 0;top: -1000px;"></div>
<div id="mocha"></div>
<script src="mocha.js?"></script>
<script>
    mocha.setup('bdd');
</script>
<script src="tests.js?r=21:36:59"></script>
<script>

    try {

        addEventListener("error", (event) => {
            document.getElementById('mocha-errors').insertAdjacentHTML("afterbegin", event.message);
            document.getElementById('mocha-stats').style.backgroundColor = 'red';
        });

        let runner = mocha.run((failures) => {
            if (failures) {
                document.getElementById('mocha-stats').style.backgroundColor = 'red';
            } else {
                document.getElementById('mocha-stats').style.backgroundColor = 'green';
            }

        });

        runner.on('end', function () {
            document.getElementById('mocha-done').insertAdjacentHTML("afterbegin", 'the execution is done');
            document.getElementById('lastupdate').innerHTML = 'last update ' + new Date();
        });
        
        runner.on('fail', function () {
            document.querySelector('body').insertAdjacentHTML("afterbegin", '<div style="color: red;">error</div>');
            document.getElementById('lastupdate').innerHTML = 'last update ' + new Date();
        });

    } catch (e) {
        document.querySelector('body').insertAdjacentHTML("afterbegin", '<div style="color: red;">' + e + '</div>');

        console.error(e);
        document.getElementById('mocha-stats').style.backgroundColor = 'red';
    }

</script>
</body>
</html>