diff --git a/srv/poe_manager/templates/index.html b/srv/poe_manager/templates/index.html
index 762a3c2..af836d4 100644
--- a/srv/poe_manager/templates/index.html
+++ b/srv/poe_manager/templates/index.html
@@ -34,16 +34,9 @@
document.addEventListener("DOMContentLoaded", () => {
const intervalMinutes = {{ interval | int }};
const intervalMilliseconds = intervalMinutes * 60 * 1000;
- let lastUpdateTime = Date.now();
+ let lastUpdateTime = Date.now(); // Startpunkt beim Laden der Seite
let reloadCountdown = null;
- let reloadTriggered = false; // verhindert endlose Reloads
-
- function parseLogTimestamp(ts) {
- const parts = ts.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
- if (!parts) return Date.now();
- const [, year, month, day, hour, minute, second] = parts.map(Number);
- return new Date(year, month - 1, day, hour, minute, second).getTime();
- }
+ let reloadTriggered = false;
function updateTimer() {
const now = Date.now();
@@ -63,13 +56,14 @@ document.addEventListener("DOMContentLoaded", () => {
reloadCountdown--;
if (reloadCountdown < 0) {
- reloadTriggered = true; // Reload nur einmal ausführen
- window.location.reload(); // Seite neu laden
+ reloadTriggered = true;
+ window.location.reload();
}
}
}
}
+ // Initiale Synchronisierung mit letzter Log-Zeit optional
function fetchLastLog() {
fetch("{{ url_for('get_log') }}")
.then(response => response.text())
@@ -85,7 +79,12 @@ document.addEventListener("DOMContentLoaded", () => {
if (lastSepIndex >= 0 && lastSepIndex + 1 < lines.length) {
const firstLine = lines[lastSepIndex + 1];
const match = firstLine.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/);
- if (match) lastUpdateTime = parseLogTimestamp(match[1]);
+ if (match) {
+ const logTime = new Date(match[1]).getTime();
+ // Nur Offset setzen, damit Haupt-Timer beim Laden nicht sofort abläuft
+ const offset = Math.min(Date.now() - logTime, intervalMilliseconds);
+ lastUpdateTime = Date.now() - offset;
+ }
}
})
.catch(err => console.error("Fehler beim Laden der Logs:", err));
@@ -96,5 +95,4 @@ document.addEventListener("DOMContentLoaded", () => {
});
-
{% endblock %}