This commit is contained in:
Your Name
2025-01-30 12:11:52 +01:00
parent 970f62658b
commit a689a7d2de
2 changed files with 29 additions and 1 deletions

View File

@@ -122,6 +122,10 @@
<input type="text" class="form-control" id="RTC_utc_time" disabled>
</div>
<div id="alert_container"></div>
</div>
<!-- UPDATE-->
@@ -222,6 +226,30 @@ window.onload = function() {
document.getElementById("sys_local_time").value = response.system_local_time;
document.getElementById("sys_UTC_time").value = response.system_utc_time;
document.getElementById("RTC_utc_time").value = response.rtc_module_time;
// Get the time difference
const timeDiff = response.time_difference_seconds;
// Reference to the alert container
const alertContainer = document.getElementById("alert_container");
// Remove any previous alert
alertContainer.innerHTML = "";
// Add an alert based on time difference
if (typeof timeDiff === "number") {
if (timeDiff >= 0 && timeDiff <= 10) {
alertContainer.innerHTML = `
<div class="alert alert-primary" role="alert">
RTC and system time are in sync (Difference: ${timeDiff} sec).
</div>`;
} else if (timeDiff > 10) {
alertContainer.innerHTML = `
<div class="alert alert-danger" role="alert">
RTC time is out of sync! (Difference: ${timeDiff} sec).
</div>`;
}
}
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);