Skip to content

Commit b71b2e4

Browse files
committed
pre-v1.0.5: new ttgo link icons, clickable sonde tooltip, gps pos info, additional sonde info on popup
1 parent 7e37c31 commit b71b2e4

File tree

7 files changed

+66
-18
lines changed

7 files changed

+66
-18
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="de.dl9rdz" version="1.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
2+
<widget id="de.dl9rdz" version="1.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
33
xmlns:android="schemas.android.com/apk/res/android">
44
<name>rdzSondyGO</name>
55
<description>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "de.dl9rdz",
33
"displayName": "rdzwx-go",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"description": "A sample Apache Cordova application that uses rdzwx-plugin.",
66
"main": "index.js",
77
"scripts": {

www/css/index.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,19 @@ html, body {
220220
.pop-header {
221221
display: flex;
222222
align-items:center;
223+
margin: 4px;
224+
}
225+
.pop-header > h4{
226+
margin: 4px;
223227
}
224228
.pop-header > img{
225229
display: inline-block;
226230
height: 16px;
227231

228232
}
233+
.leaflet-popup-content {
234+
margin: 6px 12px;
235+
}
229236

230237
.leaflet-center {
231238
position: relative !important;
@@ -336,3 +343,12 @@ h1 {
336343
color: #333;
337344
font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
338345
}
346+
347+
.online-active, .offline-active {
348+
padding-left: 0px;
349+
padding-right: 0px;
350+
}
351+
352+
button.offline-active, button.online-active {
353+
padding-top: 4px;
354+
}

www/img/ttgooff.png

834 Bytes
Loading

www/img/ttgoon.png

627 Bytes
Loading

www/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
<meta name="msapplication-tap-highlight" content="no">
3535
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover, user-scalable=no">
3636
<meta name="color-scheme" content="light dark">
37-
<link rel="stylesheet" href="css/index.css">
3837
<link rel="stylesheet" href="css/leaflet.css">
3938
<link rel="stylesheet" href="css/leaflet.contextmenu.css">
39+
<link rel="stylesheet" href="css/index.css">
4040
<script src="cordova.js"></script>
4141
<script src="js/leaflet.js"></script>
4242
<script src="js/leaflet.contextmenu.js"></script>
@@ -48,13 +48,13 @@
4848
<script src="js/easy-button.js"></script>
4949
<script src="js/L.Control.MousePosition.js"></script>
5050

51-
<title>rdzSondyGO V1.0.4</title>
51+
<title>rdzSondyGO V1.0.5</title>
5252
</head>
5353
<body>
5454
<div id="all">
5555
<div id="toolbar">
5656
<a id="toolbarclose" class="leaflet-popup-close-button" style="cursor: pointer; float: right;">X</a>
57-
<h2>rdzSondyGO v1.0.4</h2>
57+
<h2>rdzSondyGO v1.0.5</h2>
5858
<p>Copyright &copy; 2021 Hansi Reiser, dl9rdz</p>
5959
<p>see <a href="https://github.com/dl9rdz/rdzwx-go">https://github.com/dl9rdz/rdzwx-go</a> for details</p>
6060
<p>Apache License Version 2.0</p>

www/js/index.js

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var map = null;
2828
/////var lastObj = { obj: null, marker: null, /*no longer used: */pred: null, land: null };
2929
var lastMarker = null;
3030

31-
var mypos = {lat: 48.56, lon: 13.43, hdop: 25};
31+
var mypos = {lat: 48.56, lon: 13.43, hdop: 25, alt: 480};
3232
var myposMarker = null;
3333

3434
var ballonIcon, landIcon, burstIcon;
@@ -380,17 +380,19 @@ function onDeviceReady() {
380380
ttgoStatus = L.easyButton( {
381381
ttgourl: "http://192.168.42.1",
382382
states: [{ stateName: 'offline',
383-
icon: '<span class="ttgostatus">' + crossMark + '</span>'
383+
//icon: '<span class="ttgostatus">' + crossMark + '</span>'
384+
icon: '<img width=24 height=24 src="img/ttgooff.png"/>'
384385
, onClick: function(btn, map) { /* just for testing btn.state('online');*/ }
385386
},
386387
{ stateName: 'online',
387-
icon: '<span style="color: transparent; text-shadow: 0 0 0 #009900; font-size:15pt" class="ttgostatus">' + checkMark + '</span>',
388+
//icon: '<span style="color: transparent; text-shadow: 0 0 0 #009900; font-size:15pt" class="ttgostatus">' + checkMark + '</span>',
389+
icon: '<img width=24 height=24 src="img/ttgoon.png"/>',
388390
onClick: function(btn, map) {
389391
var app = cordova.InAppBrowser.open(btn.ttgourl, '_blank', "location=yes,beforeload=yes");
390392
app.addEventListener("loadstart", function(e) {
391393
if(e.url.startsWith("geo:")) {
392394
//alert("external: "+e.url);
393-
RdzWx.showmap(e.url);
395+
RdzWx.showmap(e.url, function(){});
394396
app.close();
395397
}
396398
});
@@ -402,7 +404,6 @@ function onDeviceReady() {
402404
ttgoStatus.state('offline');
403405
ttgoStatus.addTo(map);
404406

405-
// '<span class="ttgosttus">&#9989;</span>', )
406407
L.control.mousePosition({position: 'bottomleft', emptyString: ''}).addTo(map);
407408

408409

@@ -444,6 +445,15 @@ function onDeviceReady() {
444445
});
445446
myposMarker.addTo(map);
446447
updateMypos(mypos);
448+
myposMarker.bindPopup( function(lay) {
449+
var alt = lay.getLatLng().alt;
450+
if(!alt) alt = 0;
451+
return '<div class="pop-header"><img src="css/images/marker-icon.png"/><h4> Current position </h4></div>' +
452+
'<p>Lat: ' + lay.getLatLng().lat.toFixed(5) + '<br>' +
453+
'Lon: ' + lay.getLatLng().lng.toFixed(5) + '<br>' +
454+
'Altutide: ' + alt + '</p>' +
455+
'<p>HDOP: ' + (lay.hdop>0 ? lay.hdop : 'no GPS fix') + '</p>';
456+
});
447457

448458
document.addEventListener("pause", onPause);
449459
document.addEventListener("resume", onResume);
@@ -466,7 +476,7 @@ function onPause() {
466476
if(ttgoStatus.state() == 'offline') {
467477
console.log("onPause(): TTGO is offline, stopping all activities");
468478
window.localStorage.setItem('lastgps', JSON.stringify(mypos));
469-
RdzWx.stop(function(){});
479+
RdzWx.stop("", function(){});
470480
} else {
471481
console.log("onPause(): TTGO is online, keeping activities running in background");
472482
}
@@ -481,7 +491,7 @@ function onResume() {
481491
function onBackButton() {
482492
console.log("onBackButton(): Exit");
483493
window.localStorage.setItem('lastgps', JSON.stringify(mypos));
484-
RdzWx.stop(function(){});
494+
RdzWx.stop("", function(){});
485495
navigator.app.exitApp(); // note: this will also call onPause()
486496
}
487497

@@ -545,11 +555,11 @@ function getPrediction(refobj) {
545555
var tParams = {
546556
"launch_latitude": refobj.obj.lat,
547557
"launch_longitude": refobj.obj.lon,
548-
"launch_altitude": refobj.obj.alt,
558+
"launch_altitude": refobj.obj.alt.toFixed(1),
549559
"launch_datetime": new Date().toISOString().split('.')[0] + 'Z',
550560
"ascent_rate": asc,
551561
"descent_rate": desc,
552-
"burst_altitude": refobj.obj.alt+2,
562+
"burst_altitude": (refobj.obj.alt+2).toFixed(1),
553563
"profile": "standard_profile",
554564
}
555565
var vs = refobj.obj.vs;
@@ -593,7 +603,7 @@ function getPrediction(refobj) {
593603
separator: true
594604
}, {
595605
text: "Export to map app",
596-
callback: function(e) { ll=refobj.land.getLatLng(); uri="geo:0:0?q="+ll.lat+","+ll.lng+"(X-"+refobj.obj.id+")"; RdzWx.showmap(uri); }
606+
callback: function(e) { ll=refobj.land.getLatLng(); uri="geo:0:0?q="+ll.lat+","+ll.lng+"(X-"+refobj.obj.id+")"; RdzWx.showmap(uri, function(){}); }
597607
}]
598608
});
599609
refobj.land.addTo(map);
@@ -647,7 +657,7 @@ function updateMypos(obj) {
647657
return;
648658
}
649659
mypos = obj;
650-
var pos = [obj.lat, obj.lon];
660+
var pos = [obj.lat, obj.lon, obj.alt];
651661
myposMarker.setLatLng(pos);
652662
myposMarker.update();
653663
if(myposMarker.hdop) {
@@ -740,6 +750,7 @@ function updateMarkerTooltip(marker, obj) {
740750
marker.tt.setContent(tt);
741751
marker.setLatLng( new L.LatLng(obj.lat, obj.lon));
742752
marker.obj = obj;
753+
marker.getPopup().update();
743754
marker.update();
744755
}
745756
function createNewMarker(obj) {
@@ -765,7 +776,7 @@ function createNewMarker(obj) {
765776
separator: true
766777
}, {
767778
text: "Export to map app",
768-
callback: function(e) { uri="geo:0:0?q="+marker.obj.lat+","+marker.obj.lon+"("+marker.obj.id+")"; RdzWx.showmap(uri); }
779+
callback: function(e) { uri="geo:0:0?q="+marker.obj.lat+","+marker.obj.lon+"("+marker.obj.id+")"; RdzWx.showmap(uri, function(){}); }
769780
}, {
770781
separator: true
771782
}, {
@@ -777,13 +788,34 @@ function createNewMarker(obj) {
777788
marker.path = poly;
778789
marker.addTo(map);
779790
poly.addTo(map);
780-
var tooltip = L.tooltip({ direction: 'right', permanent: true, className: 'sondeTooltip', offset: [10,-16], interactive: false, opacity: 0.6 });
791+
var tooltip = L.tooltip({ direction: 'right', permanent: true, className: 'sondeTooltip', offset: [10,-16], interactive: true, opacity: 0.6 });
792+
781793
marker.bindTooltip(tooltip);
782794
marker.tt = tooltip;
783795
marker.vsavg = obj.vs;
784796
marker.obj = obj;
797+
798+
marker.bindPopup( function(lay) {
799+
var alt = lay.getLatLng().alt;
800+
if(!alt) alt = 0;
801+
return '<div class="pop-header"><img src="img/ballon.png"/><h4> ' + lay.obj.id + '</h4></div>' +
802+
'<p>Serial: '+ lay.obj.ser + '<br>' +
803+
''+(new Date(1000*lay.obj.time)).toString().split(" (")[0] + '<br/>' +
804+
'(' + formathms( new Date().valueOf() / 1000 - lay.obj.time ) + ' ago) <br/>' +
805+
'Frame #'+lay.obj.frame+', Sats='+lay.obj.sats + '<br/>' +
806+
'burstKT='+formathms(lay.obj.burstKT)+'<br>launchKT='+formathms(lay.obj.launchKT)+'<br>countdown='+formathms(lay.obj.countKT+lay.obj.crefKT-lay.obj.frame)+'<br/>' +
807+
'</p>';
808+
});
809+
785810
return marker;
786811
}
812+
function formathms(ts) {
813+
if(typeof ts === "undefined") { return "<undef>"; }
814+
var h = Math.floor(ts/3600); ts-=h*3600;
815+
var m = Math.floor(ts/60); ts=Math.floor(ts-m*60);
816+
return ("0"+h).slice(-2) + ":" + ("0"+m).slice(-2) + ":" + ("0"+ts).slice(-2);
817+
}
818+
787819
function deleteMarker(m) {
788820
removePrediction(m);
789821
m.unbindTooltip();

0 commit comments

Comments
 (0)