-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobs.html
87 lines (80 loc) · 3.31 KB
/
obs.html
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OBS Log Display</title>
<style>
body {
background-color: transparent;
margin: 100;
padding: 20px;
overflow: hidden;
}
#log-content {
white-space: pre;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
color: #00ffd5;
line-height: 1.3;
font-weight: bold;
}
.other-info {
color: #ffff00; /* Yellow for other information lines */
}
.backward {
color: #eb2222;
}
.forward {
color: #0762ebf8;
}
.highlight {
text-shadow: 0 0 5px currentColor;
}
</style>
</head>
<body>
<div id="log-content"></div>
<script>
const logContent = document.getElementById('log-content');
const normalColor = '#00ffd5'; // Same as the regular text color
function getDamageColor(value, min, max) {
if (value < min) return normalColor; // Normal color for values below minimum
if (value >= max) return '#ff0000'; // Deep red for maximum value and above
const ratio = (value - min) / (max - min);
const r = 255;
const g = Math.floor(255 * (1 - ratio));
const b = Math.floor(255 * (1 - ratio));
return `rgb(${r},${g},${b})`;
}
function fetchLogContent() {
fetch('obs.log')
.then(response => response.text())
.then(data => {
const lines = data.trim().split('\n').slice(-20);
const formattedLines = lines.map(line => {
if (line.startsWith('Ball Hit,')) {
const match = line.match(/"([\d.]+) m\/s, ([\d.]+) rev\/s, (.+), (Forward|Backward)"/);
if (match) {
const speed = parseFloat(match[1]);
const spin = parseFloat(match[2]);
const direction = match[4];
const speedColor = getDamageColor(speed, 10, 20);
const spinColor = getDamageColor(spin, 50, 150);
const directionClass = direction.toLowerCase();
const speedSpan = speed >= 10 ? `<span class="highlight" style="color:${speedColor}">${speed} m/s</span>` : `${speed} m/s`;
const spinSpan = spin >= 50 ? `<span class="highlight" style="color:${spinColor}">${spin} rev/s</span>` : `${spin} rev/s`;
return `Ball Hit,"${speedSpan}, ${spinSpan}, ${match[3]}, <span class="${directionClass}">${direction}</span>"`;
}
}
return `<span class="other-info">${line}</span>`;
});
logContent.innerHTML = formattedLines.join('\n');
})
.catch(error => console.error('Error fetching log file:', error));
}
fetchLogContent();
setInterval(fetchLogContent, 1000);
</script>
</body>
</html>