diff --git a/src/main/java/com/lbry/globe/api/API.java b/src/main/java/com/lbry/globe/api/API.java index 567dc83..b7ba940 100644 --- a/src/main/java/com/lbry/globe/api/API.java +++ b/src/main/java/com/lbry/globe/api/API.java @@ -37,6 +37,11 @@ public class API{ obj.put("lat",node.getLatitude()); obj.put("lng",node.getLongitude()); obj.put("type",service.getType()); + long ttl = (300_000-(System.currentTimeMillis()-service.getLastSeen())); + if(ttl<0){ + ttl = 0; + } + obj.put("ttl",ttl/1000); points.put(obj); } } diff --git a/src/main/resources/globe.js b/src/main/resources/globe.js index 0cca6ee..cdcdfe4 100644 --- a/src/main/resources/globe.js +++ b/src/main/resources/globe.js @@ -49,7 +49,13 @@ const POINT_RADIUS = { }; globe.pointAltitude(point => POINT_ALTITUDE[point.type]); -globe.pointColor(point => POINT_COLOR[point.type]); +globe.pointColor(function(point){ + var color = POINT_COLOR[point.type]; + if(point.ttl!==undefined){ + color += Math.round(point.ttl/300*256).toString(16).padStart(2,'0'); + } + return color; +}); globe.pointLabel(point => point.label); globe.pointRadius(point => POINT_RADIUS[point.type]); @@ -117,10 +123,10 @@ function updateGlobe(){ fetch('/api') .then(resp => resp.json()) .then(json => { - data = json; - updatePointsData(json.points); - globe.arcsData(json.arcs); - }); + data = json; + updatePointsData(json.points); + globe.arcsData(json.arcs); + }); } setInterval(updateGlobe,1_000);