Skip to content

Commit 04d63d3

Browse files
committed
Add fading for olders nodes
1 parent d253493 commit 04d63d3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/main/java/com/lbry/globe/api/API.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/main/resources/globe.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ const POINT_RADIUS = {
4949
};
5050

5151
globe.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+
});
5359
globe.pointLabel(point => point.label);
5460
globe.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

126132
setInterval(updateGlobe,1_000);

0 commit comments

Comments
 (0)