Skip to content

Commit 3a077c0

Browse files
better duplicate callsign removal
1 parent 737649b commit 3a077c0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

js/tracker.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,12 @@ var marker_rotate_setup = function(marker, image_src) {
13201320
}
13211321
};
13221322

1323+
var array_unique = function(inarr) {
1324+
var seen = {};
1325+
return inarr.filter(function(v) {
1326+
return seen.hasOwnProperty(v) ? false : (seen[v] = true);
1327+
});
1328+
};
13231329

13241330
function addPosition(position) {
13251331
var vcallsign = position.vehicle;
@@ -1734,9 +1740,10 @@ function addPosition(position) {
17341740
var dt = (new_ts - curr_ts) / 1000; // convert to seconds
17351741

17361742
if(dt === 0 && vehicle.num_positions) {
1737-
if (("," + vehicle.curr_position.callsign + ",").indexOf("," + position.callsign + ",") === -1) {
1738-
vehicle.curr_position.callsign += "," + position.callsign;
1739-
}
1743+
var callsigns = vehicle.curr_position.callsign.split(', ');
1744+
var newcalls = callsigns.concat(position.callsign.split(', '));
1745+
1746+
vehicle.curr_position.callsign = array_unique(callsigns).join(', ');
17401747
}
17411748
else if(dt >= 0) {
17421749
if(vehicle.num_positions > 0) {

0 commit comments

Comments
 (0)