05/24 Enhance functionalities

This commit is contained in:
2026-05-24 18:10:11 -04:00
parent 6605484927
commit fbf271ed71
15 changed files with 593 additions and 30 deletions
+20 -16
View File
@@ -381,25 +381,29 @@ function esc(str) {
});
}
/* ── Health dots ───────────────────────────────────────────── */
/* ── Health dots (server-side probe) ───────────────────────── */
document.querySelectorAll('.site-card').forEach(function(card) {
var id = card.dataset.id;
var url = card.dataset.url;
var dot = document.getElementById('health-' + id);
if (!dot || !url) return;
var img = new Image();
var t0 = Date.now();
img.onload = function() {
var ms = Date.now() - t0;
dot.style.color = ms > 3000 ? '#d97706' : '#16a34a';
dot.title = ms > 3000 ? 'Slow (' + ms + 'ms)' : 'Reachable (' + ms + 'ms)';
};
img.onerror = function() {
var ms = Date.now() - t0;
dot.style.color = ms < 6000 ? '#d97706' : '#dc2626';
dot.title = ms < 6000 ? 'Reachable (restricted)' : 'Unreachable';
};
img.src = 'https://www.google.com/s2/favicons?domain=' + encodeURIComponent(url) + '&t=' + Date.now();
if (!dot) return;
fetch('/dashboard/health/' + id, {credentials: 'same-origin'})
.then(function(r) { return r.json(); })
.then(function(d) {
if (d.status === 'ok') {
dot.style.color = d.ms > 3000 ? '#d97706' : '#16a34a';
dot.title = 'Reachable (' + d.ms + 'ms)';
} else if (d.status === 'timeout') {
dot.style.color = '#d97706';
dot.title = 'Timeout (>6s)';
} else {
dot.style.color = '#dc2626';
dot.title = 'Unreachable';
}
})
.catch(function() {
dot.style.color = '#9ca3af';
dot.title = 'Health check failed';
});
});
</script>