@sailingrotevista/rotevista-dash 6.0.4 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app.js +30 -2
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -1166,8 +1166,9 @@ function drawGraph(d, id, min, max, isTws, isHercules) {
1166
1166
  };
1167
1167
 
1168
1168
  let grids = "";
1169
- // Una sola linea di griglia centrale al 50%, matematicamente sempre intera e allineata all'etichetta
1170
- [0.5].forEach(p => grids += `<line x1="0" y1="${h-(p*h)}" x2="${w}" y2="${h-(p*h)}" stroke="rgba(0,0,0,0.12)" stroke-width="0.5" />`);
1169
+ // Tracciamo 3 linee simmetriche al 25%, 50% (centrale) e 75%.
1170
+ // La linea al 50% passerà sempre in modo matematicamente esatto dietro il valore medio stampato.
1171
+ [0.25, 0.5, 0.75].forEach(p => grids += `<line x1="0" y1="${h-(p*h)}" x2="${w}" y2="${h-(p*h)}" stroke="rgba(0,0,0,0.12)" stroke-width="0.5" />`);
1171
1172
 
1172
1173
  const gridInterval = (visibleMinutes <= 15) ? 1 : 5;
1173
1174
  for (let m = gridInterval; m < visibleMinutes; m += gridInterval) {
@@ -1377,7 +1378,34 @@ async function init() {
1377
1378
  connect(); // Si collegherà in tempo reale al WebSocket del Cerbo (usando l'IP di fallback se sei su Mac)
1378
1379
 
1379
1380
  setInterval(watchConfigChanges, 10000);
1381
+
1382
+ // ==========================================================================
1383
+ // WATCHDOG DI RISVEGLIO (SLEEP/WAKE DETECTOR)
1384
+ // ==========================================================================
1385
+
1386
+ // Rileva quando la scheda del browser torna in primo piano (es. sblocco iPad o Mac aperto)
1387
+ document.addEventListener('visibilitychange', () => {
1388
+ if (document.visibilityState === 'visible') {
1389
+ handleWakeUp();
1390
+ }
1391
+ });
1392
+
1393
+ // Rileva se il computer è andato in sospensione misurando il ritardo dei secondi
1394
+ let lastHeartbeat = Date.now();
1395
+ setInterval(() => {
1396
+ const now = Date.now();
1397
+ const diff = now - lastHeartbeat;
1398
+ lastHeartbeat = now;
1399
+
1400
+ // Se passano più di 6 secondi tra un ciclo e l'altro (invece di 1 secondo),
1401
+ // significa che il PC era in sospensione. Avviamo il risveglio.
1402
+ if (diff > 6000) {
1403
+ handleWakeUp();
1404
+ }
1405
+ }, 1000);
1380
1406
  }
1381
1407
 
1408
+
1409
+
1382
1410
  window.addEventListener('load', init);
1383
1411
  window.addEventListener('pagehide', saveDashboardState);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "6.0.4",
3
+ "version": "6.0.6",
4
4
  "description": "Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {