Skip to content

Commit 7d26571

Browse files
added status message to bottom right corner of map
fix #61
1 parent 0f993d8 commit 7d26571

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

js/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ var updateTime = function(date) {
366366

367367
elm.each(function(k,v) {
368368
var e = $(v);
369+
if(e.attr('data-timestamp') === undefined) return;
369370
var ts = e.attr('data-timestamp');
370371
var str = format_time_friendly(ts, now);
371372
if(str) e.text(str + ' ago');

js/tracker.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ function load() {
436436
overlay.draw = function() {};
437437
overlay.setMap(map);
438438

439+
// status message boxes
440+
var statusElm = new google.maps.StatusTextControl({
441+
map: map,
442+
position: google.maps.ControlPosition.RIGHT_BOTTOM,
443+
text: "<span id='stText'></span><span> Updated: </span><i class='friendly-dtime' id='stTimer'>never</i>"
444+
});
445+
446+
439447
google.maps.event.addListener(map, 'zoom_changed', function() {
440448
updateZoom();
441449
});
@@ -494,10 +502,6 @@ function load() {
494502
if(offline.get('opt_layers_aprs')) map.overlayMapTypes.setAt("1", overlayAPRS);
495503
}
496504

497-
function unload() {
498-
google.maps.Unload();
499-
}
500-
501505
function panTo(vcallsign) {
502506
if(!vcallsign) return;
503507

@@ -2087,11 +2091,9 @@ function refresh() {
20872091
if(ajax_inprogress) {
20882092
periodical = setTimeout(refresh, 2000);
20892093
}
2090-
//status = '<img src="spinner.gif" width="16" height="16" alt="" /> Refreshing ...';
2091-
//$('#status_bar').html(status);
20922094

2093-
//if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'ajax', 'refresh', 'Vehicles']);
2094-
//
2095+
$("#stText").text("checking |");
2096+
20952097
var mode = wvar.mode.toLowerCase();
20962098
mode = (mode == "position") ? "latest" : mode.replace(/ /g,"");
20972099

@@ -2104,10 +2106,21 @@ function refresh() {
21042106
dataType: "json",
21052107
success: function(response, textStatus) {
21062108
ajax_inprogress = true;
2109+
$("#stText").text("loading |");
2110+
response.fetch_timestamp = Date.now();
21072111
update(response);
2112+
$("#stText").text("");
2113+
$("#stTimer").attr("data-timestamp", response.fetch_timestamp);
21082114
},
21092115
error: function() {
2110-
if(!zoomed_in && offline.get('opt_offline')) update(offline.get('positions'));
2116+
$("#stText").text("error |");
2117+
2118+
if(!zoomed_in && offline.get('opt_offline')) {
2119+
var data = offline.get('positions');
2120+
update(data);
2121+
$("#stText").text("no connection |");
2122+
$("#stTimer").attr("data-timestamp", data.fetch_timestamp);
2123+
}
21112124
},
21122125
complete: function(request, textStatus) {
21132126
periodical = setTimeout(refresh, timer_seconds * 1000);

0 commit comments

Comments
 (0)