record.html 2.41 KB
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"   />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
        <title>Haptic Recording</title>
        <link rel="stylesheet" href="{{url_for('static', filename = 'style.css')}}">
        <style>
            #stop, #home {
                width:100px;
                background-color: #f8585b;
                border: none;
                color:#fff;
                padding: 15px 0;
                border-radius:10px;
                text-align: center;
                text-decoration: none;
                display: inline-block;
                font-size: 20px;
                margin: 4px;
                cursor: pointer;
            }
        </style>
    </head>

    <body>
        <div style="text-align: center; padding-top: 10%;">
            <h1>Converting...</h1>
            <h1 style="margin-top: 2%; color:#f8585b;"id="clock">00:00</h1>
            <form method ="post" action="/stop">
                <button style="margin-top: 10%;" id="stop" type="submit"> STOP </button>
            </form>

                <button style="margin-top: 10%; visibility: hidden;" id="home" type="button" onclick="location.href='/'"> HOME </button>

        </div>
    <script type="module" src="{{url_for('static', filename = 'app.js')}}"></script>
    </body>
    
    <script>
        var clockTarget = document.getElementById("clock");
            var seconds = 0;
            var miliseconds = 0;

        function clock() {
            clockTarget .innerText = `${seconds < 10 ? `0${seconds }`: seconds }:${miliseconds < 10 ? `0${miliseconds }` :miliseconds}`;
            miliseconds = miliseconds +1;
            if(miliseconds >99){
            seconds = seconds +1;
            miliseconds = miliseconds %100;
            }
        }

        var inter;
        function init() {
            clock();
            inter = setInterval(clock, 10);
        }

        function stopit(){
            clearInterval(inter);
            document.getElementById("home").style.visibility="visible";
            document.getElementById("stop").style.visibility="hidden";
        }

        document.getElementById('stop').addEventListener('click', stopit);

        init();
    </script>
</html>