|
| 1 | +var ssdv_url = "http://ssdv.habhub.org/data.php?callback=?&format=jsonp&request=update&last_id="; |
| 2 | +var ssdv_last_id = 0; |
| 3 | +var ssdv_timer = ssdv_timer || null; |
| 4 | +var ssdv_html = "<div id='ssdv' style='z-index: 20;position:absolute;bottom:0px;right:0px;width:320px'>" + |
| 5 | + "<span class='label' style='z-index:21;display:block;width:100%;background:#00a3d3;height:20px;padding:3px 5px;font-weight: bold;font-size: 11px;color:#fff;border-radius:5px 0 0 0;box-shadow:1px -1px 5px rgba(0,0,0,0.2);cursor:pointer;'>SSDV</span>" + |
| 6 | + "<img src='' style='height:0px;display:none'/>" + |
| 7 | + "<span class='link' style='display:none;position:absolute;bottom:0px;right:0px;border-radius:5px 0 0 0;padding:0px 4px;background:rgba(0,0,0,0.2);color:#ccc;font-size:10px'>powered by <a style='color:#fff' href='http://ssdv.habhub.org'>ssdv.habhub.org</a></span>" + |
| 8 | + "</div>"; |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +$('#ssdv .label').live('click',function() { |
| 13 | + var img = $('#ssdv img'); |
| 14 | + var poweredby = $('#ssdv .link'); |
| 15 | + |
| 16 | + if(img.is(':visible')) { |
| 17 | + poweredby.fadeOut(); |
| 18 | + img.animate({'height':0}, function() { $(this).hide() }); |
| 19 | + } else { |
| 20 | + img.show().width(320).animate({'height':240}, function() { poweredby.fadeIn() }).css({'display':'block'}); |
| 21 | + } |
| 22 | +}); |
| 23 | + |
| 24 | +var jsonp_callback = function(data) { |
| 25 | + if($('#ssdv').length == 0) $('#map').append(ssdv_html); |
| 26 | + |
| 27 | + if(data.images.length > 0) { |
| 28 | + var img = data.images[0]; |
| 29 | + var time = new Date(); |
| 30 | + time.setTime((img.updated + (new Date()).getTimezoneOffset()) * 1000); |
| 31 | + var minutes = Math.floor(((new Date()).getTime() - time.getTime()) / 60000); |
| 32 | + |
| 33 | + $('#ssdv .label').text("SSDV from " + img.payload + " " + img.received_packets + "/" + img.lost_packets + " updated "+minutes+" min ago"); |
| 34 | + $('#ssdv img').attr('src', 'http://ssdv.habhub.org' + img.image); |
| 35 | + } |
| 36 | + |
| 37 | + ssdv_last_id = data.last_id; |
| 38 | +}; |
| 39 | + |
| 40 | +var ssdv_fetch = function() { |
| 41 | + $.getJSON(ssdv_url + ssdv_last_id); |
| 42 | +} |
| 43 | + |
| 44 | +setTimeout(ssdv_fetch, 2000); |
| 45 | +clearInterval(ssdv_timer); |
| 46 | +ssdv_timer = setInterval(ssdv_fetch, 16000); |
0 commit comments