Skip to content

Commit 90eb5c4

Browse files
committed
Overflow and error handling improved
1 parent 9c7bbdd commit 90eb5c4

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

display.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = RED => {
5151
'9': [ true, true, true, true, false, true, true ]
5252
};
5353

54-
let value = '';
54+
let value = '---';
5555

5656
if( msg ) {
5757
switch( typeof msg.payload ) {
@@ -68,16 +68,12 @@ module.exports = RED => {
6868
break;
6969

7070
}
71-
72-
value = value.replace( '.', '' );
73-
74-
if( value.length > $scope.digits ) {
75-
value = '';
76-
}
7771
}
7872

79-
if( value === '' ) {
80-
value = ''.padStart( $scope.digits, '-' );
73+
value = value.replace( '.', '' );
74+
75+
if( value.length > $scope.digits ) {
76+
value = value.substr( -$scope.digits );
8177
} else {
8278
value = value.padStart( $scope.digits );
8379
}
@@ -91,7 +87,7 @@ module.exports = RED => {
9187
}
9288
} );
9389

94-
if( $scope.decimals > 0 && idx === $scope.digits - $scope.decimals - 1 ) {
90+
if( $scope.decimals > 0 && value.charAt( idx ) !== '-' && idx === $scope.digits - $scope.decimals - 1 ) {
9591
$( digit ).find( 'path:last-child' ).css( 'fill', 'var( --nr-dashboard-pageTitlebarBackgroundColor )' );
9692
} else {
9793
$( digit ).find( 'path:last-child' ).css( 'fill', 'var( --nr-dashboard-groupBackgroundColor )' );

0 commit comments

Comments
 (0)