* Fixed formatting of negative time values.
authorUrban Wallasch <urban.wallasch@freenet.de>
Tue, 30 Jul 2019 13:09:24 +0000 (15:09 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Tue, 30 Jul 2019 13:09:24 +0000 (15:09 +0200)
* Tweaked speed limit warning thresholds.
* Moved styling of special delivery time values to style sheet.

dash.html

index fc79cbcbd0aca8ef74a1e992746a1e6c10b90d3f..bfd04b8e227162affa21ab067837592084e1f8e1 100644 (file)
--- a/dash.html
+++ b/dash.html
@@ -60,6 +60,7 @@ table, caption, tbody, tfoot, thead, tr, th, td {
 .warn2 { color:#f20; }
 .setval { color:#0af; }
 .hilite { background-color: #ff0; }
+.special { font-size:50%; color:#088; }
 
 x-bar {
   display: block;
@@ -157,18 +158,27 @@ function pad2( x ) {
 }
 
 function s2hms(s) {
-  return pad2( Math.floor(s / 3600) ) + ':'
+  var sgn = Math.sign(s);
+  s = Math.abs(s);
+  return ( sgn < 0 ? '-' : '' )
+       + pad2( Math.floor(s / 3600) ) + ':'
        + pad2( Math.floor(s % 3600 / 60) ) + ':'
        + pad2( Math.floor(s % 60 ) );
 }
 
 function s2hm(s) {
-  return pad2( Math.floor(s / 3600) ) + ':'
+  var sgn = Math.sign(s);
+  s = Math.abs(s);
+  return ( sgn < 0 ? '-' : '' )
+       + pad2( Math.floor(s / 3600) ) + ':'
        + pad2( Math.floor(s % 3600 / 60) );
 }
 
 function m2hm(s) {
-  return pad2( Math.floor(s / 60) ) + ':'
+  var sgn = Math.sign(s);
+  s = Math.abs(s);
+  return ( sgn < 0 ? '-' : '' )
+       + pad2( Math.floor(s / 60) ) + ':'
        + pad2( Math.floor(s % 60) );
 }
 
@@ -209,10 +219,11 @@ function update_cb() {
     //// "speedo" box
 
     // speedometer:
-    speed.innerHTML = Math.abs(tele.speed * 3.6).toFixed(0);
-    if ( tele.nav_slimit > 0 && tele.speed > tele.nav_slimit * 1.075 )
+    var aspeed = Math.abs( tele.speed );
+    speed.innerHTML = (aspeed * 3.6).toFixed(0);
+    if ( tele.nav_slimit > 0 && aspeed > tele.nav_slimit + 1.9 )
       warn( speed, 2 );
-    else if ( tele.nav_slimit > 0 && tele.speed > tele.nav_slimit * 1.005 )
+    else if ( tele.nav_slimit > 0 && aspeed > tele.nav_slimit + 0.3 )
       warn( speed, 1 );
     else
       warn( speed, 0 );
@@ -278,8 +289,8 @@ function update_cb() {
       tele.job_isvalid
       ? tele.job_deltime != 4294967295
         ? m2hm(tele.job_deltime - tele.game_time)
-        : '<span style="font-size:50%;color:#088">[external]</span>'
-      : '<span style="font-size:50%;color:#088">[none]</span>';
+        : '<span class="special">[external]</span>'
+      : '<span class="special">[none]</span>'
 
     //// pause and error bar status: