| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/bc.the-word.com/ |
Upload File : |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Live OCR Feed</title>
<style>
body {
font-family: Arial, sans-serif;
}
#messages {
max-height: 90vh;
overflow-y: auto;
border: 1px solid #ccc;
padding: 10px;
}
.message {
padding: 5px;
border-bottom: 1px solid #ddd;
white-space: pre-wrap;
}
h1 {
text-align: center;
}
</style>
</head>
<body>
<h1>Live OCR Feed</h1>
<div id="messages"></div>
<script>
const socket = new WebSocket('wss://bc.the-word.com:8080/messages');
const messagesDiv = document.getElementById('messages');
let autoScroll = true; // start with auto-scrolling enabled
// Check if the user is scrolled to the bottom
function isAtBottom() {
const threshold = 5; // allow a tiny margin
return messagesDiv.scrollHeight - messagesDiv.scrollTop - messagesDiv.clientHeight < threshold;
}
// Scroll to bottom
function scrollToBottom() {
messagesDiv.scrollTop = messagesDiv.scrollHeight;
}
// On user scroll, decide if we should keep auto-scrolling
messagesDiv.addEventListener('scroll', () => {
if (isAtBottom()) {
// If user has scrolled back to bottom, re-enable autoScroll
autoScroll = true;
} else {
// User scrolled up, disable autoScroll
autoScroll = false;
}
});
socket.addEventListener('open', () => {
console.log('Connected to the server');
});
socket.addEventListener('message', (event) => {
try {
const data = JSON.parse(event.data);
const msgDiv = document.createElement('div');
msgDiv.className = 'message';
msgDiv.textContent = `${data.timestamp} - ${data.text}`;
messagesDiv.appendChild(msgDiv);
// After adding a new message, if autoScroll is true, scroll down
if (autoScroll) {
scrollToBottom();
}
} catch (e) {
console.error('Failed to parse incoming message as JSON:', event.data, e);
}
});
socket.addEventListener('close', () => {
console.log('Connection closed by server');
});
socket.addEventListener('error', (error) => {
console.error('WebSocket error:', error);
});
// Initially scroll to bottom (if empty, doesn't matter, but if you load older messages, you might)
scrollToBottom();
</script>
</body>
</html>