|
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8"> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 | | - <title>Monitor Display</title> |
| 6 | + <title>Robotic Positioning Unit</title> |
7 | 7 | <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script> |
8 | 8 | <style> |
9 | 9 | body { |
10 | 10 | font-family: Arial, sans-serif; |
11 | | - padding: 20px; |
| 11 | + display: flex; |
| 12 | + justify-content: center; |
| 13 | + align-items: center; |
| 14 | + height: 100vh; |
| 15 | + margin: 0; |
| 16 | + background-color: #f4f4f9; |
12 | 17 | } |
13 | | - .element { |
14 | | - padding: 5px 0; |
| 18 | + .position-display { |
| 19 | + text-align: center; |
| 20 | + } |
| 21 | + .position { |
| 22 | + font-size: 4rem; |
| 23 | + font-weight: bold; |
| 24 | + margin: 10px 0; |
| 25 | + color: #333; |
| 26 | + } |
| 27 | + .position span { |
| 28 | + font-size: 1.5rem; |
| 29 | + color: #555; |
15 | 30 | } |
16 | 31 | </style> |
17 | 32 | </head> |
18 | 33 | <body> |
19 | | - <h1>Monitor Display</h1> |
20 | | - <div id="monitor"></div> |
| 34 | + <div class="position-display" id="positionDisplay"> |
| 35 | + <div class="position" id="posX">X: <span>000.000</span> mm</div> |
| 36 | + <div class="position" id="posY">Y: <span>000.000</span> mm</div> |
| 37 | + <div class="position" id="posZ">Z: <span>000.000</span> mm</div> |
| 38 | + </div> |
21 | 39 |
|
22 | 40 | <script> |
23 | | - const monitorDiv = document.getElementById('monitor'); |
24 | 41 | const socket = io(); |
25 | 42 |
|
26 | | - // Listen for updates from the server |
| 43 | + // Update the positions when data is received from the server |
27 | 44 | socket.on('update', function(data) { |
28 | 45 | const parsedData = JSON.parse(data); |
29 | | - monitorDiv.innerHTML = ''; // Clear previous content |
30 | | - |
31 | | - // Display each element_id: text pair |
32 | | - for (const [element_id, text] of Object.entries(parsedData)) { |
33 | | - const elementDiv = document.createElement('div'); |
34 | | - elementDiv.classList.add('element'); |
35 | | - elementDiv.textContent = `${text}`; |
36 | | - monitorDiv.appendChild(elementDiv); |
37 | | - } |
| 46 | + |
| 47 | + // Set the text content for each axis position |
| 48 | + document.getElementById('posX').querySelector('span').textContent = parsedData['element1']; |
| 49 | + document.getElementById('posY').querySelector('span').textContent = parsedData['element2']; |
| 50 | + document.getElementById('posZ').querySelector('span').textContent = parsedData['element3']; |
38 | 51 | }); |
39 | 52 | </script> |
40 | 53 | </body> |
|
0 commit comments