File size: 3,965 Bytes
40518b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Live Fitness Trainer Test (WebSocket)</title>
    <script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
    <style>
        body { font-family: sans-serif; display: flex; flex-direction: column; align-items: center; margin: 0; padding: 20px; background-color: #f4f4f4; }
        #controls { margin-bottom: 20px; padding: 15px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
        label, select, button { font-size: 1em; margin: 5px; }
        button { padding: 10px 15px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
        button:disabled { background-color: #ccc; }
        button:hover:not(:disabled) { background-color: #0056b3; }
        #videoContainer { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 20px; }
        video { border: 2px solid #007bff; transform: scaleX(-1); border-radius: 8px; background-color: #000; } /* Flip video for mirror effect */
        #feedbackArea { border: 1px solid #ccc; padding: 15px; width: 320px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
        #feedbackArea h3 { margin-top: 0; color: #007bff; }
        #feedbackArea p { margin: 8px 0; }
        #feedbackArea span { font-weight: bold; color: #333; }
        /* .hidden class is not strictly needed as JS controls display style directly */
        /* However, if used by JS: .hidden { display: none; } */
    </style>
</head>
<body>
    <h1>Live Fitness Trainer Test (WebSocket)</h1>

    <div id="controls">
        <label for="exerciseTypeSelect">Exercise:</label>
        <select id="exerciseTypeSelect">
            <option value="squat">Squat</option>
            <option value="push_up">Push Up</option>
            <option value="hammer_curl">Hammer Curl</option>
        </select>
        <button id="startButton">Start Trainer</button>
        <button id="stopButton" disabled>Stop Trainer</button>
    </div>

    <div id="videoContainer">
        <div>
            <h3>Your Webcam</h3>
            <video id="videoElement" width="320" height="240" autoplay playsinline></video>
        </div>
        <div id="feedbackArea">
            <h3>Feedback & Status</h3>
            <!-- These are not directly updated by websocket_trainer.js but can be kept for manual/other updates if needed -->
            <p>Session ID: <span id="sessionIdDisplay">-</span></p> <!-- websocket_trainer.js doesn't update this -->
            <p>Status: <span id="statusDisplay">Idle</span></p> <!-- websocket_trainer.js doesn't update this -->
            <hr>

            <!-- Generic UI for Squat/Push-up -->
            <div class="generic-exercise-specific">
                <p>Reps: <span id="repsDisplay">0</span></p>
                <p>Stage: <span id="stageDisplay">-</span></p>
                <p>Feedback: <span id="feedbackDisplay">-</span></p>
                <p>Angle: <span id="angleDisplay">-</span></p>
            </div>

            <!-- Specific UI for Hammer Curl -->
            <div class="hammer-curl-specific" style="display: none;"> <!-- Initially hidden by style, JS will manage -->
                <p>Reps Left: <span id="repsLeftDisplay">0</span> | Reps Right: <span id="repsRightDisplay">0</span></p>
                <p>Stage Left: <span id="stageLeftDisplay">-</span> | Stage Right: <span id="stageRightDisplay">-</span></p>
                <p>Feedback Left: <span id="feedbackLeftDisplay">-</span></p>
                <p>Feedback Right: <span id="feedbackRightDisplay">-</span></p>
                <!-- The generic 'angleDisplay' is used for hammer curl angles by websocket_trainer.js -->
            </div>
        </div>
    </div>

    <script src="static/js/websocket_trainer.js"></script>
</body>
</html>