Skip to content

Commit 74af0c0

Browse files
committed
show next launch
1 parent a32d10c commit 74af0c0

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

js/tracker.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,33 @@ function showLaunchSites() {
639639
sondes = sondes.replace(new RegExp("\\b82\\b"), "LMS6-1680 (possible to track)");
640640
sondes = sondes.replace(new RegExp("\\b84\\b"), "iMet-54 (possible to track)");
641641
var marker = new L.circleMarker(latlon, {color: '#696969', fillColor: "white", radius: 8});
642-
var popup = new L.popup({ autoClose: false, closeOnClick: false }).setContent("<font style='font-size: 13px'>" + json[key].station_name + "</font><br><br><b>Sondes launched:</b> " + sondes);
642+
if (json[key].hasOwnProperty('times')) {
643+
var tempDate = null;
644+
for (var i = 0; i < json[key]['times'].length; i++) {
645+
var date = new Date();
646+
var now = new Date();
647+
var time = json[key]['times'][i].split(":");
648+
date.setUTCHours(time[0]);
649+
date.setUTCMinutes(time[1]);
650+
date.setSeconds(0);
651+
if (date < now) {
652+
date.setDate(date.getDate() + 1);
653+
}
654+
if (tempDate) {
655+
if (date < tempDate) {
656+
tempDate = date;
657+
var popup = new L.popup({ autoClose: false, closeOnClick: false }).setContent("<font style='font-size: 13px'>" + json[key].station_name + "</font><br><br><b>Sondes launched:</b> " + sondes +
658+
"<br><b>Next launch:</b> " + date.toString());
659+
}
660+
} else {
661+
tempDate = date;
662+
var popup = new L.popup({ autoClose: false, closeOnClick: false }).setContent("<font style='font-size: 13px'>" + json[key].station_name + "</font><br><br><b>Sondes launched:</b> " + sondes +
663+
"<br><b>Next launch:</b> " + date.toString());
664+
}
665+
}
666+
} else {
667+
var popup = new L.popup({ autoClose: false, closeOnClick: false }).setContent("<font style='font-size: 13px'>" + json[key].station_name + "</font><br><br><b>Sondes launched:</b> " + sondes);
668+
}
643669
marker.bindPopup(popup);
644670
launches.addLayer(marker);
645671
}

0 commit comments

Comments
 (0)