|
|
@@ -74,6 +74,31 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // ----- Local-timezone datetime rendering ----------------------------
|
|
|
+ // Server emits each audit row's `occurred_at` as a UTC ISO-8601 string
|
|
|
+ // inside <time data-local-datetime datetime="…">…</time>. Rewrite the
|
|
|
+ // text content to the viewer's local timezone in dd.mm.YYYY HH:mm:ss.
|
|
|
+ function pad2(n) { return n < 10 ? '0' + n : '' + n; }
|
|
|
+ function formatLocalDateTime(d) {
|
|
|
+ return pad2(d.getDate()) + '.' + pad2(d.getMonth() + 1) + '.' + d.getFullYear()
|
|
|
+ + ' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes()) + ':' + pad2(d.getSeconds());
|
|
|
+ }
|
|
|
+ function localizeDateTimes(root) {
|
|
|
+ const scope = root || document;
|
|
|
+ const els = scope.querySelectorAll('time[data-local-datetime]');
|
|
|
+ els.forEach(function (el) {
|
|
|
+ const iso = el.getAttribute('datetime') || '';
|
|
|
+ if (iso === '') { return; }
|
|
|
+ const d = new Date(iso);
|
|
|
+ if (isNaN(d.getTime())) { return; }
|
|
|
+ el.textContent = formatLocalDateTime(d);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ document.addEventListener('DOMContentLoaded', function () { localizeDateTimes(); });
|
|
|
+ document.addEventListener('htmx:afterSwap', function (ev) {
|
|
|
+ localizeDateTimes(ev.target || document);
|
|
|
+ });
|
|
|
+
|
|
|
// ----- Alpine component registrations -------------------------------
|
|
|
document.addEventListener('alpine:init', function () {
|
|
|
// Hamburger menu — toggle, close on outside / Escape / item click.
|