File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ public static void fillPoints(JSONArray points){
3737 obj .put ("lat" ,node .getLatitude ());
3838 obj .put ("lng" ,node .getLongitude ());
3939 obj .put ("type" ,service .getType ());
40+ long ttl = (300_000 -(System .currentTimeMillis ()-service .getLastSeen ()));
41+ if (ttl <0 ){
42+ ttl = 0 ;
43+ }
44+ obj .put ("ttl" ,ttl /1000 );
4045 points .put (obj );
4146 }
4247 }
Original file line number Diff line number Diff line change @@ -49,7 +49,13 @@ const POINT_RADIUS = {
4949} ;
5050
5151globe . pointAltitude ( point => POINT_ALTITUDE [ point . type ] ) ;
52- globe . pointColor ( point => POINT_COLOR [ point . type ] ) ;
52+ globe . pointColor ( function ( point ) {
53+ var color = POINT_COLOR [ point . type ] ;
54+ if ( point . ttl !== undefined ) {
55+ color += Math . round ( point . ttl / 300 * 256 ) . toString ( 16 ) . padStart ( 2 , '0' ) ;
56+ }
57+ return color ;
58+ } ) ;
5359globe . pointLabel ( point => point . label ) ;
5460globe . pointRadius ( point => POINT_RADIUS [ point . type ] ) ;
5561
@@ -117,10 +123,10 @@ function updateGlobe(){
117123 fetch ( '/api' )
118124 . then ( resp => resp . json ( ) )
119125 . then ( json => {
120- data = json ;
121- updatePointsData ( json . points ) ;
122- globe . arcsData ( json . arcs ) ;
123- } ) ;
126+ data = json ;
127+ updatePointsData ( json . points ) ;
128+ globe . arcsData ( json . arcs ) ;
129+ } ) ;
124130}
125131
126132setInterval ( updateGlobe , 1_000 ) ;
You can’t perform that action at this time.
0 commit comments