remove time

This commit is contained in:
2026-05-10 10:13:21 +02:00
parent 068c375fb6
commit a6f01ad8a3
3 changed files with 23 additions and 49 deletions
-1
View File
@@ -259,7 +259,6 @@
<div class="footer small">
<div><i class="fa-solid fa-server" style="margin-right: 2px;"></i><span id="server-status">connecting...</span></div>
<div><i class="fa-solid fa-user" style="margin-right: 2px;"></i><span id="user-count">-</span></div>
<div><i class="fa fa-arrows-h" style="margin-right: 2px;"></i><span id="ping-status">?</span>ms</div>
<div class="small" id="keybinds">
<span><kbd>S</kbd> skip</span>
<span><kbd>N</kbd> +skip</span>
-23
View File
@@ -17,7 +17,6 @@ let skippedIndices = [];
let lastElapsed = 0;
let lastUpdateTime = 0;
let currentRealTotal = 1;
let timeOffset = 0;
function toggleSection(id) {
document.getElementById(id).classList.toggle("collapsed");
@@ -83,13 +82,6 @@ function connectWs() {
ws.addEventListener("message", evt => {
handleMessage(JSON.parse(evt.data));
});
function syncTime() {
wsSend({ action: "get_time", client_time: performance.now() / 1000 });
}
setInterval(syncTime, 10000);
setTimeout(syncTime, 500);
}
function wsSend(obj) {
@@ -97,22 +89,7 @@ function wsSend(obj) {
}
function handleMessage(msg) {
if(msg.time && timeOffset != 0) {
const now = performance.now() / 1000;
const lag = now - (msg.time + timeOffset);
document.getElementById("ping-status").textContent = (Math.max(lag, 0) * 1000).toFixed(2);
}
switch (msg.event) {
case "time": {
const localNow = performance.now() / 1000;
const rtt = localNow - msg.client_time; // round-trip time
const serverNow = msg.data + rtt / 2; // estimate server time at this moment
const newOffset = localNow - serverNow;
if (timeOffset === 0) timeOffset = newOffset;
else timeOffset = timeOffset * 0.9 + newOffset * 0.1;
break;
}
case "state": {
const d = msg.data || {};
if (d.dirs) updateDirs(d.dirs);