Skip to content

Commit 10b511e

Browse files
hysplit is auto refreshed every 60s
1 parent 96e9bf4 commit 10b511e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

js/app.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ var loadComplete = function(e) {
6262
}
6363

6464
var hysplit = {};
65+
var refresh_hysplit = function() {
66+
$.getJSON("http://spacenear.us/tracker/datanew.php?type=hysplit&format=json", function(data) {
67+
for(var k in data) {
68+
if(k in hysplit) {
69+
// if the jobid is the same, skip to next one
70+
if(hysplit[k].jobid == data[k]) continue;
71+
72+
// otherwise update the url
73+
hysplit[k].setUrl("http://ready.arl.noaa.gov/hypubout/HYSPLITtraj_" + data[k] + ".kmz");
74+
hysplit[k].jobid = data[k];
75+
} else {
76+
hysplit[k] = new google.maps.KmlLayer({url:"http://ready.arl.noaa.gov/hypubout/HYSPLITtraj_" + data[k] + ".kmz", preserveViewport:true });
77+
hysplit[k].jobid = data[k];
78+
}
79+
}
80+
});
81+
}
6582

6683
// loads the tracker interface
6784
function trackerInit() {
@@ -77,11 +94,9 @@ function trackerInit() {
7794
if(embed.graph) $('#telemetry_graph').attr('style','');
7895

7996
// fetch hysplit jobs
80-
$.getJSON("http://spacenear.us/tracker/datanew.php?type=hysplit&format=json", function(data) {
81-
for(var k in data) {
82-
hysplit[k] = new google.maps.KmlLayer({url:"http://ready.arl.noaa.gov/hypubout/HYSPLITtraj_" + data[k] + ".kmz", preserveViewport:true });
83-
}
84-
});
97+
setInterval(refresh_hysplit, 60 * 1000);
98+
refresh_hysplit();
99+
85100
return;
86101
}
87102
checkSize();

0 commit comments

Comments
 (0)