diff --git a/assets/scripts/heartbeat.js b/assets/scripts/heartbeat.js index 3e3803f..7c74d21 100644 --- a/assets/scripts/heartbeat.js +++ b/assets/scripts/heartbeat.js @@ -6,20 +6,30 @@ document.addEventListener('DOMContentLoaded', async function() { try { const response = await fetch('https://quinten0508.com/api/heartbeat'); const data = await response.json(); - const phoneDevice = data.find(device => device.device_name === 'Phone'); - if (phoneDevice) { - const phoneTimestamp = phoneDevice.last_beat.timestamp; - const timestampMilliseconds = phoneTimestamp * 1000; - + + // Find device with the latest heartbeat + let latestDevice = null; + let latestTimestamp = 0; + + data.forEach(device => { + const timestamp = device.last_beat.timestamp; + if (timestamp > latestTimestamp) { + latestTimestamp = timestamp; + latestDevice = device; + } + }); + + if (latestDevice) { + const timestampMilliseconds = latestTimestamp * 1000; const currentTime = Date.now(); const difference = currentTime - timestampMilliseconds; const isDead = difference > (1000 * 60 * 60 * 48); const online = difference < (1000 * 60 * 5); + if (online) { heartbeatElement.textContent = 'Online!'; heartbeatElement.style = 'color: #00b400'; - return; } else if (isDead) { heartbeatElement.textContent = 'Dead'; heartbeatElement.style = 'color: #b30000'; @@ -28,8 +38,9 @@ document.addEventListener('DOMContentLoaded', async function() { heartbeatElement.style = 'color: #00b400'; } + } else { - console.error('Device "Phone" not found.'); + console.error('No devices found.'); } } catch (error) { console.error('Error fetching last beat:', error); @@ -39,4 +50,4 @@ document.addEventListener('DOMContentLoaded', async function() { // Fetch the last beat immediately and then every 10 seconds fetchLastBeat(); setInterval(fetchLastBeat, 10000); -}); +}); \ No newline at end of file diff --git a/gallery.html b/gallery.html index a51f1ea..08ed218 100644 --- a/gallery.html +++ b/gallery.html @@ -7,92 +7,13 @@ + + - @@ -190,6 +111,16 @@ + +
diff --git a/gallery/20240708_amsterdam.html b/gallery/20240708_amsterdam.html index 1eb19d7..eb83e83 100644 --- a/gallery/20240708_amsterdam.html +++ b/gallery/20240708_amsterdam.html @@ -7,80 +7,13 @@ + + - - @@ -146,7 +79,7 @@
- /home/quinten/gallery/20250301_porter
+
/home/quinten/gallery/20240708_amsterdam
- /home/quinten/gallery
+
/home/quinten/gallery/20240802_chamonix
- /home/quinten/gallery/20250301_porter
+
/home/quinten/gallery/TEMPLATE